| 1 |
name: CI |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [master] |
| 5 |
pull_request: |
| 6 |
schedule: |
| 7 |
# * is a special character in YAML so you have to quote this string |
| 8 |
- cron: '0 8 * * *' |
| 9 |
env: |
| 10 |
python_version: '3.11' |
| 11 |
jobs: |
| 12 |
build: |
| 13 |
name: Build collection |
| 14 |
runs-on: ubuntu-latest |
| 15 |
strategy: |
| 16 |
fail-fast: false |
| 17 |
matrix: |
| 18 |
ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19] |
| 19 |
steps: |
| 20 |
- name: Check out code |
| 21 |
uses: actions/checkout@v4 |
| 22 |
|
| 23 |
- name: Set up Python ${{ env.python_version }} |
| 24 |
uses: actions/setup-python@v5 |
| 25 |
with: |
| 26 |
python-version: ${{ env.python_version }} |
| 27 |
|
| 28 |
- name: Install ansible-base (${{ matrix.ansible }}) |
| 29 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check |
| 30 |
|
| 31 |
- name: Build a collection tarball |
| 32 |
run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" |
| 33 |
|
| 34 |
- name: Store migrated collection artifacts |
| 35 |
uses: actions/upload-artifact@v4 |
| 36 |
with: |
| 37 |
name: collection-${{ matrix.ansible }} |
| 38 |
path: .cache/collection-tarballs |
| 39 |
|
| 40 |
black-formating: |
| 41 |
name: Using Black to check formating |
| 42 |
runs-on: ubuntu-latest |
| 43 |
continue-on-error: true |
| 44 |
steps: |
| 45 |
- name: Check out code |
| 46 |
uses: actions/checkout@v4 |
| 47 |
|
| 48 |
- name: Run black against code |
| 49 |
uses: psf/black@stable |
| 50 |
with: |
| 51 |
options: "--check --diff --color -l 159" |
| 52 |
|
| 53 |
importer: |
| 54 |
name: Galaxy-importer check |
| 55 |
needs: |
| 56 |
- build |
| 57 |
- black-formating |
| 58 |
runs-on: ubuntu-latest |
| 59 |
strategy: |
| 60 |
matrix: |
| 61 |
ansible: [stable-2.18] |
| 62 |
steps: |
| 63 |
- name: Set up Python ${{ env.python_version }} |
| 64 |
uses: actions/setup-python@v5 |
| 65 |
with: |
| 66 |
python-version: ${{ env.python_version }} |
| 67 |
|
| 68 |
- name: Install ansible-base (${{ matrix.ansible }}) |
| 69 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check |
| 70 |
|
| 71 |
- name: Download migrated collection artifacts |
| 72 |
uses: actions/download-artifact@v4 |
| 73 |
with: |
| 74 |
name: collection-${{ matrix.ansible }} |
| 75 |
path: .cache/collection-tarballs |
| 76 |
|
| 77 |
- name: Install the collection tarball |
| 78 |
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 79 |
|
| 80 |
- name: Install galaxy-importer |
| 81 |
run: pip install galaxy-importer |
| 82 |
|
| 83 |
- name: Create galaxy-importer directory |
| 84 |
run: sudo mkdir -p /etc/galaxy-importer |
| 85 |
|
| 86 |
- name: Create galaxy-importer.cfg |
| 87 |
run: | |
| 88 |
sudo cp \ |
| 89 |
/home/runner/.ansible/collections/ansible_collections/cisco/aci/.github/workflows/galaxy-importer.cfg \ |
| 90 |
/etc/galaxy-importer/galaxy-importer.cfg |
| 91 |
|
| 92 |
- name: Run galaxy-importer check |
| 93 |
run: | |
| 94 |
python -m galaxy_importer.main .cache/collection-tarballs/cisco-*.tar.gz \ |
| 95 |
| tee .cache/collection-tarballs/log.txt \ |
| 96 |
&& sudo cp ./importer_result.json .cache/collection-tarballs/importer_result.json |
| 97 |
|
| 98 |
- name: Check warnings and errors |
| 99 |
run: if grep -E 'WARNING|ERROR' .cache/collection-tarballs/log.txt; then exit 1; else exit 0; fi |
| 100 |
|
| 101 |
- name: Store galaxy_importer check log file |
| 102 |
uses: actions/upload-artifact@v4 |
| 103 |
with: |
| 104 |
name: galaxy-importer-log |
| 105 |
path: .cache/collection-tarballs/importer_result.json |
| 106 |
|
| 107 |
sanity: |
| 108 |
name: Sanity in ubuntu-latest |
| 109 |
needs: |
| 110 |
- importer |
| 111 |
runs-on: ubuntu-latest |
| 112 |
strategy: |
| 113 |
fail-fast: false |
| 114 |
matrix: |
| 115 |
ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19] |
| 116 |
steps: |
| 117 |
- name: Set up Python ${{ env.python_version }} |
| 118 |
uses: actions/setup-python@v5 |
| 119 |
with: |
| 120 |
python-version: ${{ env.python_version }} |
| 121 |
|
| 122 |
- name: Install ansible-base (${{ matrix.ansible }}) |
| 123 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check |
| 124 |
|
| 125 |
- name: Install coverage (v4.5.4) |
| 126 |
run: pip install coverage==4.5.4 |
| 127 |
|
| 128 |
- name: Download migrated collection artifacts |
| 129 |
uses: actions/download-artifact@v4 |
| 130 |
with: |
| 131 |
name: collection-${{ matrix.ansible }} |
| 132 |
path: .cache/collection-tarballs |
| 133 |
|
| 134 |
- name: Install the collection tarball |
| 135 |
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 136 |
|
| 137 |
- name: Run sanity tests |
| 138 |
run: ansible-test sanity --docker -v --color --truncate 0 --coverage |
| 139 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 140 |
|
| 141 |
- name: Generate coverage report |
| 142 |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version |
| 143 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 144 |
|
| 145 |
- name: Push coverate report to codecov.io |
| 146 |
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F sanity |
| 147 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 148 |
|
| 149 |
units: |
| 150 |
name: Units in ubuntu-latest |
| 151 |
needs: |
| 152 |
- importer |
| 153 |
runs-on: ubuntu-latest |
| 154 |
strategy: |
| 155 |
fail-fast: false |
| 156 |
matrix: |
| 157 |
ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19] |
| 158 |
steps: |
| 159 |
- name: Set up Python ${{ env.python_version }} |
| 160 |
uses: actions/setup-python@v5 |
| 161 |
with: |
| 162 |
python-version: ${{ env.python_version }} |
| 163 |
|
| 164 |
- name: Install ansible-base (${{ matrix.ansible }}) |
| 165 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check |
| 166 |
|
| 167 |
- name: Install coverage (v4.5.4) |
| 168 |
run: pip install coverage==4.5.4 |
| 169 |
|
| 170 |
- name: Download migrated collection artifacts |
| 171 |
uses: actions/download-artifact@v4 |
| 172 |
with: |
| 173 |
name: collection-${{ matrix.ansible }} |
| 174 |
path: .cache/collection-tarballs |
| 175 |
|
| 176 |
- name: Install the collection tarball |
| 177 |
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 178 |
|
| 179 |
- name: Run unit tests |
| 180 |
run: ansible-test units --docker -v --color --truncate 0 --python ${{ env.python_version }} --coverage |
| 181 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 182 |
|
| 183 |
- name: Generate coverage report. |
| 184 |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version |
| 185 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 186 |
|
| 187 |
- name: Push coverate report to codecov.io |
| 188 |
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F unit |
| 189 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 190 |
|
| 191 |
integration: |
| 192 |
name: Integration in ubuntu-latest |
| 193 |
needs: |
| 194 |
- units |
| 195 |
- sanity |
| 196 |
runs-on: ubuntu-latest |
| 197 |
strategy: |
| 198 |
matrix: |
| 199 |
ansible: [stable-2.19] |
| 200 |
env: |
| 201 |
MUTEX_URL: https://8v7s765ibh.execute-api.us-west-1.amazonaws.com |
| 202 |
steps: |
| 203 |
- name: Set up Python ${{ env.python_version }} |
| 204 |
uses: actions/setup-python@v5 |
| 205 |
with: |
| 206 |
python-version: ${{ env.python_version }} |
| 207 |
|
| 208 |
- name: Install ansible-base (${{ matrix.ansible }}) |
| 209 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check |
| 210 |
|
| 211 |
- name: Install coverage (v4.5.4) |
| 212 |
run: pip install coverage==4.5.4 |
| 213 |
|
| 214 |
- name: Download migrated collection artifacts |
| 215 |
uses: actions/download-artifact@v4 |
| 216 |
with: |
| 217 |
name: collection-${{ matrix.ansible }} |
| 218 |
path: .cache/collection-tarballs |
| 219 |
|
| 220 |
- name: Install the collection tarball |
| 221 |
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 222 |
|
| 223 |
- name: Requesting integration mutex |
| 224 |
uses: nev7n/wait_for_response@v1 |
| 225 |
with: |
| 226 |
url: ${{ format('{0}/v1/ansible-aci?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }} |
| 227 |
responseCode: 200 |
| 228 |
timeout: 2000000 |
| 229 |
interval: 5000 |
| 230 |
|
| 231 |
- name: Run integration tests on Python ${{ env.python_version }} |
| 232 |
run: | |
| 233 |
ansible-test network-integration --docker -v --color --retry-on-error --python ${{ env.python_version }} \ |
| 234 |
--truncate 0 --continue-on-error --coverage |
| 235 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 236 |
|
| 237 |
- name: Releasing integration mutex |
| 238 |
uses: nev7n/wait_for_response@v1 |
| 239 |
if: always() |
| 240 |
with: |
| 241 |
url: ${{ format('{0}/v1/ansible-aci/release?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }} |
| 242 |
responseCode: 200 |
| 243 |
|
| 244 |
- name: Generate coverage report |
| 245 |
if: always() |
| 246 |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version |
| 247 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |
| 248 |
|
| 249 |
- name: Push coverate report to codecov.io |
| 250 |
if: always() |
| 251 |
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F integration |
| 252 |
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/aci |