Skip to content

Commit f76ee3b

Browse files
committed
feat: add generator test to CI
CI will now run the generators to ensure they succeed, and also verify they did not produce a diff. Signed-off-by: Shane Utt <[email protected]>
1 parent 5477e90 commit f76ee3b

File tree

1 file changed

+61
-35
lines changed

1 file changed

+61
-35
lines changed

.github/workflows/test.yaml

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,80 @@ name: tests
33
on:
44
pull_request:
55
branches:
6-
- '*'
6+
- "*"
77
push:
88
branches:
9-
- 'main'
9+
- "main"
1010
tags:
11-
- '*'
11+
- "*"
1212
workflow_dispatch: {}
1313

1414
jobs:
15-
unit-tests:
15+
verify-generated-code:
1616
runs-on: ubuntu-latest
1717
steps:
18+
- name: checkout repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: install rust
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: stable
27+
override: true
1828

19-
- name: checkout repository
20-
uses: actions/checkout@v3
21-
with:
22-
fetch-depth: 0
29+
- name: install kopium
30+
run: cargo install kopium --version 0.22.5
2331

24-
- name: install rust
25-
uses: actions-rs/toolchain@v1
26-
with:
27-
toolchain: stable
28-
override: true
32+
- name: run make generate
33+
run: make generate
2934

30-
- name: run unit tests
31-
uses: actions-rs/cargo@v1
32-
with:
33-
command: test
34-
args: -v -- --nocapture
35+
- name: verify no changes
36+
run: |
37+
if ! git diff --exit-code; then
38+
echo "Error: Generated code is not up to date. Please run 'make generate' and commit the changes."
39+
exit 1
40+
fi
41+
42+
unit-tests:
43+
runs-on: ubuntu-latest
44+
needs: verify-generated-code
45+
steps:
46+
- name: checkout repository
47+
uses: actions/checkout@v3
48+
with:
49+
fetch-depth: 0
50+
51+
- name: install rust
52+
uses: actions-rs/toolchain@v1
53+
with:
54+
toolchain: stable
55+
override: true
56+
57+
- name: run unit tests
58+
uses: actions-rs/cargo@v1
59+
with:
60+
command: test
61+
args: -v -- --nocapture
3562

3663
integration-tests:
3764
runs-on: ubuntu-latest
38-
needs: unit-tests
65+
needs: [verify-generated-code, unit-tests]
3966
steps:
67+
- name: checkout repository
68+
uses: actions/checkout@v3
69+
with:
70+
fetch-depth: 0
71+
72+
- name: install rust
73+
uses: actions-rs/toolchain@v1
74+
with:
75+
toolchain: stable
76+
override: true
4077

41-
- name: checkout repository
42-
uses: actions/checkout@v3
43-
with:
44-
fetch-depth: 0
45-
46-
- name: install rust
47-
uses: actions-rs/toolchain@v1
48-
with:
49-
toolchain: stable
50-
override: true
51-
52-
- name: run integration tests
53-
uses: actions-rs/cargo@v1
54-
with:
55-
command: test
56-
args: -v -- --nocapture --ignored
78+
- name: run integration tests
79+
uses: actions-rs/cargo@v1
80+
with:
81+
command: test
82+
args: -v -- --nocapture --ignored

0 commit comments

Comments
 (0)