| 1 |
# README FIRST |
| 2 |
# 1. replace "NAMESPACE" and "COLLECTION_NAME" with the correct name in the env section (e.g. with 'community' and 'mycollection') |
| 3 |
# 2. If you don't have unit tests remove that section |
| 4 |
# 3. If your collection depends on other collections ensure they are installed, see "Install collection dependencies" |
| 5 |
# If you need help please ask in #ansible-community on the Libera.chat IRC network |
| 6 |
|
| 7 |
name: CI |
| 8 |
on: |
| 9 |
# Manual triggers |
| 10 |
workflow_dispatch: |
| 11 |
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests |
| 12 |
push: |
| 13 |
branches: |
| 14 |
- main |
| 15 |
- stable-* |
| 16 |
paths-ignore: |
| 17 |
- .github/workflows/docs*.yml |
| 18 |
- .github/workflows/github-release.yml |
| 19 |
- changelogs/fragments/*.yml |
| 20 |
- .vscode/* |
| 21 |
pull_request: |
| 22 |
paths-ignore: |
| 23 |
- .github/workflows/docs*.yml |
| 24 |
- .github/workflows/github-release.yml |
| 25 |
- changelogs/fragments/*.yml |
| 26 |
- .vscode/* |
| 27 |
|
| 28 |
# Run CI once per day (at 06:00 UTC) |
| 29 |
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version |
| 30 |
schedule: |
| 31 |
- cron: "0 6 * * *" |
| 32 |
|
| 33 |
# Cancel existing runs on new commits to a branch |
| 34 |
concurrency: |
| 35 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 36 |
cancel-in-progress: true |
| 37 |
|
| 38 |
# Deny all permissions at workflow level - scope per job |
| 39 |
permissions: {} |
| 40 |
|
| 41 |
env: |
| 42 |
NAMESPACE: lowlydba |
| 43 |
COLLECTION_NAME: sqlserver |
| 44 |
|
| 45 |
jobs: |
| 46 |
### |
| 47 |
# Sanity tests (REQUIRED) |
| 48 |
# |
| 49 |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html |
| 50 |
|
| 51 |
sanity: |
| 52 |
name: Sanity (Ⓐ${{ matrix.ansible }}) |
| 53 |
continue-on-error: ${{ matrix.ansible == 'devel' }} |
| 54 |
permissions: |
| 55 |
contents: write # Required for uploading coverage reports |
| 56 |
strategy: |
| 57 |
matrix: |
| 58 |
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix |
| 59 |
ansible: |
| 60 |
# It's important that Sanity is tested against all stable-X.Y branches |
| 61 |
# Testing against `devel` may fail as new tests are added. |
| 62 |
- stable-2.19 |
| 63 |
- stable-2.20 |
| 64 |
- devel |
| 65 |
runs-on: ubuntu-latest |
| 66 |
steps: |
| 67 |
# ansible-test requires the collection to be in a directory in the form |
| 68 |
# .../ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/ |
| 69 |
|
| 70 |
- name: Check out code |
| 71 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 72 |
with: |
| 73 |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 74 |
persist-credentials: false |
| 75 |
|
| 76 |
- name: Run confidence tests |
| 77 |
uses: ansible-community/ansible-test-gh-action@d3a8ec7a59694e25e210fcd44738910149537f0e # v1.17.0 |
| 78 |
with: |
| 79 |
ansible-core-version: ${{ matrix.ansible }} |
| 80 |
testing-type: sanity |
| 81 |
pull-request-change-detection: false |
| 82 |
|
| 83 |
- name: Generate coverage report |
| 84 |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version |
| 85 |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 86 |
|
| 87 |
# See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver |
| 88 |
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 |
| 89 |
with: |
| 90 |
fail_ci_if_error: false |
| 91 |
env: |
| 92 |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env] -- Codecov token needed for uploading coverage; workflow_dispatch only |
| 93 |
|
| 94 |
### |
| 95 |
# Integration tests (RECOMMENDED) |
| 96 |
# |
| 97 |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html |
| 98 |
|
| 99 |
# If the application you are testing is available as a docker container and you want to test |
| 100 |
# multiple versions see the following for an example: |
| 101 |
# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows |
| 102 |
|
| 103 |
integration: |
| 104 |
runs-on: ubuntu-latest |
| 105 |
name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) |
| 106 |
continue-on-error: ${{ matrix.ansible == 'devel' }} |
| 107 |
permissions: |
| 108 |
contents: write # Required for uploading coverage reports |
| 109 |
services: |
| 110 |
sqlserver: |
| 111 |
image: mcr.microsoft.com/mssql/server:2022-latest # zizmor: ignore[unpinned-images] -- Trusted publisher for this CI use case |
| 112 |
ports: |
| 113 |
- 1433:1433 |
| 114 |
env: |
| 115 |
ACCEPT_EULA: "Y" |
| 116 |
SA_PASSWORD: L0wlydb4 |
| 117 |
strategy: |
| 118 |
fail-fast: false |
| 119 |
matrix: |
| 120 |
ansible: |
| 121 |
- stable-2.19 |
| 122 |
- stable-2.20 |
| 123 |
- devel |
| 124 |
python: |
| 125 |
- 3.10 |
| 126 |
|
| 127 |
steps: |
| 128 |
- name: Check out code |
| 129 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 130 |
with: |
| 131 |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 132 |
persist-credentials: false |
| 133 |
|
| 134 |
- name: Set integration test options |
| 135 |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration |
| 136 |
run: cp integration_config.sample.yml integration_config.yml |
| 137 |
|
| 138 |
- name: Run integration tests |
| 139 |
uses: ansible-community/ansible-test-gh-action@d3a8ec7a59694e25e210fcd44738910149537f0e # v1.17.0 |
| 140 |
with: |
| 141 |
ansible-core-version: ${{ matrix.ansible }} |
| 142 |
testing-type: integration |
| 143 |
test-deps: community.general |
| 144 |
pull-request-change-detection: false |
| 145 |
|
| 146 |
# ansible-test support producing code coverage date |
| 147 |
- name: Generate coverage report |
| 148 |
run: ansible-test coverage xml -v --requirements |
| 149 |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 150 |
|
| 151 |
# See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver |
| 152 |
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 |
| 153 |
with: |
| 154 |
fail_ci_if_error: false |
| 155 |
env: |
| 156 |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env] -- Codecov token needed for uploading coverage; workflow_dispatch only |
| 157 |
|
| 158 |
ci-test-rollup: |
| 159 |
name: Are we good? |
| 160 |
runs-on: ubuntu-slim |
| 161 |
needs: [sanity, integration] |
| 162 |
if: always() |
| 163 |
steps: |
| 164 |
- uses: lowlydba/are-we-good@7efad05442f92a1203940ca8b79dd4fb930e75d4 # v1.0.2 |
| 165 |
with: |
| 166 |
jobs: ${{ toJSON(needs) }} |