GitHub Action
ansible-test
A composite GitHub Action encapsulating the GitHub Actions CI/CD workflows setup necessary for testing Ansible collection repositories on GitHub.
To use the action add the following step to your workflow file (e.g.
.github/workflows/ansible-test.yml
)
- name: Perform integration testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.14
pre-test-cmd: echo This runs before the ansible-test invocation
target-python-version: 3.9
controller-python-version: auto
testing-type: integration
test-deps: ansible.netcommon
- name: Perform sanity testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.14
testing-type: sanity
- name: Perform unit testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.14
pre-test-cmd: echo This runs before the ansible-test invocation
target-python-version: 3.9
testing-type: units
test-deps: >-
ansible.netcommon
ansible.utils
Pro tip: instead of using branch pointers, like
main
, pin versions of Actions that you use to tagged versions or SHA-1 commit identifiers. This will make your workflows more secure and better reproducible, saving you from sudden and unpleasant surprises.
ansible-core
Git revision. See https://github.com/ansible/ansible/tags
and https://github.com/ansible/ansible/branches/all?query=stable- for
ideas. The repository this refers to can be changed with the
ansible-core-github-repository-slug
option. (DEFAULT: stable-2.14
)
The GitHub repository slug from which to check out ansible-core
(DEFAULT: ansible/ansible
)
Controller Python version. This is only used for integration tests and
ansible-core 2.12 or later when target-python-version
is also specified
(DEFAULT: auto
)
Path to collection root relative to repository root (DEFAULT: .
)
A pre-checked out collection directory that's already on disk (OPTIONAL, substitutes getting the source from the remote Git repository if set, also this action will not attempt to mutate its contents)
A container image spawned by ansible-test
(OPTIONAL)
Committish to check out, unused if collection-src-directory
is set (OPTIONAL)
Environment Python version. The value auto
uses the maximum Python
version supported by the given ansible-core-version
(DEFAULT: auto
)
Extra command to invoke before ansible-test (OPTIONAL)
(DEPRECATED) Use origin-python-version
instead.
ansible-test
TARGET (OPTIONAL)
Target Python version (OPTIONAL)
ansible-test
subcommand (REQUIRED, Must be one of 'sanity', 'units'
or 'integration')
Test dependencies to install along with this collection (OPTIONAL)
Path to the auto-installed ansible-playbook
executable
Path to the auto-installed ansible-test
executable
Path to the auto-downloaded collection src directory
Detected collection FQCN
Detected collection name
Detected collection namespace
The python-path
output value of the setup-python action
The actual value of origin-python-version
passed to the setup-python action
Check out the Data-Bene/ansible-test-versions-gh-action to explore a semi-automatic job matrix generation for testing your collections. This project is not maintained by us but it is a rather promising way of configuring your GitHub Actions CI/CD workflows.