-
Notifications
You must be signed in to change notification settings - Fork 132
113 lines (100 loc) · 3.46 KB
/
ansible-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
name: Ansible CI
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
- labeled
workflow_dispatch:
concurrency:
group: ansible-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
ANSIBLE_FORCE_COLOR: true
ANSIBLE_GALAXY_SERVER_GALAXY_URL: "https://galaxy.ansible.com"
ANSIBLE_GALAXY_SERVER_GALAXY_TIMEOUT: 120
ANSIBLE_GALAXY_SERVER_LIST: "galaxy"
jobs:
ansible-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint collection
uses: ansible/ansible-lint@main
arguments-spec-lint:
runs-on: ubuntu-latest
container:
image: quay.io/prometheus/golang-builder:base
steps:
- uses: actions/checkout@v4
- name: Lint arguments spec
run: ./.github/scripts/lint_arguments_spec.sh
discover-ansible-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.supported-ansible-versions.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Get Ansible versions that the collection supports
id: supported-ansible-versions
run: |
echo "result=$(python ./.github/scripts/collection_version_parser.py)" >> $GITHUB_OUTPUT
ansible-test-sanity:
uses: ./.github/workflows/ansible-test-sanity.yml
needs:
- discover-ansible-versions
with:
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
discover-ansible-tests:
runs-on: ubuntu-latest
needs:
- ansible-lint
outputs:
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
ansible-roles: ${{ steps.set-ansible-roles.outputs.roles }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Discover ansible roles
id: set-ansible-roles
env:
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
roles=$(echo $LABELS | jq -c '[.[] | select(startswith("roles/")) | ltrimstr("roles/")]')
echo $roles
echo "roles=$roles" >> $GITHUB_OUTPUT
- name: Discover integration tests
id: set-integration-tests
run: |
echo tests="[`for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -not -iname "molecule-*" -printf "%f\n"); do
echo '{"test":\"'"${test}"'\","name":\"'"${test}\"'"}';
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
molecule:
uses: ./.github/workflows/ansible-test-molecule.yml
needs:
- discover-ansible-tests
- discover-ansible-versions
if: needs.discover-ansible-tests.outputs.ansible-roles != '[]' &&
needs.discover-ansible-tests.outputs.ansible-roles != ''
with:
role: ${{ matrix.role }}
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
strategy:
fail-fast: false
matrix:
role: ${{ fromJson(needs.discover-ansible-tests.outputs.ansible-roles) }}
ansible-test-integration:
uses: ./.github/workflows/ansible-test-integration.yml
needs:
- discover-ansible-tests
- discover-ansible-versions
if:
needs.discover-ansible-tests.outputs.integration-tests != '[]' &&
needs.discover-ansible-tests.outputs.integration-tests != ''
with:
targets: ${{ needs.discover-ansible-tests.outputs.integration-tests }}
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}