Skip to content

Commit 94383ff

Browse files
committed
Use our CI image
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent d3f75da commit 94383ff

File tree

2 files changed

+103
-125
lines changed

2 files changed

+103
-125
lines changed

.github/workflows/ci-test.yml

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,73 @@ name: CI tests
22
on:
33
push:
44
env:
5-
WORKDIR: /work-dir/ansible_collections/scale_computing/hypercore
5+
# ansible-test needs special directory structure.
6+
# WORKDIR is a subdir of GITHUB_WORKSPACE
7+
WORKDIR: work-dir/ansible_collections/scale_computing/hypercore
68
jobs:
79
mypy:
810
name: Type checks (mypy)
911
runs-on: [ubuntu-latest]
10-
container: python:3.10-slim-buster
12+
container: quay.io/justinc1_github/scale_ci_integ:1
13+
defaults:
14+
run:
15+
working-directory: ${{ env.WORKDIR }}
1116
steps:
1217
- name: Check out code
1318
uses: actions/checkout@v3
14-
15-
- name: Install requirements
16-
shell: bash
17-
run: |
18-
apt update
19-
pip install --upgrade pip wheel
20-
pip install mypy==0.991
21-
22-
- name: Link repo into the correct structure and run mypy
23-
shell: bash
24-
run: |
25-
set -eux
26-
mkdir -p $WORKDIR
27-
cp -a ./ $WORKDIR
28-
cd $WORKDIR
29-
mypy -p plugins
19+
with:
20+
path: ${{ env.WORKDIR }}
21+
- run: echo GITHUB_WORKSPACE=$GITHUB_WORKSPACE
22+
- run: echo WORKDIR=$WORKDIR
23+
- run: echo PWD=$PWD
24+
- name: Run mypy
25+
run: mypy -p plugins
3026

3127
docs:
3228
runs-on: [ubuntu-latest]
33-
container: python:3.10-slim-buster
29+
container: quay.io/justinc1_github/scale_ci_integ:1
30+
defaults:
31+
run:
32+
working-directory: ${{ env.WORKDIR }}
3433
steps:
3534
- name: Checkout
3635
uses: actions/checkout@v3
37-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
38-
- run: apt update
39-
- run: apt install -y git make
40-
# ansible-test needs special directory structure.
41-
- run: mkdir -p $WORKDIR
42-
- run: cp -a ./ $WORKDIR
43-
#
44-
- run: cd $WORKDIR && make docs
45-
- run: cd $WORKDIR && ls -al docs/build/html
36+
with:
37+
path: ${{ env.WORKDIR }}
38+
- run: make docs
39+
- run: ls -al docs/build/html
4640

4741
sanity-test:
4842
runs-on: [ubuntu-latest]
49-
container: python:3.10-slim-buster
43+
container: quay.io/justinc1_github/scale_ci_integ:1
44+
defaults:
45+
run:
46+
working-directory: ${{ env.WORKDIR }}
5047
steps:
5148
- name: Checkout
5249
uses: actions/checkout@v3
53-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
54-
- run: apt update
55-
- run: apt install -y git make
56-
- run: pip install ansible-core==2.13.1
57-
# ansible-test needs special directory structure.
58-
- run: mkdir -p $WORKDIR
59-
- run: cp -a ./ $WORKDIR
50+
with:
51+
path: ${{ env.WORKDIR }}
6052
# Same as "make sanity"
6153
# TODO reuse Makefile
62-
- run: cd $WORKDIR && black -t py38 --check --diff --color plugins tests/unit
63-
- run: cd $WORKDIR && ansible-lint
64-
- run: cd $WORKDIR && flake8 --exclude tests/output/
65-
- run: cd $WORKDIR && ansible-test sanity
54+
- run: black -t py38 --check --diff --color plugins tests/unit
55+
- run: ansible-lint
56+
- run: flake8 --exclude tests/output/
57+
- run: ansible-test sanity --local --python 3.10
6658

6759
units-test:
6860
runs-on: [ubuntu-latest]
69-
container: python:3.10-slim-buster
61+
container: quay.io/justinc1_github/scale_ci_integ:1
62+
defaults:
63+
run:
64+
working-directory: ${{ env.WORKDIR }}
7065
steps:
7166
- name: Checkout
7267
uses: actions/checkout@v3
73-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
74-
- run: apt update
75-
- run: apt install -y git make
76-
- run: pip install ansible-core==2.13.1
77-
# ansible-test needs special directory structure.
78-
- run: mkdir -p $WORKDIR
79-
- run: cp -a ./ $WORKDIR
68+
with:
69+
path: ${{ env.WORKDIR }}
8070
# Same as "make units"
8171
# TODO reuse Makefile
82-
- run: cd $WORKDIR && ansible-test units --coverage
83-
- run: cd $WORKDIR && ansible-test coverage html --requirements
84-
- run: cd $WORKDIR && ansible-test coverage report --omit 'tests/*' --show-missing
72+
- run: ansible-test units --local --python 3.10 --coverage
73+
- run: ansible-test coverage html --requirements
74+
- run: ansible-test coverage report --omit 'tests/*' --show-missing

.github/workflows/integ-test.yml

Lines changed: 62 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ on:
2727
env:
2828
INTEG_TESTS_INCLUDE_SCHEDULE: "*"
2929
INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_"
30-
WORKDIR: /work-dir/ansible_collections/scale_computing/hypercore
30+
# ansible-test needs special directory structure.
31+
# WORKDIR is a subdir of GITHUB_WORKSPACE
32+
WORKDIR: work-dir/ansible_collections/scale_computing/hypercore
3133
# Run only one workflow for specific branch.
3234
concurrency:
3335
group: ${{ github.ref_name }}
@@ -39,50 +41,44 @@ jobs:
3941
# to delay integ-test until integration-prepare-env finishes.
4042
integration-prepare-env:
4143
runs-on: [self-hosted2]
42-
container: python:3.10-slim-buster
44+
container: quay.io/justinc1_github/scale_ci_integ:1
4345
env:
44-
DEBIAN_FRONTEND: noninteractive
45-
ANSIBLE_COLLECTIONS_PATH: /work-dir
46+
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
47+
defaults:
48+
run:
49+
working-directory: ${{ env.WORKDIR }}
4650
steps:
4751
- name: Checkout
4852
uses: actions/checkout@v3
49-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
50-
- run: apt update
51-
- run: apt install -y git make
52-
- run: pip install ansible-core==2.13.1
53-
- run: apt install -y genisoimage qemu-utils
54-
- run: apt install -y jq
55-
- run: mkdir -p $WORKDIR
56-
- run: cp -a ./ $WORKDIR
53+
with:
54+
path: ${{ env.WORKDIR }}
5755
- run: ansible-galaxy collection install community.crypto community.general
56+
- run: ansible-galaxy collection list
5857
- run: |
59-
cd $WORKDIR
6058
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
6159
cat tests/integration/integration_config.yml
6260
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
6361
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
6462
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
6563
ls -al tests/integration/integration_config.yml
66-
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_iso.yml
67-
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_vm.yml
68-
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_examples.yml
64+
- run: ansible-playbook tests/integration/prepare/prepare_iso.yml
65+
- run: ansible-playbook tests/integration/prepare/prepare_vm.yml
66+
- run: ansible-playbook tests/integration/prepare/prepare_examples.yml
6967
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"
7068

7169
integ-matrix:
7270
runs-on: [ubuntu-latest]
73-
container: python:3.10-slim-buster
74-
env:
75-
DEBIAN_FRONTEND: noninteractive
76-
ANSIBLE_COLLECTIONS_PATH: /work-dir
71+
container: quay.io/justinc1_github/scale_ci_integ:1
72+
defaults:
73+
run:
74+
working-directory: ${{ env.WORKDIR }}
7775
outputs:
7876
matrix: ${{ steps.set-matrix.outputs.matrix }}
7977
steps:
8078
- name: Checkout
8179
uses: actions/checkout@v3
82-
- run: apt update
83-
- run: apt install -y jq
84-
- run: mkdir -p $WORKDIR
85-
- run: cp -a ./ $WORKDIR
80+
with:
81+
path: ${{ env.WORKDIR }}
8682
# We want to run all integ tests periodically - "integ_tests_include || '*'", the '*' is used.
8783
# When running with workflow-dispatch, user is required to put some non-empty string into integ_tests_include.
8884
- run: echo 'INTEG_TESTS_INCLUDE=${{ github.event.inputs.integ_tests_include || env.INTEG_TESTS_INCLUDE_SCHEDULE }}' >> $GITHUB_ENV
@@ -92,7 +88,7 @@ jobs:
9288
shell: bash
9389
run: |-
9490
echo "matrix=$(
95-
ls -r $WORKDIR/tests/integration/targets |
91+
ls -r tests/integration/targets |
9692
grep -v -E "${{ env.INTEG_TESTS_EXCLUDE }}" |
9793
grep -E "${{ env.INTEG_TESTS_INCLUDE }}" |
9894
jq -R -s -c 'split("\n")[:-1]'
@@ -101,27 +97,25 @@ jobs:
10197

10298
examples-matrix:
10399
runs-on: [ ubuntu-latest ]
104-
container: python:3.10-slim-buster
105-
env:
106-
DEBIAN_FRONTEND: noninteractive
107-
ANSIBLE_COLLECTIONS_PATH: /work-dir
100+
container: quay.io/justinc1_github/scale_ci_integ:1
101+
defaults:
102+
run:
103+
working-directory: ${{ env.WORKDIR }}
108104
outputs:
109105
matrix: ${{ steps.set-matrix.outputs.matrix }}
110106
steps:
111107
- name: Checkout
112108
uses: actions/checkout@v3
113-
- run: apt update
114-
- run: apt install -y jq
115-
- run: mkdir -p $WORKDIR
116-
- run: cp -a ./ $WORKDIR
109+
with:
110+
path: ${{ env.WORKDIR }}
117111
# A few files are not an example playbook:
118112
# hypercore_inventory.yml - inventory example
119113
# cloud-init-user-data-example.yml - cloud-init user-data example
120114
- id: set-matrix
121115
shell: bash
122116
run: |-
123117
echo "matrix=$(
124-
ls -r $WORKDIR/examples |
118+
ls -r examples |
125119
grep -v -E "^README.md$|^hypercore_inventory.yml$|^cloud-init-user-data-example.yml$" |
126120
jq -R -s -c 'split("\n")[:-1]'
127121
)" >> $GITHUB_OUTPUT
@@ -131,9 +125,13 @@ jobs:
131125
needs:
132126
- examples-matrix
133127
runs-on: [ self-hosted2 ]
134-
container: python:3.10-slim-buster
128+
container: quay.io/justinc1_github/scale_ci_integ:1
135129
env:
130+
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
136131
DEBIAN_FRONTEND: noninteractive
132+
defaults:
133+
run:
134+
working-directory: ${{ env.WORKDIR }}
137135
strategy:
138136
fail-fast: false
139137
matrix:
@@ -142,26 +140,19 @@ jobs:
142140
steps:
143141
- name: Checkout
144142
uses: actions/checkout@v3
145-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
146-
- run: apt update
147-
- run: apt install -y git make
148-
- run: apt install -y genisoimage qemu-utils jq
149-
- run: pip install yq
143+
with:
144+
path: ${{ env.WORKDIR }}
150145
- run: pip install ansible-core~=${{ matrix.ansible }}
151-
- run: mkdir -p $WORKDIR
152-
- run: cp -a ./ $WORKDIR
153-
- run: cd $WORKDIR && ansible-galaxy collection install community.crypto community.general
154-
- run: cd $WORKDIR && ansible-galaxy collection list
146+
- run: ansible-galaxy collection install community.crypto community.general
147+
- run: ansible-galaxy collection list
155148
- run: |
156-
cd $WORKDIR
157149
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
158150
cat tests/integration/integration_config.yml
159151
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
160152
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
161153
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
162154
ls -al tests/integration/integration_config.yml
163155
- run: |
164-
cd $WORKDIR
165156
eval export SC_HOST=$(cat tests/integration/integration_config.yml | yq '.sc_host')
166157
eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_username')
167158
eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_password')
@@ -173,9 +164,12 @@ jobs:
173164
- integ-matrix
174165
# - units-test
175166
runs-on: [self-hosted2]
176-
container: python:3.10-slim-buster
167+
container: quay.io/justinc1_github/scale_ci_integ:1
177168
env:
178169
DEBIAN_FRONTEND: noninteractive
170+
defaults:
171+
run:
172+
working-directory: ${{ env.WORKDIR }}
179173
strategy:
180174
fail-fast: false
181175
matrix:
@@ -186,69 +180,63 @@ jobs:
186180
steps:
187181
- name: Checkout
188182
uses: actions/checkout@v3
189-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
190-
- run: apt update
191-
- run: apt install -y git make
192-
- run: apt install -y genisoimage qemu-utils
183+
with:
184+
path: ${{ env.WORKDIR }}
193185
- run: pip install ansible-core~=${{ matrix.ansible }}
194-
- run: mkdir -p $WORKDIR
195-
- run: cp -a ./ $WORKDIR
196186
# We have ansible.cfg "for testing" in git repo
197187
# (it is excluded in galaxy.yml, so it is not part of collection artifact)
198188
# But it does affect ansible-galaxy and ansible-test commands.
199-
- run: cd $WORKDIR && ansible-galaxy collection install community.crypto
200-
- run: cd $WORKDIR && ansible-galaxy collection list
189+
- run: ansible-galaxy collection install community.crypto
190+
- run: ansible-galaxy collection list
201191
# TODO - make integration_config.yml a reusable artifact/output of integration-prepare-env
202192
- run: |
203-
cd $WORKDIR
204193
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
205194
cat tests/integration/integration_config.yml
206195
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
207196
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
208197
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
209198
ls -al tests/integration/integration_config.yml
210-
- run: cd $WORKDIR && ansible-test integration --local ${{ matrix.test_name }}
199+
- run: ansible-test integration --local ${{ matrix.test_name }}
211200

212201

213202
replica_cleanup:
214203
needs:
215204
- integ
216205
runs-on: [self-hosted2]
217-
container: python:3.10-slim-buster
206+
container: quay.io/justinc1_github/scale_ci_integ:1
218207
env:
219-
ANSIBLE_COLLECTIONS_PATH: /work-dir
208+
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
209+
defaults:
210+
run:
211+
working-directory: ${{ env.WORKDIR }}
220212
steps:
221213
- name: Checkout
222214
uses: actions/checkout@v3
223-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
224-
- run: apt update
225-
- run: apt install -y git make
226-
- run: pip install ansible-core==2.13.1
215+
with:
216+
path: ${{ env.WORKDIR }}
217+
- run: pip install ansible-core~=2.13.0
227218
# ansible-test needs special directory structure.
228-
- run: mkdir -p $WORKDIR
229-
- run: cp -a ./ $WORKDIR
230219
- run: |
231-
cd $WORKDIR
232220
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
233221
cat tests/integration/integration_config.yml
234222
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
235223
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
236224
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
237225
ls -al tests/integration/integration_config.yml
238226
- run: ansible-galaxy collection install community.general
239-
- run: cd $WORKDIR && ansible-playbook tests/integration/cleanup/ci_replica_cleanup.yml
227+
- run: ansible-playbook tests/integration/cleanup/ci_replica_cleanup.yml
240228

241229
smb_cleanup:
242230
needs:
243231
- integ
244232
runs-on: [self-hosted2]
245-
container: python:3.10-slim-buster
233+
container: quay.io/justinc1_github/scale_ci_integ:1
234+
defaults:
235+
run:
236+
working-directory: ${{ env.WORKDIR }}
246237
steps:
247238
- name: Checkout
248239
uses: actions/checkout@v3
249-
- run: apt update
250-
- run: apt install -y git make
251-
- run: apt install -y smbclient
252-
- run: mkdir -p $WORKDIR
253-
- run: cp -a ./ $WORKDIR
254-
- run: cd $WORKDIR/tests/integration/cleanup && ./smb_cleanup.sh ${{ secrets.SMB_SERVER }} ${{ secrets.SMB_SHARE }} "${{ secrets.SMB_USERNAME }}" ${{ secrets.SMB_PASSWORD }}
240+
with:
241+
path: ${{ env.WORKDIR }}
242+
- run: cd tests/integration/cleanup && ./smb_cleanup.sh ${{ secrets.SMB_SERVER }} ${{ secrets.SMB_SHARE }} "${{ secrets.SMB_USERNAME }}" ${{ secrets.SMB_PASSWORD }}

0 commit comments

Comments
 (0)