Skip to content

Shared: Use jemalloc as global allocator in Rust-coded extractors #5

Shared: Use jemalloc as global allocator in Rust-coded extractors

Shared: Use jemalloc as global allocator in Rust-coded extractors #5

Workflow file for this run

name: Rust checks
# Run on every PR; package selection below skips checks for unrelated changes.
on:
pull_request:
push:
branches:
- main
- rc/*
permissions:
contents: read
concurrency:
# Cancel superseded PR checks; each push gets its own group so GitHub cannot
# replace an already-pending push run with a newer one.
group: rust-checks-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
rust-checks:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
# PRs compare the merge commit with its first parent; pushes need full
# history to compare the event's before SHA across multi-commit pushes.
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Select affected packages
id: select
env:
# Use the PR merge base's actual first parent, or the push's before SHA.
BASE: ${{ github.event_name == 'pull_request' && 'HEAD^1' || github.event.before }}
run: |
packages=$(python3 misc/scripts/rust-checks/rust_checks.py select --base "$BASE")
echo "packages=$packages" >> "$GITHUB_OUTPUT"
echo "Selected packages: $packages" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Restore Cargo cache
id: cache
if: steps.select.outputs.packages != '[]'
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: rust-checks-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }}-${{ github.sha }}
restore-keys: |
rust-checks-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }}-
- name: Show stable toolchain and cache
if: steps.select.outputs.packages != '[]'
env:
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
run: |
rustup show active-toolchain
cargo clippy --version
echo "Exact cache hit: ${CACHE_HIT:-false}" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Inject ast-generator sources
if: contains(fromJSON(steps.select.outputs.packages), 'ast-generator')
run: bazel run //rust/ast-generator:inject-sources
- name: Check formatting
if: steps.select.outputs.packages != '[]'
env:
PACKAGES: ${{ steps.select.outputs.packages }}
run: python3 misc/scripts/rust-checks/rust_checks.py format "$PACKAGES"
- name: Run Clippy
if: steps.select.outputs.packages != '[]'
env:
PACKAGES: ${{ steps.select.outputs.packages }}
# For the unified extractor: skip linking the native Swift shim and
# only check Rust code.
SWIFT_SYNTAX_RS_CHECK_ONLY: "1"
run: python3 misc/scripts/rust-checks/rust_checks.py lint "$PACKAGES"
- name: Run tests
if: steps.select.outputs.packages != '[]'
env:
PACKAGES: ${{ steps.select.outputs.packages }}
# Skips the unified extractor crates, whose tests need a Swift toolchain,
# and ast-generator, which has no tests of its own.
run: python3 misc/scripts/rust-checks/rust_checks.py test "$PACKAGES"