In most cases, you should use the ansible-community/project-template
when creating a new repository. Using the project-template
populates the new repository with recommended content such as license, DCO, and code of conduct.
If required, you can move over content and contributor history from a source repository into your new repository. An alternative might be to use the GitHub importer at https://github.com/new/import to create a new repo that preserves contributor history and all content from the original source repo.
The GitHub importer allows you to basically mirror a repository without forking it. You can then add and remove content as needed. However if there is a need to change the license or other essential files, it's better to use the project-template
. This way you have the correct license from the initial commit.
When moving content from one repository to another, it is important to preserve contributor history. This section outlines some general techniques for moving git revision history.
There are many different strategies and options to achieve this, depending on your goals. In some cases, you might want to preserve the entire chain of commits. For larger repositories with years of history, you might want to preserve only portions of the commit chain to prevent bloating the new repository.
A straightforward method of moving contributor history is to add the source repository as a remote of the new repository and then merge the history.
Another option is to get a clean export of the git history from the source repository and then copy it to the new repository. This option might be suitable when the new repository does not have any commits yet.
Teams can make their own informed choices on project conventions and code related configuration like *.toml
files. This section highlights some initial GitHub settings that might be useful for new Ansible projects.
Enforcement status: Active
Branch targeting criteria: All branches
Branch rules:
Restrict deletions
Require signed commits
Require a pull request before merging
Required approvals = 2
Require approval of the most recent reviewable push
Require conversation resolution before merging
Block force pushes
Ansible projects should use the forum for discussions and help queries. Likewise, Ansible projects should provide actively maintained docsites hosted on Read The Docs.
Wikis
Discussions
Merge commits can result in cluttered git history. On the other hand, merge commits are useful, especially in cases when merging a series of related commits that you later want to cherry-pick separately.
Starting out with a new repository it can be beneficial to disable merge commits and squash only while changes occur more frequently. However this is generally a matter of preference and ultimately for teams to discuss and decide amongst themselves.
Allow merge commits
Allow squash merging
(default)Allow rebase merging
(default)Here is a basic rundown of the static analysis and code scanning tools for Ansible project repositories. For help with these tools, use the Red Hat internal slack channel, #ansible-github-admins
.
Projects in the Ansible GitHub org have access to SonarCloud static analysis tooling. PRs will have comments from Sonarcloud detailing the analysis of the delta in the subject PR, and a passing scan will be required for the final merge.
You can configure SonarCloud analysis using a properties file in your repo, see Additional analysis configuration.
To get set up with SonarCloud or ask questions, use the Red Hat internal slack channel #wg-aap-sonarcloud
.
Pre-commit ci is a tool that automatically fixes trivial issues and problems in pull requests, like code formatting.
https://github.com/apps/pre-commit-ci/installations/19541297
Codecov is a recommended tool for quality gates and ensuring test coverage for PRs.
https://github.com/apps/codecov/installations/398480
Ansible projects should provide docsites with markdown or RST source files.
Use either the MKDocs or Sphinx theme:
ansible
namespaceAnsible projects that are managed by Red Hat should be available under the ansible
namespace in Read The Docs. To do this, your project needs to be added as a subproject to https://readthedocs.org/projects/ansible/
If you do not have access to the ansible
project, you can ping one of the maintainers like Don Naro, Sviat, Shane, gundalow, or Sandra McCann.
Be sure to enable PR previews in Read The Docs, see How to configure pull request builds.