1
- name : Rust
2
-
1
+ name : Rust CI
3
2
on :
4
3
pull_request :
5
4
branches : [ "master", "rewrite/v3" ]
6
5
push :
7
6
branches : [ "master", "rewrite/v3" ]
8
7
workflow_dispatch :
9
-
10
8
env :
11
9
CARGO_TERM_COLOR : always
12
-
10
+ defaults :
11
+ run :
12
+ shell : bash
13
13
jobs :
14
14
format :
15
- name : Check code formatting
15
+ name : Check Code Formatting
16
16
runs-on : ubuntu-latest
17
17
steps :
18
18
- name : Checkout repository
19
19
uses : actions/checkout@v4
20
-
20
+ - name : Cache dependencies
21
+ uses : actions/cache@v3
22
+ with :
23
+ path : |
24
+ ~/.cargo/registry
25
+ ~/.cargo/git
26
+ target
27
+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
28
+ restore-keys : |
29
+ ${{ runner.os }}-cargo-
21
30
- name : Install Rust nightly
22
31
uses : dtolnay/rust-toolchain@nightly
23
-
24
- - name : Install rustfmt
25
- run : rustup component add rustfmt
26
-
32
+ with :
33
+ components : rustfmt
27
34
- name : Run cargo fmt
28
35
run : cargo fmt --all -- --check
29
-
30
36
clippy :
31
37
name : Run Clippy
32
38
runs-on : ubuntu-latest
33
39
steps :
34
40
- name : Checkout repository
35
41
uses : actions/checkout@v4
36
-
37
- - name : Restore cargo cache
42
+ - name : Cache dependencies
38
43
uses : actions/cache@v3
39
44
with :
40
45
path : |
41
46
~/.cargo/registry
42
47
~/.cargo/git
48
+ target
43
49
key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
44
50
restore-keys : |
45
51
${{ runner.os }}-cargo-
46
-
47
52
- name : Install Rust nightly
48
53
uses : dtolnay/rust-toolchain@nightly
49
-
50
- - name : Install clippy
51
- run : rustup component add clippy
52
-
54
+ with :
55
+ components : clippy
53
56
- name : Run Clippy
54
- run : cargo clippy --all-targets -- -Dwarnings
55
-
57
+ run : cargo clippy --all-targets -- -D warnings
56
58
security :
57
- name : Check for security vulnerabilities
59
+ name : Check Security Vulnerabilities
58
60
runs-on : ubuntu-latest
59
61
steps :
60
62
- name : Checkout repository
61
63
uses : actions/checkout@v4
62
-
63
- - name : Install Rust nightly
64
- uses : dtolnay/rust-toolchain@nightly
65
-
66
- - name : Install audit
67
- run : cargo install cargo-audit
68
-
69
- - name : Run cargo audit
70
- run : cargo install cargo-audit && cargo audit
71
-
72
- build :
73
- name : Build project
74
- runs-on : ${{ matrix.os }}
75
- strategy :
76
- matrix :
77
- include :
78
- - os : macos-14
79
- target : aarch64-apple-darwin
80
- - os : ubuntu-latest
81
- target : x86_64-unknown-linux-gnu
82
- - os : windows-latest
83
- target : x86_64-pc-windows-msvc
84
-
85
- steps :
86
- - name : Checkout repository
87
- uses : actions/checkout@v4
88
-
89
64
- name : Cache dependencies
90
65
uses : actions/cache@v3
91
66
with :
@@ -96,17 +71,16 @@ jobs:
96
71
key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
97
72
restore-keys : |
98
73
${{ runner.os }}-cargo-
99
-
100
74
- name : Install Rust nightly
101
75
uses : dtolnay/rust-toolchain@nightly
102
- with :
103
- targets : ${{ matrix.target }}
104
-
105
- - name : Build
106
- run : cargo build --release --target ${{ matrix.target }} --verbose
107
-
76
+ - name : Install and Run Cargo Audit
77
+ run : |
78
+ if ! command -v cargo-audit &> /dev/null; then
79
+ cargo install cargo-audit
80
+ fi
81
+ cargo audit
108
82
test :
109
- name : Run tests
83
+ name : Run Tests
110
84
runs-on : ${{ matrix.os }}
111
85
strategy :
112
86
matrix :
@@ -117,26 +91,22 @@ jobs:
117
91
target : x86_64-unknown-linux-gnu
118
92
- os : windows-latest
119
93
target : x86_64-pc-windows-msvc
120
-
121
94
steps :
122
95
- name : Checkout repository
123
96
uses : actions/checkout@v4
124
-
125
97
- name : Cache dependencies
126
98
uses : actions/cache@v3
127
99
with :
128
100
path : |
129
101
~/.cargo/registry
130
102
~/.cargo/git
131
103
target
132
- key : ${{ runner .os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
104
+ key : ${{ matrix .os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
133
105
restore-keys : |
134
- ${{ runner.os }}-cargo-
135
-
106
+ ${{ matrix.os }}-cargo-
136
107
- name : Install Rust nightly
137
108
uses : dtolnay/rust-toolchain@nightly
138
109
with :
139
110
targets : ${{ matrix.target }}
140
-
141
- - name : Run tests
142
- run : cargo test --target ${{ matrix.target }} --verbose
111
+ - name : Run Tests
112
+ run : cargo test --target ${{ matrix.target }} --verbose
0 commit comments