Skip to content

Automatically check semVer compatibility in CI #852

Automatically check semVer compatibility in CI

Automatically check semVer compatibility in CI #852

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
merge_group:
types: [checks_requested]
jobs:
build-and-test:
name: CI
runs-on: ubuntu-latest
strategy:
matrix:
version: [stable, beta]
steps:
- uses: actions/checkout@v4
- name: Set toolchain
run: |
rustup set profile minimal
rustup override set ${{ matrix.version }}
- name: Init submodules
run: git submodule update --init
- name: Cargo build
run: cargo build --all
- name: Cargo test
run: cargo test --all
- name: Test tendril w/encoding feature
run: cargo test -p tendril --features encoding_rs
doc:
name: Cargo doc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set toolchain
run: |
rustup set profile minimal
rustup override set nightly
- run: cargo doc
env:
RUSTFLAGS: --cfg bench
bench-html5ever:
name: Bench html5ever
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo bench -p html5ever
env:
RUSTFLAGS: --cfg bench
bench-tendril:
name: Bench tendril
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo bench -p tendril --bench tendril -- --quick --significance-level 0.01
env:
RUSTFLAGS: --cfg bench
- run: cargo bench -p tendril --bench futf -- --quick --significance-level 0.01
env:
RUSTFLAGS: --cfg bench
msrv:
name: MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
run: |
rustup set profile minimal
rustup override set 1.71.0
- run: cargo check --lib --all-features
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
run: |
rustup set profile minimal
rustup override set stable
- name: Install clippy
run: |
rustup component add clippy
rustup component add rustfmt
- name: Format
run: cargo fmt --all -- --check
- name: Run clippy
uses: servo/actions/cargo-annotation@main
with:
cargo-command: clippy --all-features --all-targets
build_result:
name: Result
runs-on: ubuntu-latest
needs:
- build-and-test
- doc
- lint
- msrv
- bench-html5ever
- bench-tendril
steps:
- name: Success
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Failure
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
semver_check:
name: SemVer compatiblity check
runs-on: ubuntu-latest
permissions:
pull-requests: write # To add labels to PR
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch main branch for reference
run: |
git fetch origin main:main
- name: Install cargo-semver-checks
run: |
cargo install cargo-semver-checks --locked
- name: Run cargo-semver-checks
id: semver
run: |
(cargo semver-checks --baseline-rev main && echo "label=non-breaking" >> $GITHUB_OUTPUT) || echo "label=breaking" >> $GITHUB_OUTPUT
- name: Assign labels
run: gh pr edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
LABELS: ${{ steps.semver.outputs.label }}