Skip to content

Commit cd18bfa

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

File tree

2 files changed

+102
-124
lines changed

2 files changed

+102
-124
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: 61 additions & 73 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,49 +41,43 @@ 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.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
64+
- run: ansible-playbook tests/integration/prepare/prepare_iso.yml
65+
- run: ansible-playbook tests/integration/prepare/prepare_vm.yml
6866
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"
6967

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

10197
examples-matrix:
10298
runs-on: [ ubuntu-latest ]
103-
container: python:3.10-slim-buster
104-
env:
105-
DEBIAN_FRONTEND: noninteractive
106-
ANSIBLE_COLLECTIONS_PATH: /work-dir
99+
container: quay.io/justinc1_github/scale_ci_integ:1
100+
defaults:
101+
run:
102+
working-directory: ${{ env.WORKDIR }}
107103
outputs:
108104
matrix: ${{ steps.set-matrix.outputs.matrix }}
109105
steps:
110106
- name: Checkout
111107
uses: actions/checkout@v3
112-
- run: apt update
113-
- run: apt install -y jq
114-
- run: mkdir -p $WORKDIR
115-
- run: cp -a ./ $WORKDIR
108+
with:
109+
path: ${{ env.WORKDIR }}
116110
# A few files are not an example playbook:
117111
# hypercore_inventory.yml - inventory example
118112
# cloud-init-user-data-example.yml - cloud-init user-data example
119113
- id: set-matrix
120114
shell: bash
121115
run: |-
122116
echo "matrix=$(
123-
ls -r $WORKDIR/examples |
117+
ls -r examples |
124118
grep -v -E "^README.md$|^hypercore_inventory.yml$|^cloud-init-user-data-example.yml$" |
125119
jq -R -s -c 'split("\n")[:-1]'
126120
)" >> $GITHUB_OUTPUT
@@ -130,9 +124,13 @@ jobs:
130124
needs:
131125
- examples-matrix
132126
runs-on: [ self-hosted2 ]
133-
container: python:3.10-slim-buster
127+
container: quay.io/justinc1_github/scale_ci_integ:1
134128
env:
129+
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
135130
DEBIAN_FRONTEND: noninteractive
131+
defaults:
132+
run:
133+
working-directory: ${{ env.WORKDIR }}
136134
strategy:
137135
fail-fast: false
138136
matrix:
@@ -141,26 +139,19 @@ jobs:
141139
steps:
142140
- name: Checkout
143141
uses: actions/checkout@v3
144-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
145-
- run: apt update
146-
- run: apt install -y git make
147-
- run: apt install -y genisoimage qemu-utils jq
148-
- run: pip install yq
142+
with:
143+
path: ${{ env.WORKDIR }}
149144
- run: pip install ansible-core~=${{ matrix.ansible }}
150-
- run: mkdir -p $WORKDIR
151-
- run: cp -a ./ $WORKDIR
152-
- run: cd $WORKDIR && ansible-galaxy collection install community.crypto community.general
153-
- run: cd $WORKDIR && ansible-galaxy collection list
145+
- run: ansible-galaxy collection install community.crypto community.general
146+
- run: ansible-galaxy collection list
154147
- run: |
155-
cd $WORKDIR
156148
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
157149
cat tests/integration/integration_config.yml
158150
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
159151
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
160152
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
161153
ls -al tests/integration/integration_config.yml
162154
- run: |
163-
cd $WORKDIR
164155
eval export SC_HOST=$(cat tests/integration/integration_config.yml | yq '.sc_host')
165156
eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_username')
166157
eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_password')
@@ -172,9 +163,12 @@ jobs:
172163
- integ-matrix
173164
# - units-test
174165
runs-on: [self-hosted2]
175-
container: python:3.10-slim-buster
166+
container: quay.io/justinc1_github/scale_ci_integ:1
176167
env:
177168
DEBIAN_FRONTEND: noninteractive
169+
defaults:
170+
run:
171+
working-directory: ${{ env.WORKDIR }}
178172
strategy:
179173
fail-fast: false
180174
matrix:
@@ -185,69 +179,63 @@ jobs:
185179
steps:
186180
- name: Checkout
187181
uses: actions/checkout@v3
188-
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
189-
- run: apt update
190-
- run: apt install -y git make
191-
- run: apt install -y genisoimage qemu-utils
182+
with:
183+
path: ${{ env.WORKDIR }}
192184
- run: pip install ansible-core~=${{ matrix.ansible }}
193-
- run: mkdir -p $WORKDIR
194-
- run: cp -a ./ $WORKDIR
195185
# We have ansible.cfg "for testing" in git repo
196186
# (it is excluded in galaxy.yml, so it is not part of collection artifact)
197187
# But it does affect ansible-galaxy and ansible-test commands.
198-
- run: cd $WORKDIR && ansible-galaxy collection install community.crypto
199-
- run: cd $WORKDIR && ansible-galaxy collection list
188+
- run: ansible-galaxy collection install community.crypto
189+
- run: ansible-galaxy collection list
200190
# TODO - make integration_config.yml a reusable artifact/output of integration-prepare-env
201191
- run: |
202-
cd $WORKDIR
203192
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
204193
cat tests/integration/integration_config.yml
205194
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
206195
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
207196
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
208197
ls -al tests/integration/integration_config.yml
209-
- run: cd $WORKDIR && ansible-test integration --local ${{ matrix.test_name }}
198+
- run: ansible-test integration --local ${{ matrix.test_name }}
210199

211200

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

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