Skip to content

Commit 9dfe1e9

Browse files
xixiaofinlandxi xiao
andauthored
Feature/c (#58)
* feat: update CI script * refactor: rename NodeInfo to NodeContext * refactor: fix CI warnings --------- Co-authored-by: xi xiao <tdxiaoxi2@gmail.com>
1 parent eea8ccd commit 9dfe1e9

File tree

15 files changed

+800
-692
lines changed

15 files changed

+800
-692
lines changed
Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,88 @@
11
name: PR CI and Merge Restrictions
2-
32
on:
43
pull_request:
5-
branches:
6-
- main
4+
branches: [main]
5+
# Add paths-ignore to skip CI for docs-only changes
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
9+
- 'LICENSE'
10+
11+
# Add concurrency to cancel outdated runs
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
715

816
jobs:
917
pr_ci_checks:
1018
name: PR Checks
1119
runs-on: ubuntu-latest
12-
1320
steps:
14-
# Step 1: Checkout Code
1521
- name: Checkout Code
1622
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # Needed for proper commit linting
1725

18-
# Step 2: Restrict Source Branch
1926
- name: Check Source Branch
2027
if: "!startsWith(github.head_ref, 'feature/') && !startsWith(github.head_ref, 'release-please--')"
2128
run: |
2229
echo "❌ Pull requests to main must come from feature/* or release-please-- branches."
2330
exit 1
2431
25-
# Step 3: Lint Commit Messages
2632
- name: Lint Commit Messages
2733
uses: wagoid/commitlint-github-action@v6
2834

29-
# Step 4: Cache Cargo Dependencies
30-
- name: Cache Cargo Registry
35+
# Combine both cache steps into one for better efficiency
36+
- name: Cache Rust Dependencies
3137
uses: actions/cache@v3
3238
with:
33-
path: ~/.cargo/registry
34-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
target
43+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3544
restore-keys: |
36-
${{ runner.os }}-cargo-registry-
45+
${{ runner.os }}-cargo-
3746
38-
- name: Cache Cargo Build
39-
uses: actions/cache@v3
40-
with:
41-
path: target
42-
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
43-
restore-keys: |
44-
${{ runner.os }}-cargo-build-
45-
46-
# Step 5: Set up Rust Toolchain
4747
- name: Set up Rust
4848
uses: dtolnay/rust-toolchain@stable
49+
with:
50+
components: clippy, rustfmt
4951

50-
# Step 6: Run Clippy
51-
- name: Run Clippy
52+
# Combine security tools installation
53+
- name: Install Security Tools
5254
run: |
55+
cargo install cargo-audit cargo-deny --locked
56+
57+
# Group formatting and linting checks
58+
- name: Code Quality Checks
59+
run: |
60+
cargo fmt -- --check
5361
cargo clippy --all-targets --all-features -- -D warnings
5462
55-
# Step 7: Run Tests
63+
# Run tests with coverage
5664
- name: Run Tests
57-
run: cargo test --all-features
58-
59-
# Step 8: Check Formatting
60-
- name: Check Formatting
61-
run: cargo fmt -- --check
62-
63-
# Step 9: Run Cargo Audit (Security Checks)
64-
- name: Run Cargo Audit
6565
run: |
66-
cargo install cargo-audit
67-
cargo audit
66+
cargo install cargo-tarpaulin
67+
cargo tarpaulin --out Xml
6868
69-
# Step 10: Run Cargo Deny (Dependency Checks)
70-
- name: Run Cargo Deny
69+
# Add test coverage reporting
70+
- name: Upload Coverage
71+
uses: codecov/codecov-action@v3
72+
if: always() # Run even if tests fail
73+
74+
# Group security checks
75+
- name: Security Audit
7176
run: |
72-
cargo install cargo-deny
77+
cargo audit --stale
7378
cargo deny check
79+
80+
# Add caching for installed tools
81+
- name: Cache Tools
82+
uses: actions/cache@v3
83+
with:
84+
path: |
85+
~/.cargo/bin/cargo-audit
86+
~/.cargo/bin/cargo-deny
87+
~/.cargo/bin/cargo-tarpaulin
88+
key: ${{ runner.os }}-cargo-tools-${{ hashFiles('**/Cargo.lock') }}

0 commit comments

Comments
 (0)