Skip to content

Tests

Tests #1642

Workflow file for this run

name: Tests
# This workflow deliberately never triggers on tags: the push trigger below
# is restricted to the "main" branch. Pushing a git tag is handled by
# release.yml instead; see docs/RELEASING.md and docs/SUPPLY_CHAIN_SECURITY.md
# for how releases work. One consequence is that github.ref, used below for
# the concurrency group, is always a branch ref here (e.g. refs/heads/main)
# rather than a tag ref.
on:
merge_group:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions: {}
# Cancel a still-running run for the same PR (or branch) once a newer one
# starts, e.g. after a force-push or an "Update branch" merge commit, so
# superseded runs don't sit queued behind/compete with the current one.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Execute unit and integration tests
runs-on: ubuntu-latest
timeout-minutes: 20
permissions: {}
# sccache still earns its keep alongside the target/ cache below: an A/B
# measurement (same source change, same unchanged Cargo.lock, sccache
# toggled) showed it saves ~180s on a typical PR, since Cargo still
# re-invokes rustc for much of the dependency graph even when the
# restored target/ cache matches Cargo.lock exactly. See
# https://github.com/alltheplaces/osm-diffs/issues/597 for the numbers.
env:
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
steps:
- name: Set up shared compilation cache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install protobuf compiler and tippecanoe
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
with:
packages: protobuf-compiler tippecanoe
# Bump this if the package list above changes, to bust the cache.
version: 1.0
- name: Print installed tool versions
run: |
protoc --version
tippecanoe --version
- name: Install Rust coverage tool
uses: taiki-e/install-action@7f4eb899022d8fe70b20c4f3de697aa85c309026 # v2.85.11
with:
tool: cargo-llvm-cov
- name: Cache Cargo registry and build artifacts
# This cache only ever feeds this test workflow. release.yml builds
# release binaries from scratch on purpose, without touching this
# (or any other) build cache.
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
# GitHub Actions caches are scoped per ref, so PR and merge-queue
# runs would otherwise each save their own full (~1 GB) copy of
# this cache on top of main's. Only save from main; other refs
# still restore main's cache via the usual base-branch fallback,
# they just don't pay to re-save a duplicate.
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Fetch Rust dependencies
run: cargo fetch --locked
- name: Check formatting
run: cargo fmt --check
- name: Build
run: cargo build --locked
- name: Run tests
run: |
# Line coverage was ~91% as of 2026-08; 88% leaves some headroom
# for noise while still catching real regressions. Ratchet this
# up over time as coverage improves.
cargo llvm-cov test --cobertura --locked --verbose \
--output-path cobertura.xml --fail-under-lines 88
- name: Look for common mistakes
run: cargo clippy --locked --all-targets -- -D warnings
- name: Upload test coverage to Coveralls
with:
fail-on-error: false # not critical when coveralls.io is down
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8