Skip to content

Sync the pre-commit checks with what CI is doing #37

Sync the pre-commit checks with what CI is doing

Sync the pre-commit checks with what CI is doing #37

Workflow file for this run

# GitHub workflow to run the pre-commit hook.
name: Pre-commit hook
on:
pull_request:
push:
branches:
- main
# NOTE: The following values seem to be a fix for OOM, in case they are needed again.
#
# RUST_CACHE_VERBOSE: true
# CARGO_BUILD_JOBS: 1
# CARGO_INCREMENTAL: 0
# RUSTFLAGS: >
# -C codegen-units=1
#
# but we have reverted CARGO_INCREMENTAL to 1 to speed up builds.
env:
RUST_CACHE_VERBOSE: true
CARGO_BUILD_JOBS: 1
CARGO_INCREMENTAL: 1 # NOTE: unfortunately this does not propagate to steps below.
RUSTFLAGS: >
-C codegen-units=1
jobs:
run-pre-commit:
name: Run pre-commit hook
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
# Install Rust
#
# See: https://github.com/actions-rust-lang/setup-rust-toolchain
# Note that it can handle the Rust cache automatically (via Swatinem/rust-cache).
- name: Install Rust and setup Rust cache
uses: actions-rust-lang/setup-rust-toolchain@v1.13.0
with:
toolchain: nightly-2025-01-06, stable
override: true
components: rustfmt, clippy
cache-shared-key: v3-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml', '**/build.rs') }}
cache-directories: |
~/.cache/sccache
# Install Rust tools
#
# For more tools, see: https://github.com/taiki-e/install-action/blob/main/TOOLS.md
- name: Install Rust tools
uses: taiki-e/install-action@v2
with:
tool: sccache,cargo-binstall,just,cargo-nextest,typos
# Enable sccache
- name: Enable sccache
run: |
echo "export RUSTC_WRAPPER=$(command -v sccache)" >> $GITHUB_ENV
echo "export SCCACHE_DIR=~/.cache/sccache" >> $GITHUB_ENV
# Install NPM stuff from helpers/npm-install-g.txt
- name: Install NPM stuff from helpers/npm-install-g.txt
run: ./helpers/npm-install-g.sh
# Print stable,nightly versions
- run: cargo +stable --version && cargo +nightly-2025-01-06 --version
# Finally, run the pre-commit hook
- run: |
echo $RUSTC_WRAPPER
echo $SCCACHE_DIR
echo "Running pre-commit hook..."
./.pre-commit/pre-commit
# Show sccache stats
- name: Show sccache stats
run: sccache --show-stats