Skip to content

Commit e60d9da

Browse files
Use a composite action to avoid duplicate logic
1 parent 6309d08 commit e60d9da

File tree

2 files changed

+43
-93
lines changed

2 files changed

+43
-93
lines changed

.github/actions/test-prep/action.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Prepare test prerequisites
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install test dependencies
7+
shell: bash
8+
run: |
9+
set -x
10+
sudo apt-get install python3-setuptools
11+
sudo pip3 install --upgrade pip
12+
sudo pip3 install -U pytest==8.3.4 sh psutil requests
13+
sudo apt-get -y install open-iscsi
14+
sudo systemctl enable iscsid
15+
# Docker sets iptables rules that interfere with LXD and K8s.
16+
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
17+
- name: Apply Docker iptables workaround
18+
shell: bash
19+
run: sudo iptables -I DOCKER-USER -j ACCEPT
20+
- name: Fetch snap
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: microk8s.snap
24+
path: build
25+
# - name: Setup tmate session
26+
# uses: mxschmitt/action-tmate@v3

.github/workflows/build-snap.yml

+17-93
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,12 @@ jobs:
4444
name: Upgrade path test
4545
runs-on: ubuntu-22.04
4646
needs: build
47-
47+
timeout-minutes: 30
4848
steps:
4949
- name: Checking out repo
5050
uses: actions/checkout@v4
51-
- name: Install test dependencies
52-
run: |
53-
set -x
54-
sudo apt-get install python3-setuptools
55-
sudo pip3 install --upgrade pip
56-
sudo pip3 install -U pytest sh psutil
57-
sudo apt-get -y install open-iscsi
58-
sudo systemctl enable iscsid
59-
- name: Fetch snap
60-
uses: actions/download-artifact@v4
61-
with:
62-
name: microk8s.snap
63-
path: build
51+
- name: Prepare test prerequisites
52+
uses: ./.github/actions/test-prep
6453
- name: Running upgrade path test
6554
run: |
6655
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
@@ -70,28 +59,11 @@ jobs:
7059
runs-on: ubuntu-22.04
7160
needs: build
7261
timeout-minutes: 30
73-
7462
steps:
7563
- name: Checking out repo
7664
uses: actions/checkout@v4
77-
- name: Install test dependencies
78-
run: |
79-
set -x
80-
sudo apt-get install python3-setuptools
81-
sudo pip3 install --upgrade pip
82-
sudo pip3 install -U pytest==8.3.4 sh psutil
83-
sudo apt-get -y install open-iscsi
84-
sudo systemctl enable iscsid
85-
# Docker sets iptables rules that interfere with LXD or K8s.
86-
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
87-
- name: Apply Docker iptables workaround
88-
shell: bash
89-
run: sudo iptables -I DOCKER-USER -j ACCEPT
90-
- name: Fetch snap
91-
uses: actions/download-artifact@v4
92-
with:
93-
name: microk8s.snap
94-
path: build
65+
- name: Prepare test prerequisites
66+
uses: ./.github/actions/test-prep
9567
- name: Running addons tests
9668
env:
9769
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
@@ -106,25 +78,12 @@ jobs:
10678
name: Test community addons
10779
runs-on: ubuntu-22.04
10880
needs: build
109-
81+
timeout-minutes: 30
11082
steps:
11183
- name: Checking out repo
11284
uses: actions/checkout@v4
113-
- name: Install test dependencies
114-
run: |
115-
set -x
116-
sudo apt-get install python3-setuptools
117-
sudo pip3 install --upgrade pip
118-
sudo pip3 install -U pytest sh
119-
sudo apt-get -y install open-iscsi
120-
sudo systemctl enable iscsid
121-
- name: Fetch snap
122-
uses: actions/download-artifact@v4
123-
with:
124-
name: microk8s.snap
125-
path: build
126-
# - name: Setup tmate session
127-
# uses: mxschmitt/action-tmate@v3
85+
- name: Prepare test prerequisites
86+
uses: ./.github/actions/test-prep
12887
- name: Running addons tests
12988
env:
13089
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
@@ -139,30 +98,11 @@ jobs:
13998
runs-on: ubuntu-22.04
14099
needs: build
141100
timeout-minutes: 30
142-
143101
steps:
144102
- name: Checking out repo
145103
uses: actions/checkout@v4
146-
# - name: Setup tmate session
147-
# uses: mxschmitt/action-tmate@v3
148-
- name: Install test dependencies
149-
run: |
150-
set -x
151-
sudo apt-get install python3-setuptools
152-
sudo pip3 install --upgrade pip
153-
sudo pip3 install -U pytest sh psutil
154-
sudo apt-get -y install open-iscsi
155-
sudo systemctl enable iscsid
156-
# Docker sets iptables rules that interfere with LXD or K8s.
157-
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
158-
- name: Apply Docker iptables workaround
159-
shell: bash
160-
run: sudo iptables -I DOCKER-USER -j ACCEPT
161-
- name: Fetch snap
162-
uses: actions/download-artifact@v4
163-
with:
164-
name: microk8s.snap
165-
path: build
104+
- name: Prepare test prerequisites
105+
uses: ./.github/actions/test-prep
166106
- name: Running upgrade tests
167107
env:
168108
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
@@ -174,21 +114,12 @@ jobs:
174114
name: Cluster agent health check
175115
runs-on: ubuntu-22.04
176116
needs: build
177-
117+
timeout-minutes: 30
178118
steps:
179119
- name: Checking out repo
180120
uses: actions/checkout@v4
181-
- name: Install test dependencies
182-
run: |
183-
set -x
184-
sudo apt-get install python3-setuptools
185-
sudo pip3 install --upgrade pip
186-
sudo pip3 install -U pytest sh requests
187-
- name: Fetch snap
188-
uses: actions/download-artifact@v4
189-
with:
190-
name: microk8s.snap
191-
path: build
121+
- name: Prepare test prerequisites
122+
uses: ./.github/actions/test-prep
192123
- name: Running cluster agent health check
193124
run: |
194125
set -x
@@ -199,26 +130,18 @@ jobs:
199130
name: Test airgap installation
200131
runs-on: ubuntu-22.04
201132
needs: build
202-
133+
timeout-minutes: 30
203134
steps:
204135
- name: Checking out repo
205136
uses: actions/checkout@v4
206-
- name: Fetch snap
207-
uses: actions/download-artifact@v4
208-
with:
209-
name: microk8s.snap
210-
path: build
137+
- name: Prepare test prerequisites
138+
uses: ./.github/actions/test-prep
211139
- name: Initialize LXD
212140
run: |
213141
sudo lxd init --auto
214142
sudo lxc network set lxdbr0 ipv6.address=none
215143
sudo usermod --append --groups lxd $USER
216144
sg lxd -c 'lxc version'
217-
# Docker sets iptables rules that interfere with LXD or K8s.
218-
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
219-
- name: Apply Docker iptables workaround
220-
shell: bash
221-
run: sudo iptables -I DOCKER-USER -j ACCEPT
222145
- name: Run airgap tests
223146
run: |
224147
sudo -E bash -x -c "./tests/libs/airgap.sh --distro ubuntu:22.04 --channel $PWD/build/microk8s.snap"
@@ -227,6 +150,7 @@ jobs:
227150
name: Security scan
228151
runs-on: ubuntu-22.04
229152
needs: build
153+
timeout-minutes: 30
230154
steps:
231155
- name: Checking out repo
232156
uses: actions/checkout@v4

0 commit comments

Comments
 (0)