Skip to content

Commit 20105d5

Browse files
committed
ci: Introduce E2E tests for CLI
This will simplify further development.
1 parent c4d9499 commit 20105d5

File tree

3 files changed

+292
-0
lines changed

3 files changed

+292
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
name: E2E tests
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
linux-amd64:
10+
name: Linux amd64
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
14+
steps:
15+
- name: Harden Runner
16+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
17+
with:
18+
egress-policy: block
19+
allowed-endpoints: >
20+
github.com:443
21+
api.github.com:443
22+
objects.githubusercontent.com:443
23+
ppa.launchpadcontent.net:443
24+
azure.archive.ubuntu.com:80
25+
motd.ubuntu.com:443
26+
esm.ubuntu.com:443
27+
security.ubuntu.com:80
28+
proxy.golang.org:443
29+
hn.algolia.com:80
30+
hn.algolia.com:443
31+
lemmy.world:443
32+
lobste.rs:443
33+
www.reddit.com:443
34+
35+
- name: Checkout repository
36+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
37+
38+
- name: Setup seccomp
39+
uses: awalsh128/cache-apt-pkgs-action@44c33b32f808cdddd5ac0366d70595ed63661ed8 # v1.3.1
40+
with:
41+
packages: libseccomp-dev
42+
43+
- name: Setup Go
44+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
45+
with:
46+
go-version: 'stable'
47+
48+
- name: Install dependencies
49+
run: make
50+
51+
- name: Build executable
52+
run: make build
53+
54+
- run: make e2e
55+
56+
linux-arm:
57+
name: Linux ARMv7
58+
runs-on: ubuntu-latest
59+
timeout-minutes: 10
60+
61+
steps:
62+
- name: Harden Runner
63+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
64+
with:
65+
egress-policy: block
66+
allowed-endpoints: >
67+
github.com:443
68+
api.github.com:443
69+
objects.githubusercontent.com:443
70+
proxy.golang.org:443
71+
ppa.launchpadcontent.net:443
72+
packages.microsoft.com:443
73+
azure.archive.ubuntu.com:80
74+
motd.ubuntu.com:443
75+
esm.ubuntu.com:443
76+
downloads.raspberrypi.org:443
77+
hn.algolia.com:80
78+
hn.algolia.com:443
79+
lemmy.world:443
80+
lobste.rs:443
81+
www.reddit.com:443
82+
83+
- name: Checkout repository
84+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
85+
86+
- name: Setup Go
87+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
88+
with:
89+
go-version: 'stable'
90+
91+
- name: Install dependencies
92+
run: make
93+
94+
- name: Build executable
95+
run: GOOS=linux GOARCH=arm GOARM=7 make unsafe
96+
97+
- name: Run E2E tests inside VM
98+
uses: pguyot/arm-runner-action@e04ca3becb581a2b52cabe31e53835ada344522f # v2.5.2
99+
with:
100+
cpu: cortex-a7
101+
cpu_info: cpuinfo/raspberrypi_3b
102+
base_image: raspios_lite:latest
103+
commands: |
104+
make e2e
105+
106+
linux-arm64:
107+
name: Linux ARM64
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 10
110+
111+
steps:
112+
- name: Harden Runner
113+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
114+
with:
115+
egress-policy: block
116+
allowed-endpoints: >
117+
github.com:443
118+
api.github.com:443
119+
objects.githubusercontent.com:443
120+
proxy.golang.org:443
121+
ppa.launchpadcontent.net:443
122+
packages.microsoft.com:443
123+
azure.archive.ubuntu.com:80
124+
motd.ubuntu.com:443
125+
esm.ubuntu.com:443
126+
downloads.raspberrypi.org:443
127+
hn.algolia.com:80
128+
hn.algolia.com:443
129+
lemmy.world:443
130+
lobste.rs:443
131+
www.reddit.com:443
132+
133+
- name: Checkout repository
134+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
135+
136+
- name: Setup Go
137+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
138+
with:
139+
go-version: 'stable'
140+
141+
- name: Install dependencies
142+
run: make
143+
144+
- name: Build executable
145+
run: GOOS=linux GOARCH=arm64 make unsafe
146+
147+
- name: Run E2E tests inside VM
148+
uses: pguyot/arm-runner-action@e04ca3becb581a2b52cabe31e53835ada344522f # v2.5.2
149+
with:
150+
cpu: cortex-a53
151+
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64
152+
base_image: raspios_lite_arm64:latest
153+
commands: |
154+
make e2e
155+
156+
windows:
157+
name: Windows amd64 (not hardened)
158+
runs-on: windows-latest
159+
timeout-minutes: 10
160+
161+
steps:
162+
- name: Checkout repository
163+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
164+
165+
- name: Setup Go
166+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
167+
with:
168+
go-version: 'stable'
169+
170+
- name: Install dependencies
171+
run: make
172+
173+
- name: Build executable
174+
run: make unsafe
175+
176+
- run: make e2e
177+
178+
freebsd:
179+
name: FreeBSD amd64
180+
runs-on: ubuntu-latest
181+
timeout-minutes: 10
182+
183+
steps:
184+
- name: Harden Runner
185+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
186+
with:
187+
egress-policy: block
188+
allowed-endpoints: >
189+
github.com:443
190+
api.github.com:443
191+
proxy.golang.org:443
192+
0.freebsd.pool.ntp.org:443
193+
2.freebsd.pool.ntp.org:443
194+
raw.githubusercontent.com:443
195+
objects.githubusercontent.com:443
196+
changelogs.ubuntu.com:443
197+
ppa.launchpadcontent.net:443
198+
packages.microsoft.com:443
199+
azure.archive.ubuntu.com:80
200+
motd.ubuntu.com:443
201+
esm.ubuntu.com:443
202+
pypi.org:443
203+
files.pythonhosted.org:443
204+
hn.algolia.com:80
205+
hn.algolia.com:443
206+
lemmy.world:443
207+
lobste.rs:443
208+
www.reddit.com:443
209+
210+
- name: Checkout repository
211+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
212+
213+
- name: Setup Go
214+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
215+
with:
216+
go-version: 'stable'
217+
218+
- name: Install dependencies
219+
run: make
220+
221+
- name: Build executable for FreeBSD amd64
222+
run: GOOS=freebsd GOARCH=amd64 make unsafe
223+
224+
- name: Run E2E tests inside VM
225+
uses: vmactions/freebsd-vm@d139f0eaa5d47d9fcc44f7ab1748574475d89565 # v1.0.5
226+
with:
227+
usesh: true
228+
run: |
229+
set -e -x
230+
make e2e
231+
232+
openbsd:
233+
name: OpenBSD amd64
234+
runs-on: ubuntu-latest
235+
timeout-minutes: 10
236+
237+
steps:
238+
- name: Harden Runner
239+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
240+
with:
241+
egress-policy: block
242+
allowed-endpoints: >
243+
github.com:443
244+
api.github.com:443
245+
proxy.golang.org:443
246+
pool.ntp.org:443
247+
cdn.openbsd.org:443
248+
www.google.com:443
249+
raw.githubusercontent.com:443
250+
objects.githubusercontent.com:443
251+
time.cloudflare.com:443
252+
ppa.launchpadcontent.net:443
253+
packages.microsoft.com:443
254+
azure.archive.ubuntu.com:80
255+
motd.ubuntu.com:443
256+
esm.ubuntu.com:443
257+
pypi.org:443
258+
files.pythonhosted.org:443
259+
hn.algolia.com:80
260+
hn.algolia.com:443
261+
lemmy.world:443
262+
lobste.rs:443
263+
www.reddit.com:443
264+
265+
- name: Checkout repository
266+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
267+
268+
- name: Setup Go
269+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
270+
with:
271+
go-version: 'stable'
272+
273+
- name: Install dependencies
274+
run: make
275+
276+
- name: Build executable for OpenBSD amd64
277+
run: GOOS=openbsd GOARCH=amd64 make build
278+
279+
- name: Run E2E tests inside VM
280+
uses: vmactions/openbsd-vm@c69c6aa05e19f11533a5d00913e398606bd66133 # v1.0.4
281+
with:
282+
run: |
283+
make e2e

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ test:
2525
@echo '# Unit tests: go test .' >&2
2626
@go test .
2727

28+
e2e:
29+
@echo '# E2E tests of ./dist/opinions' >&2
30+
@printf 'Hacker News\nLemmy\nLobsters\nReddit\n' >test_case.grugbrain
31+
@printf '' >test_case.unknown
32+
./dist/opinions --version
33+
./dist/opinions --timeout 10s 'https://grugbrain.dev' | cut -d' ' -f1 | sort -u | diff test_case.grugbrain -
34+
./dist/opinions --timeout 8500ms 'zażółćjaźńgęślą' | diff test_case.unknown -
35+
2836
build: *.go
2937
@echo '# Create release binary: ./dist/opinions' >&2
3038
@CURRENT_VER_TAG="$$(git tag --points-at HEAD | sed 's/^v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)"; \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Use `make` (GNU or BSD):
6666
6767
- `make` - install dependencies
6868
- `make test` - runs test
69+
- `make e2e` - runs e2e tests for CLI
6970
- `make check` - static code analysis
7071
- `make build` - compile binary from latest commit
7172
- `make unsafe` - compile binary from latest commit without security sandbox

0 commit comments

Comments
 (0)