name: CI on: # Run CI against all pushes (direct commits, also merged PRs), Pull Requests push: branches: - main - stable-* pull_request: # Run CI once per day (at 04:45 UTC) schedule: - cron: '45 4 * * *' jobs: ### # Sanity tests (REQUIRED) # # https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html sanity: name: Sanity (Ⓐ${{ matrix.ansible }}) strategy: matrix: ansible: # It's important that Sanity is tested against all stable-X.Y branches # Testing against `devel` may fail as new tests are added. - stable-2.9 - stable-2.10 - stable-2.11 - stable-2.12 - stable-2.13 - devel runs-on: ubuntu-latest steps: # ansible-test requires the collection to be in a directory in the form # .../ansible_collections/community/hrobot/ - name: Check out code uses: actions/checkout@v3 with: path: ansible_collections/community/hrobot - name: Set up Python uses: actions/setup-python@v3 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. python-version: '3.10' # Install the head of the given branch (devel, stable-2.10) - name: Install ansible-base (${{ matrix.ansible }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check # run ansible-test sanity inside of Docker. # The docker container has all the pinned dependencies that are required # and all python versions ansible supports. - name: Run sanity tests run: ansible-test sanity --docker -v --color --coverage working-directory: ./ansible_collections/community/hrobot # ansible-test support producing code coverage date - name: Generate coverage report run: ansible-test coverage xml -v --requirements --group-by command --group-by version working-directory: ./ansible_collections/community/hrobot # See the reports at https://codecov.io/gh/ansible-collections/community.hrobot - uses: codecov/codecov-action@v3 with: fail_ci_if_error: false ### # Unit tests (OPTIONAL) # # https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html units: runs-on: ubuntu-latest name: Units (Ⓐ${{ matrix.ansible }}) strategy: # As soon as the first unit test fails, cancel the others to free up the CI queue fail-fast: true matrix: ansible: - stable-2.9 - stable-2.10 - stable-2.11 - stable-2.12 - stable-2.13 - devel steps: - name: Check out code uses: actions/checkout@v3 with: path: ansible_collections/community/hrobot - name: Set up Python uses: actions/setup-python@v3 with: # it is just required to run that once as "ansible-test units" in the docker image # will run on all python versions it supports. python-version: '3.10' - name: Install ansible-base (${{ matrix.ansible }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check # OPTIONAL If your unit test requires Python libraries from other collections # Install them like this - name: Install collection dependencies run: git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ansible_collections/community/internal_test_tools # NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) # run: ansible-galaxy collection install community.internal_test_tools -p . # Run the unit tests - name: Run unit test run: ansible-test units -v --color --docker --coverage working-directory: ./ansible_collections/community/hrobot # ansible-test support producing code coverage date - name: Generate coverage report run: ansible-test coverage xml -v --requirements --group-by command --group-by version working-directory: ./ansible_collections/community/hrobot # See the reports at https://codecov.io/gh/ansible-collections/community.hrobot - uses: codecov/codecov-action@v3 with: fail_ci_if_error: false