Skip to content

Commit 8cdd81a

Browse files
committed
refactor: split tests
1 parent 2f811fa commit 8cdd81a

7 files changed

Lines changed: 55 additions & 113 deletions

File tree

.github/workflows/build-dist.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
7575
- name: Build artifacts
7676
run: |
77-
devenv tasks run dist:clean --mode before
78-
devenv tasks run dist:build --mode before
77+
devenv tasks run dist:clean
78+
devenv tasks run dist:build
7979
8080
- name: Commit and push dist branch
8181
run: |

.github/workflows/lint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: nix profile install nixpkgs#devenv
2323
- name: Build Web Assets
2424
run: |
25-
devenv tasks run dist:clean --mode before
26-
devenv tasks run dist:build --mode before
25+
devenv tasks run dist:clean
26+
devenv tasks run dist:build
2727
- name: Lint
28-
run: devenv tasks run go:lint --mode before
28+
run: devenv tasks run go:lint

.github/workflows/test.yaml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ jobs:
1818
- name: Install devenv.sh
1919
run: nix profile install nixpkgs#devenv
2020
- name: Build Web Assets
21-
run: |
22-
devenv tasks run dist:clean --mode before
23-
devenv tasks run dist:build --mode before
21+
run: devenv tasks run dist:build
2422
- name: Build
2523
run: devenv shell xcaddy build
2624
- name: Upload artifacts
@@ -29,8 +27,21 @@ jobs:
2927
name: "caddy"
3028
path: "caddy"
3129
test:
32-
name: Test
30+
name: Test (${{ matrix.name }})
3331
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- name: Go
37+
task: test:go
38+
artifact: false
39+
- name: Rust
40+
task: test:rust
41+
artifact: false
42+
- name: Playwright
43+
task: test:playwright
44+
artifact: true
3445
steps:
3546
- uses: actions/checkout@v4
3647
- uses: cachix/install-nix-action@v26
@@ -39,14 +50,10 @@ jobs:
3950
name: devenv
4051
- name: Install devenv.sh
4152
run: nix profile install nixpkgs#devenv
42-
- name: Build Web Assets
43-
run: |
44-
devenv tasks run dist:clean --mode before
45-
devenv tasks run dist:build --mode before
4653
- name: Test
47-
run: devenv test
54+
run: devenv tasks run ${{ matrix.task }}
4855
- uses: actions/upload-artifact@v4
49-
if: ${{ !cancelled() }}
56+
if: ${{ !cancelled() && matrix.artifact }}
5057
with:
5158
name: playwright-report
5259
path: web/playwright-report/

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Cerberus is a Caddy plugin that protects open source infrastructure using sha256
1111
### Code Generation
1212
Before developing, generate necessary Go files:
1313
```bash
14-
devenv tasks run go:codegen --mode before
14+
devenv tasks run go:codegen
1515
```
1616

1717
### Building Web Assets
1818
After modifying web assets:
1919
```bash
20-
devenv tasks run dist:build --mode before
20+
devenv tasks run dist:build
2121
```
2222

2323
### Testing
@@ -36,7 +36,7 @@ cd web && pnpm exec playwright test --project=chromium
3636

3737
### Linting
3838
```bash
39-
devenv tasks run go:lint --mode before
39+
devenv tasks run go:lint
4040
```
4141

4242
### Testing Requirements

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ This will surely slow down legitimate users, but we believe that this is a neces
6666

6767
You need to first generate necessary go files before developing:
6868
```bash
69-
$ devenv tasks run go:codegen --mode before
69+
$ devenv tasks run go:codegen
7070
```
7171

7272
If you modified any web asset, you need to run the following command to build the dist files:
7373
```bash
74-
$ devenv tasks run dist:build --mode before
74+
$ devenv tasks run dist:build
7575
```
7676

7777
Please run tests and lints before submitting a PR:
7878
```bash
7979
$ direnv test # or go test
80-
$ devenv tasks run go:lint --mode before
80+
$ devenv tasks run go:lint
8181
```
8282

8383
## Build Pipeline

devenv.lock

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,6 @@
1616
"type": "github"
1717
}
1818
},
19-
"flake-compat": {
20-
"flake": false,
21-
"locked": {
22-
"lastModified": 1767039857,
23-
"owner": "NixOS",
24-
"repo": "flake-compat",
25-
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
26-
"type": "github"
27-
},
28-
"original": {
29-
"owner": "NixOS",
30-
"repo": "flake-compat",
31-
"type": "github"
32-
}
33-
},
34-
"git-hooks": {
35-
"inputs": {
36-
"flake-compat": "flake-compat",
37-
"gitignore": "gitignore",
38-
"nixpkgs": [
39-
"nixpkgs"
40-
]
41-
},
42-
"locked": {
43-
"lastModified": 1769939035,
44-
"owner": "cachix",
45-
"repo": "git-hooks.nix",
46-
"rev": "a8ca480175326551d6c4121498316261cbb5b260",
47-
"type": "github"
48-
},
49-
"original": {
50-
"owner": "cachix",
51-
"repo": "git-hooks.nix",
52-
"type": "github"
53-
}
54-
},
55-
"gitignore": {
56-
"inputs": {
57-
"nixpkgs": [
58-
"git-hooks",
59-
"nixpkgs"
60-
]
61-
},
62-
"locked": {
63-
"lastModified": 1762808025,
64-
"owner": "hercules-ci",
65-
"repo": "gitignore.nix",
66-
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
67-
"type": "github"
68-
},
69-
"original": {
70-
"owner": "hercules-ci",
71-
"repo": "gitignore.nix",
72-
"type": "github"
73-
}
74-
},
7519
"nixpkgs": {
7620
"locked": {
7721
"lastModified": 1770169770,
@@ -90,11 +34,7 @@
9034
"root": {
9135
"inputs": {
9236
"devenv": "devenv",
93-
"git-hooks": "git-hooks",
9437
"nixpkgs": "nixpkgs",
95-
"pre-commit-hooks": [
96-
"git-hooks"
97-
],
9838
"rust-overlay": "rust-overlay"
9939
}
10040
},
@@ -120,4 +60,4 @@
12060
},
12161
"root": "root",
12262
"version": 7
123-
}
63+
}

devenv.nix

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,32 @@
122122
"go:codegen"
123123
];
124124
};
125+
"test:go" = {
126+
exec = "go test ./...";
127+
after = [
128+
"dist:build"
129+
];
130+
};
131+
"test:rust" = {
132+
exec = ''
133+
cd pow
134+
PATH="${rust-toolchain}/bin:${pkgs.nodejs}/bin:$PATH" \
135+
RUSTFLAGS="-Ctarget-cpu=mvp -Ctarget-feature=+simd128" \
136+
${wasm-pack} test --node
137+
'';
138+
after = [
139+
"js:install"
140+
];
141+
};
142+
"test:playwright" = {
143+
exec = ''
144+
cd web
145+
${pnpm} exec playwright test
146+
'';
147+
after = [
148+
"dist:build"
149+
];
150+
};
125151
};
126152

127153
# tasks = {
@@ -153,37 +179,6 @@
153179
validate-playwright
154180
'';
155181

156-
# https://devenv.sh/tests/
157-
enterTest =
158-
let
159-
pnpm = "${pkgs.nodePackages.pnpm}/bin/pnpm";
160-
wasm-pack = "${pkgs.wasm-pack}/bin/wasm-pack";
161-
rust-toolchain = pkgs.rust-bin.selectLatestNightlyWith (
162-
toolchain:
163-
toolchain.minimal.override {
164-
extensions = [ "rust-src" ];
165-
targets = [ "wasm32-unknown-unknown" ];
166-
}
167-
);
168-
in
169-
''
170-
echo "Running Go tests"
171-
go test ./...
172-
173-
echo "Running native Rust PoW tests"
174-
cd pow
175-
PATH="${rust-toolchain}/bin:$PATH" cargo test
176-
177-
echo "Running wasm SIMD Rust PoW tests"
178-
PATH="${rust-toolchain}/bin:${pkgs.nodejs}/bin:$PATH" \
179-
RUSTFLAGS="-Ctarget-cpu=mvp -Ctarget-feature=+simd128" \
180-
${wasm-pack} test --node
181-
cd ..
182-
183-
echo "Running Playwright tests"
184-
cd web && ${pnpm} exec playwright test
185-
'';
186-
187182
# https://devenv.sh/git-hooks/
188183
# git-hooks.hooks.shellcheck.enable = true;
189184

0 commit comments

Comments
 (0)