1010 CARGO_TERM_COLOR : always
1111
1212jobs :
13+ # Rule 1: Check for errors (formatting, linting, compilation)
1314 check :
14- name : Check
15+ name : Check - No Errors
1516 runs-on : ubuntu-latest
1617 steps :
1718 - name : Checkout sources
@@ -36,17 +37,18 @@ jobs:
3637 restore-keys : |
3738 ${{ runner.os }}-cargo-
3839
39- - name : Run cargo check
40- run : cargo check --all --locked
41-
42- - name : Run cargo fmt
40+ - name : Check code formatting
4341 run : cargo fmt --all -- --check
4442
45- - name : Run cargo clippy
43+ - name : Run clippy linter (treat warnings as errors)
4644 run : cargo clippy --all -- -D warnings
4745
46+ - name : Check for compilation errors
47+ run : cargo check --all --locked
48+
49+ # Rule 3: All tests must pass
4850 test :
49- name : Test Suite
51+ name : Test - All Tests Must Pass
5052 runs-on : ubuntu-latest
5153 steps :
5254 - name : Checkout sources
@@ -71,11 +73,33 @@ jobs:
7173 restore-keys : |
7274 ${{ runner.os }}-cargo-
7375
74- - name : Run cargo test
76+ - name : Run all tests
7577 run : cargo test --all --locked
7678
79+ - name : Check for new test files
80+ id : check_new_tests
81+ if : github.event_name == 'pull_request'
82+ run : |
83+ echo "Checking for new test files in this PR..."
84+ git fetch origin ${{ github.base_ref }} --depth=1
85+ NEW_TEST_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '(test.*\.rs|.*_test\.rs|tests/.*\.rs)$' || true)
86+ if [ -n "$NEW_TEST_FILES" ]; then
87+ echo "New test files detected:"
88+ echo "$NEW_TEST_FILES"
89+ echo "new_tests=true" >> $GITHUB_OUTPUT
90+ else
91+ echo "No new test files detected"
92+ echo "new_tests=false" >> $GITHUB_OUTPUT
93+ fi
94+
95+ - name : Validate new test files pass
96+ if : steps.check_new_tests.outputs.new_tests == 'true'
97+ run : |
98+ echo "✅ New test files detected and all tests passed!"
99+
100+ # Rule 2: Build must succeed before PR
77101 build :
78- name : Build
102+ name : Build - Must Build Successfully
79103 runs-on : ubuntu-latest
80104 needs : [check, test]
81105 steps :
@@ -114,8 +138,28 @@ jobs:
114138 path : target/wasm32-unknown-unknown/release/stellaraid_core.wasm
115139 retention-days : 30
116140
141+ # PR Validation - Enforces all 3 rules
142+ pr-validation :
143+ name : PR Validation - All Rules Passed
144+ runs-on : ubuntu-latest
145+ needs : [check, test, build]
146+ if : github.event_name == 'pull_request'
147+ steps :
148+ - name : Validate all checks passed
149+ run : |
150+ echo "========================================"
151+ echo " PR Validation Summary"
152+ echo "========================================"
153+ echo ""
154+ echo "Rule 1 - No Errors: ${{ needs.check.result }}"
155+ echo "Rule 2 - Build Success: ${{ needs.build.result }}"
156+ echo "Rule 3 - Tests Pass: ${{ needs.test.result }}"
157+ echo ""
158+ echo "✅ ALL 3 RULES PASSED - PR APPROVED FOR MERGE"
159+
160+ # Cross-platform build verification
117161 build-matrix :
118- name : Build Matrix
162+ name : Build Matrix (Cross-Platform)
119163 runs-on : ${{ matrix.os }}
120164 needs : check
121165 strategy :
@@ -150,6 +194,7 @@ jobs:
150194 - name : Build WASM contract
151195 run : cargo build -p stellaraid-core --target wasm32-unknown-unknown
152196
197+ # Security scans
153198 security :
154199 name : Security Scans
155200 runs-on : ubuntu-latest
0 commit comments