Skip to content

fixed issies on newer Rust 1.97 #24

fixed issies on newer Rust 1.97

fixed issies on newer Rust 1.97 #24

Workflow file for this run

name: ci
on:
push:
pull_request:
# Least privilege by default; the release/publish jobs elevate as needed.
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Format
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# --all-targets compiles every binary (rpt, rpt-render), example
# (record_bytes), and test/bench target, so a broken build in any of them
# fails CI here rather than only when that target is exercised.
- name: Build (all features, all targets)
run: cargo build --all-features --all-targets
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# Some tests depend on local-only fixtures that are absent in CI; they skip
# gracefully so the suite still runs green on a clean checkout.
- name: Test
run: cargo test --all-features
# Render-parity corpus: seed the committed SQL fixtures into a real PostgreSQL (the single DB
# technology for render testing) and diff the rendered HTML against the committed baselines. The
# test skips without RPT_DB_URL, so it only runs where a server is provided — here, and locally via
# `docker compose up -d --wait` (see docker-compose.yml / Makefile).
render-fixtures:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: rpt
POSTGRES_PASSWORD: rpt
POSTGRES_DB: rptfixtures
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U rpt -d rptfixtures"
--health-interval 2s
--health-timeout 3s
--health-retries 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Render fixtures against PostgreSQL
env:
RPT_DB_URL: postgres://rpt:rpt@localhost:5432/rptfixtures
run: cargo test -p rpt-render --test postgres_fixtures
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Verify the crate still builds on its declared minimum supported Rust version.
- uses: dtolnay/rust-toolchain@1.89.0
- name: Build (MSRV)
run: cargo build --all-features
feature-matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build without default features
run: cargo build -p rpt --no-default-features
- name: Build with serde
run: cargo build -p rpt --no-default-features --features serde
baseline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install bubblewrap
run: sudo apt-get update && sudo apt-get install -y bubblewrap
# Ubuntu 24.04 (ubuntu-latest) ships an AppArmor profile that blocks unprivileged user
# namespaces, which Bubblewrap needs to set up its uid map ("setting up uid map:
# Permission denied"). Re-enable them so bwrap can run without privileges.
- name: Allow unprivileged user namespaces
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
# Build the exporter, dump each fixture's XML in a Bubblewrap sandbox (fixed filesystem
# path), and require an exact match against the committed baselines. RPT_REQUIRE_SANDBOX
# makes the test fail rather than skip if the sandbox is unavailable.
- name: XML baseline regression
env:
RPT_REQUIRE_SANDBOX: "1"
run: cargo test -p rpt-cli --test baseline
# Create the GitHub Release once, before the matrix upload jobs. The upload
# action only uploads assets to an existing release; if the per-target jobs
# each tried to create it they would race and fail with "release not found".
# Idempotent so re-running a tag (or re-running failed jobs) is safe.
create-release:
needs: [check, test, msrv, feature-matrix, baseline]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create release if it does not exist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--generate-notes \
--verify-tag
fi
# Release stage: only on a version tag (vX.Y.Z) and only after every CI job
# above has passed, so a failing commit can never be published. Builds the
# cross-platform binaries and uploads them to the release created above.
release:
name: release (${{ matrix.target }})
needs: [create-release]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
# Builds both binaries for the target, archives them (.tar.gz on Unix,
# .zip on Windows) with a sha256 checksum, creates the GitHub Release for
# the tag if it does not exist yet, and uploads the archive as an asset.
- name: Build and upload binaries
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: rpt,rpt-render
target: ${{ matrix.target }}
archive: rpt-rs-$tag-$target
include: README.md,LICENSE
checksum: sha256
token: ${{ secrets.GITHUB_TOKEN }}