-
Notifications
You must be signed in to change notification settings - Fork 4
192 lines (173 loc) · 5.32 KB
/
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
---
name: CI (Lint + Molecule)
"on":
workflow_dispatch:
inputs:
lint:
description: "Lint"
required: true
default: true
type: boolean
distro:
description: "Select a Distribution to run"
required: false
type: choice
default: "ubuntu2204"
options:
- ubuntu2004
- ubuntu2204
- debian11
- debian12
- rockylinux8
- rockylinux9
- fedora39
- ALL
ansible_version:
description: "Select Ansible Versions to run"
required: false
type: choice
# (minimum)
default: "ansible-6"
options:
- ansible-6,ansible-7,ansible-8,ansible-9
- ansible-7,ansible-8,ansible-9
- ansible-8,ansible-9
- ansible-6
- ansible-7
- ansible-8
- ansible-9
pull_request:
branches-ignore:
- renovate/**
paths:
- ".github/workflows/ci.yml"
- "defaults/**"
- "handlers/**"
- "meta/**"
- "molecule/**"
- "tasks/**"
- "vars/**"
- ".ansible-lint"
- ".gitattributes"
- ".yamllint"
- "pyproject.toml"
- "requirements-dev.txt"
- "requirements.yml"
- "tox.ini"
push:
branches:
- master
- renovate/**
paths:
- ".github/workflows/ci.yml"
- "defaults/*"
- "handlers/*"
- "meta/**"
- "molecule/**"
- "tasks/*"
- "vars/*"
- ".ansible-lint"
- ".gitattributes"
- ".yamllint"
- "pyproject.toml"
- "requirements.yml"
- "tox.ini"
schedule:
# At 05:00 on Sunday.
- cron: "0 5 * * 0"
permissions: read-all
jobs:
lint:
name: Lint
if: ${{ github.event.inputs.lint != 'false' }}
runs-on: ubuntu-latest
steps:
- name: check out the codebase
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: set up python 3
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: "3.10"
- name: Install yamllint package.
run: pip3 install "yamllint==1.*"
- name: Lint YAML (GitHub Annotations)
run: |
cat <<HEREDOC
Wondering about why there are no file names?
This command outputs information parsed by GitHub
to be displayed in 'Annotations' tab.
HEREDOC
yamllint . -f github
- name: Lint YAML (Standard Output)
if: always()
run: yamllint . -f standard
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
# half length of matrix's distro list / most important:
max-parallel: 4
matrix:
distro:
# ensure diversity in first half:
- ubuntu2204
- debian12
- rockylinux9
- fedora39
# other:
- rockylinux8
- ubuntu2004
- debian11
env:
WORKFLOW_DISPATCH_IF: >-
${{github.event_name == 'workflow_dispatch' &&
(github.event.inputs.distro == 'ALL' ||
contains(matrix.distro, github.event.inputs.distro)) }}
steps:
- name: if this step is run, this is a real ci run
run: >
cat << EOF
If this step is NOT skipped, this workflow run was manually dispatched
and the chosen distro does not match the current matrix distro.
This is a hack because GitHub CI does not allow for a state other than "failed"
as per https://github.com/actions/runner/issues/662
EOF
if: github.event_name != 'workflow_dispatch' || env.WORKFLOW_DISPATCH_IF == 'true'
- name: check out the codebase
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: set up python 3
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: "3.10"
- name: setup/activate pre-commit cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ~/.cache/pre-commit
key: ${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Install test dependencies.
run: pip3 install -r requirements-dev.txt
- name: Run Molecule tests (normal).
run: tox
env:
TOX_SKIP_ENV: pre-commit
MOLECULE_DISTRO: ${{ matrix.distro }}
if: github.event_name != 'workflow_dispatch'
- name: Run Molecule tests (debug).
run: tox
env:
TOXENV: py3-${{ github.event.inputs.ansible_version }}
TOX_SKIP_ENV: pre-commit
MOLECULE_DESTROY: never
MOLECULE_DISTRO: ${{ matrix.distro }}
if: env.WORKFLOW_DISPATCH_IF == 'true'
- name: Upload output of /molecule/resources/debug.yml as CI Artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
with:
name: debug-${{ matrix.distro }}.yml
path: |
/var/tmp/vars.yml
/var/tmp/environment.yml
- name: setup tmate session if previous step failed and if this is a manual run
if: failure() && env.WORKFLOW_DISPATCH_IF == 'true'
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # v3
timeout-minutes: 30