name: Rust on: # No `push` trigger: this needs the turbo cache the build job writes, and a # standalone run races it. `deploy-main.yml` calls it after `build-all`. workflow_call: secrets: CODECOV_TOKEN: required: true # Set minimum permissions to prevent unnecessary access permissions: {} env: CI: 1 TURBO_TELEMETRY_DISABLED: 1 concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: test: name: Test (${{ matrix.runs-on.name }}) runs-on: ${{ matrix.runs-on.label }} strategy: matrix: runs-on: - label: lynx-ubuntu-26.04-xlarge name: Ubuntu # - label: lynx-windows-2022-large # name: Windows timeout-minutes: 30 permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false - uses: ./.github/actions/rustup with: key: test save-if: ${{ github.ref_name == 'main' }} - name: Install llvm-cov and nextest uses: taiki-e/install-action@5b4d68e2e660441203ab128a23676f1e4faf1532 # v2.86.3 with: tool: cargo-llvm-cov,cargo-nextest - name: Install runtime dependencies run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libepoxy0 - name: TurboCache uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732 with: path: .turbo # We have to be strict here to make sure getting the cache of build-all key: turbo-v4-${{ runner.os }}-${{ hashFiles('packages/**/src/**/*.rs') }}-${{ github.sha }} fail-on-cache-miss: true - name: Install uses: ./.github/actions/pnpm-install with: node-version: "22" save-if: ${{ github.ref_name == 'main' }} - name: Build run: pnpm turbo build --summarize - name: Build React fixture run: | NODE_ENV=production node packages/rspeedy/core/bin/rspeedy.js build --root packages/genui/ui-judge/tests/fixtures/react - name: Test env: CARGO_LLVM_COV_FLAGS_NO_RUNNER: --no-sparse run: | cargo llvm-cov nextest --all-targets --all-features --profile ci --config-file .cargo/nextest.toml --lcov --output-path lcov.info --release - name: Upload coverage reports to Codecov uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 with: token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1 with: token: ${{ secrets.CODECOV_TOKEN }} files: target/nextest/ci/test-report.junit.xml rustfmt: runs-on: lynx-ubuntu-26.04-medium timeout-minutes: 10 permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false # `cargo fmt --check` itself takes a second; installing the toolchain took # over eight minutes on a bad day and pushed this past `timeout-minutes`, # which GitHub then reports as `cancelled` and `Done` reads as a failure. # The local action restores a cached toolchain and installs the minimal # component set. - name: Setup Rust uses: ./.github/actions/rustup with: key: lint save-if: ${{ github.ref_name == 'main' }} - name: Format run: cargo fmt --check clippy: runs-on: lynx-ubuntu-26.04-medium timeout-minutes: 30 permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false - name: Setup Rust uses: ./.github/actions/rustup with: key: lint save-if: ${{ github.ref_name == 'main' }} - name: Clippy run: cargo clippy --tests --all-features -- -D warnings lockfile: runs-on: lynx-ubuntu-26.04-medium timeout-minutes: 10 permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false - name: Setup Rust uses: ./.github/actions/rustup with: key: lint save-if: ${{ github.ref_name == 'main' }} # A `Cargo.toml` edit that is not reflected in `Cargo.lock` does not fail # any build: the first cargo invocation silently rewrites the lock file. # That leaves a dirty tree behind, which breaks anything downstream that # expects a clean checkout after a build — `pnpm publish` aborts with # `ERR_PNPM_GIT_UNCLEAN`. `cargo metadata --locked` resolves the graph # without compiling and without writing, so it fails fast instead. - name: Check Cargo.lock is up to date run: cargo metadata --locked --format-version 1 > /dev/null