| 1 | # README FIRST |
| 2 | # 1. If you don't have unit tests, remove that section. |
| 3 | # 2. If your collection depends on other collections ensure they are installed, |
| 4 | # add them to the "test-deps" input. |
| 5 | # 3. For the comprehensive list of the inputs supported by the |
| 6 | # ansible-community/ansible-test-gh-action GitHub Action, see |
| 7 | # https://github.com/marketplace/actions/ansible-test. |
| 8 | # 4. If you want to prevent merging PRs that do not pass all tests, |
| 9 | # make sure to add the "check" job to your repository branch |
| 10 | # protection once this workflow is added. |
| 11 | # It is also possible to tweak which jobs are allowed to fail. See |
| 12 | # https://github.com/marketplace/actions/alls-green#gotchas for more detail. |
| 13 | # 5. If you need help please ask in #ansible-community on the Libera.chat IRC |
| 14 | # network. |
| 15 | |
| 16 | name: CI |
| 17 | on: |
| 18 | # Run CI against all pushes (direct commits, also merged PRs), Pull Requests |
| 19 | push: |
| 20 | branches: |
| 21 | - main |
| 22 | - develop |
| 23 | pull_request: |
| 24 | # Run CI once per day (at 06:00 UTC) |
| 25 | # This ensures that even if there haven't been commits that we are still |
| 26 | # testing against latest version of ansible-test for each ansible-core |
| 27 | # version |
| 28 | schedule: |
| 29 | - cron: '0 6 * * *' |
| 30 | |
| 31 | concurrency: |
| 32 | group: >- |
| 33 | ${{ github.workflow }}-${{ |
| 34 | github.event.pull_request.number || github.sha |
| 35 | }} |
| 36 | cancel-in-progress: true |
| 37 | |
| 38 | jobs: |
| 39 | |
| 40 | ### |
| 41 | # Sanity tests (REQUIRED) |
| 42 | # |
| 43 | # https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html |
| 44 | |
| 45 | sanity: |
| 46 | name: Sanity (Ⓐ${{ matrix.ansible }}) |
| 47 | strategy: |
| 48 | matrix: |
| 49 | ansible: |
| 50 | # It's important that Sanity is tested against all stable-X.Y branches |
| 51 | # Testing against `devel` may fail as new tests are added. |
| 52 | # An alternative to `devel` is the `milestone` branch with |
| 53 | # gets synchronized with `devel` every few weeks and therefore |
| 54 | # tends to be a more stable target. Be aware that it is not updated |
| 55 | # around creation of a new stable branch, this might cause a problem |
| 56 | # that two different versions of ansible-test use the same sanity test |
| 57 | # ignore.txt file. |
| 58 | - stable-2.16 |
| 59 | - stable-2.17 |
| 60 | - stable-2.18 |
| 61 | - stable-2.19 |
| 62 | # - devel |
| 63 | # - milestone |
| 64 | # Ansible-test on various stable branches does not yet work well with cgroups v2. |
| 65 | # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 |
| 66 | # image for these stable branches. The list of branches where this is necessary will |
| 67 | # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 |
| 68 | # for the latest list. |
| 69 | runs-on: >- |
| 70 | ${{ contains(fromJson( |
| 71 | '["stable-2.9", "stable-2.10", "stable-2.11"]' |
| 72 | ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} |
| 73 | steps: |
| 74 | # Run sanity tests inside a Docker container. |
| 75 | # The docker container has all the pinned dependencies that are |
| 76 | # required and all Python versions Ansible supports. |
| 77 | - name: Perform sanity testing |
| 78 | # See the documentation for the following GitHub action on |
| 79 | # https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md |
| 80 | uses: ansible-community/ansible-test-gh-action@release/v1 |
| 81 | with: |
| 82 | ansible-core-version: ${{ matrix.ansible }} |
| 83 | # origin-python-version: 3.10 |
| 84 | testing-type: sanity |
| 85 | # OPTIONAL If your sanity tests require code |
| 86 | # from other collections, install them like this |
| 87 | # test-deps: >- |
| 88 | # ansible.netcommon |
| 89 | # ansible.utils |
| 90 | # OPTIONAL If set to true, will test only against changed files, |
| 91 | # which should improve CI performance. See limitations on |
| 92 | # https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection |
| 93 | pull-request-change-detection: true |
| 94 | |
| 95 | ### |
| 96 | # Unit tests (OPTIONAL) |
| 97 | # |
| 98 | # https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html |
| 99 | |
| 100 | units: |
| 101 | # Ansible-test on various stable branches does not yet work well with cgroups v2. |
| 102 | # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 |
| 103 | # image for these stable branches. The list of branches where this is necessary will |
| 104 | # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 |
| 105 | # for the latest list. |
| 106 | runs-on: >- |
| 107 | ${{ contains(fromJson( |
| 108 | '["stable-2.9", "stable-2.10", "stable-2.11"]' |
| 109 | ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} |
| 110 | name: Units (Ⓐ${{ matrix.ansible }}) |
| 111 | strategy: |
| 112 | # As soon as the first unit test fails, cancel the others to free up the CI queue |
| 113 | fail-fast: true |
| 114 | matrix: |
| 115 | ansible: |
| 116 | # The commented branches below are EOL, |
| 117 | # do you really need your collection to support them if it still does? |
| 118 | - stable-2.16 |
| 119 | - stable-2.17 |
| 120 | - stable-2.18 |
| 121 | - stable-2.19 |
| 122 | python: |
| 123 | - '3.10' |
| 124 | - '3.11' |
| 125 | - '3.12' |
| 126 | - '3.13' |
| 127 | exclude: |
| 128 | # Python 3.10 will not be supported in ansible 2.18 and later. Python 3.13 support started with ansible 2.18. |
| 129 | - ansible: stable-2.16 |
| 130 | python: '3.13' |
| 131 | - ansible: stable-2.17 |
| 132 | python: '3.13' |
| 133 | - ansible: stable-2.18 |
| 134 | python: '3.10' |
| 135 | - ansible: stable-2.19 |
| 136 | python: '3.10' |
| 137 | |
| 138 | |
| 139 | steps: |
| 140 | - name: >- |
| 141 | Install paramiko dependency |
| 142 | run: pip install paramiko |
| 143 | - name: >- |
| 144 | Perform unit testing against |
| 145 | Ansible version ${{ matrix.ansible }} |
| 146 | under Python ${{ matrix.python }} |
| 147 | # See the documentation for the following GitHub action on |
| 148 | # https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md |
| 149 | uses: ansible-community/ansible-test-gh-action@release/v1 |
| 150 | with: |
| 151 | ansible-core-version: ${{ matrix.ansible }} |
| 152 | target-python-version: ${{ matrix.python }} |
| 153 | testing-type: units |
| 154 | # OPTIONAL If your unit tests require code |
| 155 | # from other collections, install them like this |
| 156 | # test-deps: >- |
| 157 | # ansible.netcommon |
| 158 | # ansible.utils |
| 159 | # OPTIONAL If set to true, will test only against changed files, |
| 160 | # which should improve CI performance. See limitations on |
| 161 | # https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection |
| 162 | pull-request-change-detection: true |
| 163 | |
| 164 | |
| 165 | ### |
| 166 | # Integration tests (RECOMMENDED) |
| 167 | # |
| 168 | # https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html |
| 169 | |
| 170 | |
| 171 | # If the application you are testing is available as a docker container and you want to test |
| 172 | # multiple versions see the following for an example: |
| 173 | # https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows |
| 174 | |
| 175 | integration: |
| 176 | # Ansible-test on various stable branches does not yet work well with cgroups v2. |
| 177 | # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 |
| 178 | # image for these stable branches. The list of branches where this is necessary will |
| 179 | # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 |
| 180 | # for the latest list. |
| 181 | runs-on: >- |
| 182 | ${{ contains(fromJson( |
| 183 | '["stable-2.9", "stable-2.10", "stable-2.11"]' |
| 184 | ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} |
| 185 | name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) |
| 186 | strategy: |
| 187 | fail-fast: false |
| 188 | matrix: |
| 189 | ansible: |
| 190 | # The commented branches below are EOL, |
| 191 | # do you really need your collection to support them if it still does? |
| 192 | - stable-2.16 |
| 193 | - stable-2.17 |
| 194 | - stable-2.18 |
| 195 | - stable-2.19 |
| 196 | # - devel |
| 197 | # - milestone |
| 198 | python: |
| 199 | - '3.10' |
| 200 | - '3.11' |
| 201 | - '3.12' |
| 202 | - '3.13' |
| 203 | exclude: |
| 204 | # Python 3.10 will not be supported in ansible 2.18 and later. Python 3.13 support started with ansible 2.18. |
| 205 | - ansible: stable-2.16 |
| 206 | python: '3.13' |
| 207 | - ansible: stable-2.17 |
| 208 | python: '3.13' |
| 209 | - ansible: stable-2.18 |
| 210 | python: '3.10' |
| 211 | - ansible: stable-2.19 |
| 212 | python: '3.10' |
| 213 | |
| 214 | steps: |
| 215 | - name: >- |
| 216 | Perform integration testing against |
| 217 | Ansible version ${{ matrix.ansible }} |
| 218 | under Python ${{ matrix.python }} |
| 219 | # See the documentation for the following GitHub action on |
| 220 | # https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md |
| 221 | uses: ansible-community/ansible-test-gh-action@release/v1 |
| 222 | with: |
| 223 | ansible-core-version: ${{ matrix.ansible }} |
| 224 | # OPTIONAL command to run before invoking `ansible-test integration` |
| 225 | # pre-test-cmd: |
| 226 | target-python-version: ${{ matrix.python }} |
| 227 | testing-type: integration |
| 228 | # OPTIONAL If your integration tests require code |
| 229 | # from other collections, install them like this |
| 230 | test-deps: ansible.netcommon |
| 231 | # OPTIONAL If set to true, will test only against changed files, |
| 232 | # which should improve CI performance. See limitations on |
| 233 | # https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection |
| 234 | pull-request-change-detection: true |
| 235 | |
| 236 | |
| 237 | check: # This job does nothing and is only used for the branch protection |
| 238 | # or multi-stage CI jobs, like making sure that all tests pass before |
| 239 | # a publishing job is started. |
| 240 | if: always() |
| 241 | |
| 242 | needs: |
| 243 | - sanity |
| 244 | - units |
| 245 | - integration |
| 246 | |
| 247 | runs-on: ubuntu-latest |
| 248 | |
| 249 | steps: |
| 250 | - name: Decide whether the needed jobs succeeded or failed |
| 251 | uses: re-actors/alls-green@release/v1 |
| 252 | with: |
| 253 | jobs: ${{ toJSON(needs) }} |