4
4
workflow_call :
5
5
6
6
jobs :
7
- check :
7
+ clippy :
8
8
runs-on : ubuntu-latest
9
9
strategy :
10
10
fail-fast : false
11
11
matrix :
12
- check : [clippy, test, udeps]
13
12
crate : [web-prover-notary, web-prover-client, web-prover-core]
14
- include :
15
- - check : fmt
16
- crate : all
17
13
steps :
18
14
- uses : actions/checkout@v4
19
15
20
- # Setup Rust with cache key based on check type
21
16
- uses : ./.github/actions/setup-rust-ubuntu
22
17
with :
23
- rust-cache-key : ${{ matrix.check }}
18
+ rust-cache-key : clippy- ${{ matrix.crate }}
24
19
25
- # Install necessary tools based on check type
26
- - name : Install cargo-binstall
27
- if : matrix.check == 'udeps'
28
- uses : cargo-bins/cargo-binstall@main
20
+ - name : Run clippy
21
+ continue-on-error : true
22
+ run : cargo clippy -p ${{ matrix.crate }}
23
+
24
+ # Save the target directory to cache for reuse in test job
25
+ - name : Save target directory
26
+ uses : actions/cache/save@v3
27
+ with :
28
+ path : |
29
+ target/
30
+ ~/.cargo/registry/
31
+ ~/.cargo/git/
32
+ key : build-cache-${{ matrix.crate }}-${{ github.sha }}
29
33
30
- - name : Install cargo-udeps
31
- if : matrix.check == 'udeps'
32
- run : cargo binstall --no-confirm cargo-udeps
34
+ fmt :
35
+ runs-on : ubuntu-latest
36
+ steps :
37
+ - uses : actions/checkout@v4
38
+
39
+ - uses : ./.github/actions/setup-rust-ubuntu
40
+ with :
41
+ rust-cache-key : fmt
33
42
34
- - name : Install rustfmt
35
- if : matrix.check == 'fmt'
36
- run : rustup component add rustfmt
43
+ - run : rustup component add rustfmt
37
44
38
- # Run the appropriate check
39
- - name : Run clippy
40
- if : matrix.check == 'clippy'
41
- continue-on-error : true
42
- run : cargo clippy -p ${{ matrix.crate }} -- -D warnings
45
+ - run : cargo fmt --all -- --check
46
+
47
+ test :
48
+ needs : clippy
49
+ runs-on : ubuntu-latest
50
+ strategy :
51
+ fail-fast : false
52
+ matrix :
53
+ crate : [web-prover-notary, web-prover-client, web-prover-core]
54
+ steps :
55
+ - uses : actions/checkout@v4
56
+
57
+ - uses : ./.github/actions/setup-rust-ubuntu
58
+ with :
59
+ rust-cache-key : test-${{ matrix.crate }}
60
+
61
+ # Restore the target directory from clippy job
62
+ - name : Restore cached build
63
+ uses : actions/cache/restore@v3
64
+ with :
65
+ path : |
66
+ target/
67
+ ~/.cargo/registry/
68
+ ~/.cargo/git/
69
+ key : build-cache-${{ matrix.crate }}-${{ github.sha }}
70
+ restore-keys : |
71
+ build-cache-${{ matrix.crate }}-
43
72
44
73
- name : Run tests
45
- if : matrix.check == 'test'
46
74
run : cargo test -p ${{ matrix.crate }}
47
75
48
- - name : Check fmt
49
- if : matrix.check == 'fmt'
50
- continue-on-error : true
51
- run : cargo fmt --all -- --check
76
+ udeps :
77
+ runs-on : ubuntu-latest
78
+ strategy :
79
+ fail-fast : false
80
+ matrix :
81
+ crate : [web-prover-notary, web-prover-client, web-prover-core]
82
+ steps :
83
+ - uses : actions/checkout@v4
84
+
85
+ - name : Install cargo-binstall
86
+ uses : cargo-bins/cargo-binstall@main
87
+
88
+ - uses : ./.github/actions/setup-rust-ubuntu
89
+ with :
90
+ rust-cache-key : udeps-${{ matrix.crate }}
91
+
92
+ - name : Install cargo-udeps
93
+ run : cargo binstall --no-confirm cargo-udeps
52
94
53
95
- name : Check unused dependencies
54
- if : matrix.check == 'udeps'
55
96
continue-on-error : true
56
97
run : cargo udeps -p ${{ matrix.crate }}
0 commit comments