Nightly Build & Test #180
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Build & Test | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' # Run at 2 AM UTC daily | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| nightly-rust: | |
| name: Nightly Rust Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rustfmt, clippy, miri | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: backend | |
| - name: Run tests on nightly | |
| run: cargo test --all-features | |
| working-directory: backend | |
| continue-on-error: true | |
| - name: Run clippy on nightly | |
| run: cargo clippy --all-targets --all-features | |
| working-directory: backend | |
| continue-on-error: true | |
| - name: Check formatting on nightly | |
| run: cargo fmt --all -- --check | |
| working-directory: backend | |
| continue-on-error: true | |
| full-test-suite: | |
| name: Full Test Suite | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: backend | |
| # Run all Rust tests including ignored ones | |
| - name: Run all tests (including ignored) | |
| run: cargo test --all-features -- --include-ignored | |
| working-directory: backend | |
| continue-on-error: true | |
| # Run with extra checking | |
| - name: Run with address sanitizer | |
| run: | | |
| export RUSTFLAGS="-Z sanitizer=address" | |
| cargo +nightly test --all-features --target x86_64-unknown-linux-gnu | |
| working-directory: backend | |
| continue-on-error: true | |
| coverage-report: | |
| name: Weekly Coverage Report | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: llvm-tools-preview | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: backend | |
| - uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Generate coverage report | |
| run: cargo llvm-cov --all-features --html --output-dir coverage | |
| working-directory: backend | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: backend/coverage/ | |
| retention-days: 30 | |
| dependency-audit: | |
| name: Dependency Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Rust audit | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit --locked | |
| - name: Audit Rust dependencies | |
| run: cargo audit --json > rust-audit.json || true | |
| working-directory: backend | |
| # NPM audit | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| working-directory: frontend | |
| - name: Audit NPM dependencies | |
| run: npm audit --json > npm-audit.json || true | |
| working-directory: frontend | |
| # Generate summary | |
| - name: Generate audit summary | |
| run: | | |
| echo "## Dependency Audit Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Rust Dependencies" >> $GITHUB_STEP_SUMMARY | |
| if [ -f backend/rust-audit.json ]; then | |
| echo '```json' >> $GITHUB_STEP_SUMMARY | |
| cat backend/rust-audit.json | head -50 >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### NPM Dependencies" >> $GITHUB_STEP_SUMMARY | |
| if [ -f frontend/npm-audit.json ]; then | |
| echo '```json' >> $GITHUB_STEP_SUMMARY | |
| cat frontend/npm-audit.json | head -50 >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| fi | |
| notify: | |
| name: Notify on Failure | |
| runs-on: ubuntu-latest | |
| needs: [nightly-rust, full-test-suite, dependency-audit] | |
| if: failure() | |
| steps: | |
| - name: Create issue on failure | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`; | |
| await github.rest.issues.create({ | |
| owner, | |
| repo, | |
| title: `Nightly build failed - ${new Date().toISOString().split('T')[0]}`, | |
| body: `The nightly build and test workflow has failed.\n\n[View the failed run](${runUrl})`, | |
| labels: ['bug', 'ci', 'automated'] | |
| }); |