-
-
Notifications
You must be signed in to change notification settings - Fork 4
242 lines (212 loc) · 8.91 KB
/
molecule_certified_ees.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
---
name: 'molecule certified EEs'
on: # yamllint disable-line rule:truthy
pull_request_target:
types:
- 'labeled'
paths:
- '.github/workflows/molecule_certified_ees.yml'
- 'defaults/**'
- 'files/**'
- 'handlers/**'
- 'library/**'
- 'lookup_plugins/**'
- 'meta/**'
- 'module_utils/**'
- 'tasks/**'
- 'templates/**'
- 'vars/**'
push:
branches:
- 'main'
paths:
- '.github/workflows/molecule_certified_ees.yml'
- 'defaults/**'
- 'files/**'
- 'handlers/**'
- 'library/**'
- 'lookup_plugins/**'
- 'meta/**'
- 'module_utils/**'
- 'tasks/**'
- 'templates/**'
- 'vars/**'
workflow_dispatch:
inputs:
repoCache:
description: 'Reset or disable the cache?'
type: 'choice'
default: 'enabled'
options:
- 'enabled'
- 'disabled'
- 'reset'
permissions:
contents: 'read'
# Adding these as env variables makes it easy to re-use them in different steps and in bash.
env:
cache_archive: 'molecule_cache.tar.gz'
# This is the dir renovate provides
# If we set our own directory via cacheDir, we can run into permissions issues.
# It is also possible to cache a higher level of the directory, but it has minimal benefit. While renovate execution
# time gets faster, it also takes longer to upload the cache as it grows bigger.
cache_dir: '/tmp/.cache/molecule'
# This can be manually changed to bust the cache if neccessary.
cache_key: 'molecule-cache'
jobs:
check-user-permissions:
runs-on: 'ubuntu-latest'
if: >-
contains(github.event.pull_request.labels.*.name, 'run') ||
github.ref == 'refs/heads/main'
outputs:
require-result: '${{ steps.check-access.outputs.require-result }}'
steps:
- name: 'Harden Runner'
uses: 'step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6' # v2.8.1
with:
egress-policy: 'block'
allowed-endpoints: >
api.github.com:443
github.com:443
- name: 'Get User Permissions'
id: 'check-access'
uses: 'actions-cool/check-user-permission@956b2e73cdfe3bcb819bb7225e490cb3b18fd76e' # v2.2.1
with:
require: 'write'
username: '${{ github.triggering_actor }}'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: 'Check User Permission'
if: "steps.check-access.outputs.require-result == 'false'"
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.check-access.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
molecule-certified-ees:
runs-on: 'ubuntu-latest'
needs: 'check-user-permissions'
if: "needs.check-user-permissions.outputs.require-result == 'true'"
permissions:
contents: 'write'
container:
image: '${{ matrix.container.image }}'
credentials:
username: '${{ secrets.crc_username }}'
password: '${{ secrets.crc_password }}'
options: '--privileged'
strategy:
matrix:
container:
#
# UBI 8
#
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.17@sha256:96e1594b2956cc14443c58f441097e53df54f50c88ae0e01d6a948158beb1b8f'
cache_key_suffix: 'rhel8-2.17'
# renovate yaml: datasource=pypi
molecule: '24.7.0'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.16@sha256:5728903400b4b797eb697c1db419f2676d4a2aa67404f1e6f6a15d8f6c3d0252'
cache_key_suffix: 'rhel8-2.16'
# renovate yaml: datasource=pypi
molecule: '24.7.0'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.15@sha256:1be81d9d69d43700dc46ff95084c845191ff0146bf90ceb69e612b674487dd94'
cache_key_suffix: 'rhel8-2.15'
# renovate yaml: datasource=pypi
molecule: '6.0.3'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.14@sha256:8073b374c3654488c515770f82e2d3a4d293ad7f428eef36399a04b36899227d'
cache_key_suffix: 'rhel8-2.14'
# renovate yaml: datasource=pypi
molecule: '6.0.3'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.13@sha256:8e67f956ffb1dba10773c458831c7b9241aeb7b2862e64e8f37220e562e5e96f'
cache_key_suffix: 'rhel8-2.13'
# renovate yaml: datasource=pypi
molecule: '6.0.3'
#
# UBI 9
#
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel9:2.17@sha256:aee53021fb1ead2f9486433ca503dc490ec544e8ea2035fcbe822bae8574d5c3'
cache_key_suffix: 'rhel9-2.17'
# renovate yaml: datasource=pypi
molecule: '24.7.0'
additional_packages:
- 'python-unversioned-command'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel9:2.16@sha256:51b046ea91fb4fbb50b7d085cf9e96c2ccb2e0600ece4a6d470d0b71f3547459'
cache_key_suffix: 'rhel9-2.16'
# renovate yaml: datasource=pypi
molecule: '24.7.0'
additional_packages:
- 'python-unversioned-command'
# yamllint disable-line rule:line-length
- image: 'registry.redhat.io/ansible-automation-platform/ee-minimal-rhel9:2.15@sha256:9c2072bd7f9187f87bac11c4fcf3975bcd876e5b73dfdc84e1aebf2571ab5fdc'
cache_key_suffix: 'rhel9-2.15'
# renovate yaml: datasource=pypi
molecule: '6.0.3'
additional_packages:
- 'python-unversioned-command'
steps:
- name: 'Install NodeJS'
uses: 'actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b' # v4.0.3
with:
# renovate dep: datasource=npm depName=node
node-version: '20.15.1'
- name: 'Install podman'
run: 'microdnf install podman -y'
- name: 'Checkout repository'
uses: 'actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332' # v4.1.7
with:
# check out the pull request's HEAD
ref: '${{ github.event.pull_request.head.sha }}'
- name: 'Download cache of the previous workflow run'
uses: 'dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11' # v6
if: "github.event.inputs.repoCache != 'disabled'"
continue-on-error: true
with:
name: '${{ env.cache_key }}-${{ matrix.container.cache_key_suffix }}'
path: 'cache-download'
- name: 'Extract molecule cache to improve performance'
if: "github.event.inputs.repoCache != 'disabled'"
run: |
set -x
# Skip if no cache is set, such as the first time it runs.
if [ ! -d cache-download ] ; then
echo "No cache found."
exit 0
fi
# Make sure the directory exists, and extract it there. Note that it's nested in the download directory.
mkdir -p "${cache_dir}"
tar -xzf "cache-download/${cache_archive}" -C "${cache_dir}"
- name: 'Install additional packages'
if: "join(matrix.container.additional_packages, ' ') != ''"
run: |
microdnf install -y ${{ join(matrix.container.additional_packages, ' ') }}
- name: 'Install Python packages'
run: |
pip3 install molecule==${{ matrix.container.molecule }}
mkdir -pv "${cache_dir}"
- name: 'Run molecule'
run: |
molecule test
- name: 'Compress molecule cache to improve performance'
if: "github.event.inputs.repoCache != 'disabled'"
run: |
# The -C is important, as otherwise we end up extracting the files with
# their full path, ultimately leading to a nested directory situation.
tar -czf "${cache_archive}" -C "${cache_dir}" .
- name: 'Upload compressed cache'
uses: 'actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b' # v4.3.4
if: "github.event.inputs.repoCache != 'disabled'"
with:
name: '${{ env.cache_key }}-${{ matrix.container.cache_key_suffix }}'
path: '${{ env.cache_archive }}'
# Since this is updated and restored on every run, we don't need to keep it
# for long. Just make sure this value is large enough that multiple renovate
# runs can happen before older cache archives are deleted.
retention-days: 1
...