diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0a25f48 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +--- +name: Test collection + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + changelog: + uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + sanity: + uses: ansible-network/github_actions/.github/workflows/sanity.yml@main + unit-galaxy: + uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main + unit-source: + uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main + with: + collection_pre_install: >- + git+https://github.com/ansible-collections/ansible.utils.git + git+https://github.com/ansible-collections/ansible.netcommon.git + all_green: + if: ${{ always() }} + needs: + - changelog + - sanity + - unit-galaxy + - unit-source + runs-on: ubuntu-latest + steps: + - run: >- + python -c "assert set([ + '${{ needs.changelog.result }}', + '${{ needs.sanity.result }}', + '${{ needs.unit-galaxy.result }}', + '${{ needs.unit-source.result }}' + ]) == {'success'}" diff --git a/changelogs/fragments/gha.yaml b/changelogs/fragments/gha.yaml new file mode 100644 index 0000000..2d667e4 --- /dev/null +++ b/changelogs/fragments/gha.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Enable unit and sanity tests using Github actions diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4b00287 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[tool.black] +line-length = 79 + +[tool.pytest.ini_options] +addopts = ["-vvv", "-n", "2", "--log-level", "WARNING", "--color", "yes"] +testpaths = ["tests"] +filterwarnings = ['ignore:AnsibleCollectionFinder has already been configured'] diff --git a/test-requirements.txt b/test-requirements.txt index 5baa138..8359fc5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,8 @@ black==22.3.0 ; python_version > '3.5' flake8 mock pexpect pytest-xdist yamllint coverage==4.5.4 +git+https://github.com/ansible-community/pytest-ansible-units.git