-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (32 loc) · 1.06 KB
/
rust.yml
File metadata and controls
41 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for Rust projects
id: check_rust
run: |
if [ -f "Cargo.toml" ] && ([ -f "src/main.rs" ] || [ -f "src/lib.rs" ]); then
echo "has_rust=true" >> $GITHUB_OUTPUT
else
echo "has_rust=false" >> $GITHUB_OUTPUT
echo "No valid Rust project (Cargo.toml + src/main.rs or src/lib.rs) found. Rust steps will be skipped."
echo "### 🦀 Rust Build Skip" >> $GITHUB_STEP_SUMMARY
echo "No valid Rust project found in the root directory. Rust build and test steps were skipped to prevent CI failure (Exit Code 101)." >> $GITHUB_STEP_SUMMARY
fi
- name: Build
if: steps.check_rust.outputs.has_rust == 'true'
run: cargo build --verbose
- name: Run tests
if: steps.check_rust.outputs.has_rust == 'true'
run: cargo test --verbose