File tree 1 file changed +65
-0
lines changed
1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Rust
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
8
+
9
+ jobs :
10
+ test :
11
+ name : Run Rust Tests
12
+ runs-on : ubuntu-latest
13
+
14
+ steps :
15
+ # Checkout the code
16
+ - name : Checkout Code
17
+ uses : actions/checkout@v4
18
+
19
+ # Set up Rust toolchain.
20
+ # This will be overwritten anyway by a `rust-toolchain.toml`
21
+ # file.
22
+ - name : Setup Rust Toolchain
23
+ uses : actions-rust-lang/setup-rust-toolchain@v1
24
+ with :
25
+ toolchain : stable
26
+ components : rustfmt
27
+
28
+ # Run install toolchains for each `blog/*/code` directory
29
+ - name : Installing Rust toolchains
30
+ run : |
31
+ for dir in blog/*/code; do
32
+ if [ -f "$dir/Cargo.toml" ]; then
33
+ echo "Installing toolchain for $dir"
34
+ (cd "$dir" && cargo version)
35
+ else
36
+ echo "Skipping $dir as it does not contain a Cargo.toml file"
37
+ fi
38
+ done
39
+
40
+ # Run rustfmt and confirm no changes for each `blog/*/code` directory
41
+ - name : Check Formatting
42
+ run : |
43
+ for dir in blog/*/code; do
44
+ if [ -f "$dir/Cargo.toml" ]; then
45
+ echo "Checking formatting in $dir"
46
+ (cd "$dir" && cargo fmt --check)
47
+ else
48
+ echo "Skipping $dir as it does not contain a Cargo.toml file"
49
+ fi
50
+ done
51
+
52
+ # Run tests for each `blog/*/code` directory
53
+ - name : Build and Test
54
+ run : |
55
+ for dir in blog/*/code; do
56
+ if [ -f "$dir/Cargo.toml" ]; then
57
+ cd "$dir";
58
+ echo "Running build in $dir"
59
+ cargo build --release
60
+ echo "Running tests in $dir"
61
+ cargo test --release
62
+ else
63
+ echo "Skipping $dir as it does not contain a Cargo.toml file"
64
+ fi
65
+ done
You can’t perform that action at this time.
0 commit comments