Contributing to Ansible Navigator

Some background:

The ansible-navigator code base is not just for it’s users but current and future developers. Over time we have adopted a few tools that help us maintain it and you contribute.

  1. mypy (Helps with type checking)

  2. pylint (lints all the things)

  3. code-spell (prevents typos in code)

  4. isort (sorts import statements)

Note

In early development cycles, a decision was made to use black as a formatter which is why current pull-requests are required to pass a black --diff check of the source tree. The decision to use black is left to individual developers as the formatting changes it makes can be achieved without it.

Details can be found below on how to run these manually, our CI will also check them for you.

In order to contribute, you’ll need to:

  1. Fork the repository.

  2. Create a branch, push your changes there. Don’t forget to include news files for the changelog.

  3. Send it to us as a PR.

  4. Iterate on your PR, incorporating the requested improvements and participating in the discussions.

Prerequisites:

  1. Have tox.

  2. Use tox to run the tests.

  3. Before sending a PR, make sure that lint passes:

    $ tox -e lint
    lint create: .tox/lint
    lint installdeps: .[test]
    lint installed: ...
    lint run-test-pre: PYTHONHASHSEED='4242713142'
    lint run-test: commands[0] | pylint ansible_navigator tests ...
    ...
    _________________________________ summary __________________________________
    lint: commands succeeded
    congratulations :)
    

    Tip

    Because the version of python is pinned to a specific version to ensure the outcome of running tox -e lint locally is the same as tox -e lint being run by github actions, you may see the following error: RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.XX'. This indicates the version of python that needs to be installed for tox to run locally.

Contributing docs

We use Sphinx to generate our docs website. You can trigger the process locally by executing:

$ tox -e docs
docs create: .tox/docs
docs installdeps: --editable .[docs]
...

========================================================================================================================

Documentation available under:

    file://.tox/docs/docs_out/index.html

To serve docs, use

    $ python3 -m http.server --directory  ".tox/docs/docs_out" 0

========================================================================================================================
_______________________________________________________ summary ________________________________________________________
  docs: commands succeeded
  congratulations :)

It is also integrated with Read The Docs that builds and publishes each commit to the main branch and generates live docs previews for each pull request.

The sources of the Sphinx documents use reStructuredText as a de-facto standard. But in order to make contributing docs more beginner-friendly, we have integrated MyST parser allowing us to also accept new documents written in an extended version of Markdown that supports using Sphinx directives and roles. Read the docs to learn more on how to use it.

Adding change notes with your PRs

It is very important to maintain a log for news of how updating to the new version of the software will affect end-users. This is why we enforce collection of the change fragment files in pull requests as per Towncrier philosophy.

The idea is that when somebody makes a change, they must record the bits that would affect end-users only including information that would be useful to them. Then, when the maintainers publish a new release, they’ll automatically use these records to compose a change log for the respective version. It is important to understand that including unnecessary low-level implementation related details generates noise that is not particularly useful to the end-users most of the time. And so such details should be recorded in the Git history rather than a changelog.

Alright! So how do I add a news fragment?

To submit a change note about your PR, add a text file into the docs/changelog-fragments.d/ folder. It should contain an explanation of what applying this PR will change in the way end-users interact with the project. One sentence is usually enough but feel free to add as many details as you feel necessary for the users to understand what it means.

Use the past tense for the text in your fragment because, combined with others, it will be a part of the “news digest” telling the readers what changed in a specific version of the library since the previous version. You should also use MyST Markdown syntax for highlighting code (inline or block), linking parts of the docs or external sites. At the end, sign your change note by adding -- by {user}`github-username (replace github-username with your own!).

Finally, name your file following the convention that Towncrier understands: it should start with the number of an issue or a PR followed by a dot, then add a patch type, like feature, bugfix, doc, misc etc., and add .md as a suffix. If you need to add more than one fragment, you may add an optional sequence number (delimited with another period) between the type and the suffix.

Examples for changelog entries adding to your Pull Requests

File docs/changelog-fragments.d/666.doc.md:

Added a `{user}` role to Sphinx config -- by {user}`webknjaz`

File docs/changelog-fragments.d/116.feature.md:

Added support for nested module options (sub_options)
-- by {user}`tomaciazek`

File docs/changelog-fragments.d/140.bugfix.md:

Implemented opening standalone Ansible files that have no workspace
associated -- by {user}`ganeshrn`

Tip

See pyproject.toml for all available categories (tool.towncrier.type).