Skip to content

Commit 1dafee6

Browse files
committed
gihub/workflow/test: Use yaml anchors to reduce duplication.
* Create a dummy section with the steps. * Reference the steps from each section. Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
1 parent 9b07ad2 commit 1dafee6

1 file changed

Lines changed: 77 additions & 108 deletions

File tree

.github/workflows/test.yml

Lines changed: 77 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,37 @@ on:
1212
push:
1313
pull_request:
1414

15-
jobs:
15+
shared-steps:
16+
.: &step-install-apt
17+
name: Install dependencies
18+
run: |
19+
apt update -qq
20+
apt install -y make wget git
21+
.: &step-checkout
22+
uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
1625

26+
.: &step-make-env
27+
name: Make env
28+
run: |
29+
cd test
30+
make env
31+
make env-info
32+
33+
.: &step-make-example-command
34+
name: Make example-command
35+
run: |
36+
cd test
37+
make example-command
38+
39+
.: &step-make-test-command
40+
name: Make test-command
41+
run: |
42+
cd test
43+
make test-command
44+
45+
jobs:
1746

1847
test:
1948
strategy:
@@ -33,29 +62,13 @@ jobs:
3362
git config --global core.autocrlf input
3463
git config --global core.symlinks true
3564
36-
- uses: actions/checkout@v2
37-
with:
38-
fetch-depth: 0
39-
40-
- name: Make env
41-
run: |
42-
cd test
43-
make env
44-
make env-info
65+
- *step-checkout
66+
- *step-make-env
67+
- *step-make-example-command
68+
- *step-make-test-command
4569

46-
- name: Make example-command
47-
run: |
48-
cd test
49-
make example-command
50-
51-
- name: Make test-command
52-
run: |
53-
cd test
54-
make test-command
55-
56-
57-
# https://www.debian.org/releases/
58-
# http://releases.ubuntu.com/
70+
# Debian should test on all stable/testing/unstable
71+
# See https://www.debian.org/releases/
5972
debian:
6073
runs-on: ubuntu-latest
6174
strategy:
@@ -66,40 +79,41 @@ jobs:
6679
- debian:buster
6780
- debian:bullseye
6881
- debian:sid
82+
container: ${{ matrix.os }}
83+
steps:
84+
- *step-install-apt
85+
- *step-checkout
86+
- *step-make-env
87+
- *step-make-example-command
88+
- *step-make-test-command
89+
90+
# Ubuntu should test on;
91+
# - On all the LTS versions
92+
# - The latest version of Ubuntu
93+
# See http://releases.ubuntu.com/
94+
ubuntu:
95+
runs-on: ubuntu-latest
96+
strategy:
97+
fail-fast: false
98+
max-parallel: 3
99+
matrix:
100+
os:
69101
- ubuntu:14.04
70102
- ubuntu:16.04
71103
- ubuntu:18.04
72104
- ubuntu:20.04
73105
- ubuntu:20.10
74106
container: ${{ matrix.os }}
75107
steps:
76-
77-
- name: Install dependencies
78-
run: |
79-
apt update -qq
80-
apt install -y make wget git
81-
82-
- uses: actions/checkout@v2
83-
with:
84-
fetch-depth: 0
85-
86-
- name: Make env
87-
run: |
88-
cd test
89-
make env
90-
make env-info
91-
92-
- name: Make example-command
93-
run: |
94-
cd test
95-
make example-command
96-
97-
- name: Make test-command
98-
run: |
99-
cd test
100-
make test-command
108+
- *step-install-apt
109+
- *step-checkout
110+
- *step-make-env
111+
- *step-make-example-command
112+
- *step-make-test-command
101113

102114

115+
# Fedora should test on;
116+
# - FIXME: Figure out a good policy
103117
# https://fedoraproject.org/wiki/Releases
104118
fedora:
105119
runs-on: ubuntu-latest
@@ -112,34 +126,19 @@ jobs:
112126
- 33
113127
- 34
114128
container: fedora:${{ matrix.os }}
115-
steps:
116129

130+
steps:
117131
- name: Install dependencies
118132
run: |
119133
dnf update -y
120134
dnf install -y make wget git which
121135
122-
- uses: actions/checkout@v2
123-
with:
124-
fetch-depth: 0
125-
126-
- name: Make env
127-
run: |
128-
cd test
129-
make env
130-
make env-info
131-
132-
- name: Make example-command
133-
run: |
134-
cd test
135-
make example-command
136-
137-
- name: Make test-command
138-
run: |
139-
cd test
140-
make test-command
141-
136+
- *step-checkout
137+
- *step-make-env
138+
- *step-make-example-command
139+
- *step-make-test-command
142140

141+
# Test on the LTS versions of CentOS
143142
centos:
144143
runs-on: ubuntu-latest
145144
strategy:
@@ -157,27 +156,12 @@ jobs:
157156
yum update -y
158157
yum install -y make wget git which
159158
160-
- uses: actions/checkout@v2
161-
with:
162-
fetch-depth: 0
163-
164-
- name: Make env
165-
run: |
166-
cd test
167-
make env
168-
make env-info
169-
170-
- name: Make example-command
171-
run: |
172-
cd test
173-
make example-command
174-
175-
- name: Make test-command
176-
run: |
177-
cd test
178-
make test-command
179-
159+
- *step-checkout
160+
- *step-make-env
161+
- *step-make-example-command
162+
- *step-make-test-command
180163

164+
# Test on the latest version or archlinux
181165
archlinux:
182166
runs-on: ubuntu-latest
183167
container: archlinux
@@ -188,22 +172,7 @@ jobs:
188172
pacman -Syu --noconfirm
189173
pacman -S make wget git which --noconfirm
190174
191-
- uses: actions/checkout@v2
192-
with:
193-
fetch-depth: 0
194-
195-
- name: Make env
196-
run: |
197-
cd test
198-
make env
199-
make env-info
200-
201-
- name: Make example-command
202-
run: |
203-
cd test
204-
make example-command
205-
206-
- name: Make test-command
207-
run: |
208-
cd test
209-
make test-command
175+
- *step-checkout
176+
- *step-make-env
177+
- *step-make-example-command
178+
- *step-make-test-command

0 commit comments

Comments
 (0)