99 lines
3.1 KiB
YAML
99 lines
3.1 KiB
YAML
name: CI
|
|
|
|
# The gates this repository relies on: formatting, lints and the 190-odd tests
|
|
# that need neither a browser nor a network. The browser end-to-end suite is a
|
|
# separate, opt-in job: it drives a real Chromium against a local fixture, and a
|
|
# runner without a browser should not make the whole pipeline red.
|
|
|
|
on:
|
|
# A push to the default branch, and every pull request. Add the branch name
|
|
# here if this repository defaults to something else.
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
schedule:
|
|
# Every night at 04:17 UTC, so the browser suite still runs on its own.
|
|
- cron: "17 4 * * *"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
check:
|
|
name: fmt, clippy and tests (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install the Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache the build
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all --check
|
|
|
|
- name: Lint every target
|
|
run: cargo clippy --all-targets --locked -- -D warnings
|
|
|
|
# Unit tests, binary tests, HTTP integration tests against the mock
|
|
# backend, and doc tests. Everything here runs without Chrome.
|
|
- name: Run the test suite
|
|
run: cargo test --locked --all-targets
|
|
|
|
- name: Run the doc tests
|
|
run: cargo test --locked --doc
|
|
|
|
- name: Build the release binary
|
|
run: cargo build --locked --release
|
|
|
|
browser-e2e:
|
|
name: browser end-to-end (Chromium + fixture)
|
|
runs-on: ubuntu-latest
|
|
# On demand, or with the nightly run: these tests need a browser and are the
|
|
# ones most sensitive to the runner image.
|
|
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install the Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache the build
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
# The runner image ships Chrome; the tests find it through CHROME, which
|
|
# is the same override a user can set on a machine with an unusual layout.
|
|
- name: Locate a Chromium-based browser
|
|
run: |
|
|
for path in /usr/bin/google-chrome /usr/bin/google-chrome-stable /usr/bin/chromium /usr/bin/chromium-browser; do
|
|
if [ -x "$path" ]; then
|
|
"$path" --version
|
|
echo "CHROME=$path" >> "$GITHUB_ENV"
|
|
exit 0
|
|
fi
|
|
done
|
|
echo "no Chromium-based browser found on this runner" >&2
|
|
exit 1
|
|
|
|
# The suite is #[ignore]d by default so that "cargo test" stays usable on
|
|
# a machine without a browser.
|
|
- name: Run the browser suite
|
|
run: cargo test --locked --test e2e_browser -- --ignored --test-threads=1 --nocapture
|