Merge pull request #116 from aviator5/optimize-dev #362
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, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| # Cancel previous runs for the same ref to save CI minutes. | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| SCCACHE_CACHE_SIZE: "2G" | |
| CARGO_INCREMENTAL: "0" | |
| jobs: | |
| test: | |
| name: Test Suite (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-latest, windows-latest, macos-latest ] | |
| steps: | |
| - name: Force LF in working tree (w/a for Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| clean: 'true' | |
| - name: Install Rust toolchain from rust-toolchain.toml | |
| run: | | |
| rustup show active-toolchain || rustup toolchain install | |
| rustup show | |
| # Cache Cargo registry/git + target/ across platforms. | |
| - name: Cache Cargo/target | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| with: | |
| shared-key: ${{ matrix.os }} | |
| # Install sccache (cross-platform) | |
| - name: Install sccache | |
| uses: mozilla-actions/sccache-action@ee68efe471c107882388f2e629ccf265e279e9b6 # v0.0.5 | |
| # Use a local disk dir for sccache and cache it with actions/cache (reliable). | |
| - name: Prepare sccache dir | |
| shell: bash | |
| run: | | |
| echo "SCCACHE_DIR=$RUNNER_TEMP/sccache" >> "$GITHUB_ENV" | |
| mkdir -p "$RUNNER_TEMP/sccache" | |
| - name: Cache sccache artifacts | |
| if: runner.os != 'macOS' | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/sccache | |
| key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| sccache-${{ runner.os }}- | |
| # Probe sccache; if startup fails, fall back to plain rustc (no hard CI failure). | |
| - name: Probe sccache & set RUSTC_WRAPPER | |
| shell: bash | |
| run: | | |
| if sccache --start-server >/dev/null 2>&1; then | |
| echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" | |
| echo "SCCACHE_OK=1" >> "$GITHUB_ENV" | |
| else | |
| echo "sccache failed, falling back to plain rustc" | |
| echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" | |
| echo "SCCACHE_OK=0" >> "$GITHUB_ENV" | |
| fi | |
| - name: Show rustc version | |
| run: rustc -Vv | |
| # Formatting check (fast fail for style issues) | |
| - name: cargo fmt (check) | |
| run: cargo fmt --all -- --check | |
| # Clippy lints across workspace and all targets; fail on warnings | |
| - name: cargo clippy | |
| run: cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::perf | |
| # Unit tests | |
| - name: cargo test | |
| run: cargo test --workspace --no-fail-fast | |
| # Smoke test installability of gts-validator as a standalone CLI. | |
| - name: cargo install smoke test (gts-validator) | |
| run: | | |
| cargo install --path gts-validator --force | |
| gts-validator --help | |
| # Print sccache stats when active | |
| - name: sccache stats | |
| if: env.SCCACHE_OK == '1' | |
| run: sccache --show-stats | |
| security: | |
| name: Security (cargo-deny on Ubuntu) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Install Rust toolchain from rust-toolchain.toml | |
| run: | | |
| rustup show active-toolchain || rustup toolchain install | |
| rustup show | |
| - name: Cache Cargo/target | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| # Install tools via prebuilt binaries for speed. | |
| - name: Install cargo-deny | |
| uses: taiki-e/install-action@385db9cc6bf65d19775b02084a4b698eaca9a4f2 # v2 | |
| with: | |
| tool: cargo-deny@0.19.0 | |
| # Run deny checks but do not fail CI (as requested). | |
| - name: cargo deny check | |
| run: cargo deny check | |
| continue-on-error: true | |
| coverage: | |
| name: Code Coverage (cargo-llvm-cov) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Install Rust toolchain from rust-toolchain.toml (with llvm-tools) | |
| run: | | |
| rustup show active-toolchain || rustup toolchain install | |
| rustup component add llvm-tools-preview | |
| rustup show | |
| - name: Cache Cargo/target | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - name: Install sccache | |
| uses: mozilla-actions/sccache-action@ee68efe471c107882388f2e629ccf265e279e9b6 # v0.0.5 | |
| - name: Prepare sccache dir | |
| shell: bash | |
| run: | | |
| echo "SCCACHE_DIR=$RUNNER_TEMP/sccache" >> "$GITHUB_ENV" | |
| mkdir -p "$RUNNER_TEMP/sccache" | |
| - name: Cache sccache artifacts | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/sccache | |
| key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| sccache-${{ runner.os }}- | |
| - name: Probe sccache & set RUSTC_WRAPPER | |
| shell: bash | |
| run: | | |
| if sccache --start-server >/dev/null 2>&1; then | |
| echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" | |
| echo "SCCACHE_OK=1" >> "$GITHUB_ENV" | |
| else | |
| echo "sccache failed, falling back to plain rustc" | |
| echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" | |
| echo "SCCACHE_OK=0" >> "$GITHUB_ENV" | |
| fi | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@385db9cc6bf65d19775b02084a4b698eaca9a4f2 # v2 | |
| with: | |
| tool: cargo-llvm-cov | |
| # Generate lcov.info for upload. | |
| - name: Coverage (lcov) | |
| env: | |
| RUSTFLAGS: "-C debuginfo=0" | |
| CARGO_LLVM_COV_TARGET_DIR: llvm-cov-target | |
| CARGO_LLVM_COV_BUILD_DIR: llvm-cov-build | |
| run: | | |
| cargo llvm-cov clean --workspace | |
| cargo llvm-cov --workspace --lcov --output-path lcov.info | |
| # Upload to Codecov; do not fail CI if Codecov is down/misconfigured. | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@0f8570b1a125f4937846a11fcfa3bcd548bd8c97 # v4.6.0 | |
| with: | |
| files: lcov.info | |
| fail_ci_if_error: false | |
| # token: ${{ secrets.CODECOV_TOKEN }} # Uncomment if required for private repos | |
| gts-spec-tests: | |
| name: GTS Spec Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Install Rust toolchain from rust-toolchain.toml | |
| run: | | |
| rustup show active-toolchain || rustup toolchain install | |
| rustup show | |
| - name: Cache Cargo/target | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| # Builds the release binary, pulls the gts-spec test-runner image from | |
| # GHCR (tag from .gts-spec-version), starts the server natively, waits | |
| # for readiness, then runs pytest inside the container against | |
| # host.docker.internal:$PORT. See Makefile. | |
| - name: Run gts-spec tests via docker | |
| run: make gts-spec-tests | |
| dylint: | |
| name: Dylint + Prefix Tests (nightly, Ubuntu) | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTUP_TOOLCHAIN: nightly-2026-04-16 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install pinned nightly toolchain | |
| uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly | |
| with: | |
| toolchain: ${{ env.RUSTUP_TOOLCHAIN }} | |
| components: llvm-tools-preview,rustc-dev | |
| - name: Cache Cargo/target | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| with: | |
| shared-key: dylint | |
| - name: Install cargo-dylint and dylint-link from source | |
| run: cargo install --locked cargo-dylint dylint-link | |
| - name: Run dylint | |
| run: cargo +${{ env.RUSTUP_TOOLCHAIN }} dylint --all | |
| - name: Run dylint UI tests | |
| run: cargo +${{ env.RUSTUP_TOOLCHAIN }} test --manifest-path gts-dylint/Cargo.toml | |
| - name: Run prefix-aware tests | |
| run: make test-gts-id-prefix |