feat: improve ci #7
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| merge_group: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # Cancel in-progress runs for the same PR/branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup: | |
| name: Setup Environment | |
| uses: ./.github/workflows/reusable-setup.yml | |
| # You can pass secrets if the reusable workflow needs them | |
| # secrets: inherit | |
| # ============================================================================ | |
| # Unified CI Check (uses Makefile) | |
| # ============================================================================ | |
| ci: | |
| name: CI | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| toolchains: stable, nightly | |
| - name: Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Install development tools | |
| run: make ci-tools | |
| - name: Run CI checks | |
| run: make ci | |
| env: | |
| RUSTFLAGS: "-D warnings" | |
| # ============================================================================ | |
| # Coverage (uses Makefile) | |
| # ============================================================================ | |
| coverage: | |
| name: Coverage | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.title, '[coverage]') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: llvm-tools-preview | |
| - name: Cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install development tools | |
| run: make tools | |
| - name: Generate coverage report | |
| run: make cov-report-html | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: lcov.info | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload HTML coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: target/llvm-cov/html/ | |
| retention-days: 30 |