mdBook/.github/workflows/main.yml

90 lines
2.6 KiB
YAML
Raw Normal View History

2019-10-21 05:44:28 +08:00
name: CI
on:
pull_request:
2023-07-17 04:21:45 +08:00
merge_group:
2019-10-21 05:44:28 +08:00
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, beta, nightly, macos, windows, msrv]
include:
- build: stable
os: ubuntu-latest
rust: stable
- build: beta
os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable
- build: msrv
2022-12-15 21:52:15 +08:00
os: ubuntu-20.04
# sync MSRV with docs: guide/src/guide/installation.md and Cargo.toml
2023-07-17 04:21:45 +08:00
rust: 1.66.0
2019-10-21 05:44:28 +08:00
steps:
- uses: actions/checkout@v3
2019-10-21 05:44:28 +08:00
- name: Install Rust
run: bash ci/install-rust.sh ${{ matrix.rust }}
- name: Build and run tests
2023-02-13 23:43:10 +08:00
run: cargo test --locked
2019-10-21 05:44:28 +08:00
- name: Test no default
run: cargo test --no-default-features
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
2019-10-21 05:44:28 +08:00
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
2022-01-14 08:01:42 +08:00
- run: cargo fmt --check
# These success/failure jobs are here to consolidate the total
# success/failure state of all other jobs. These jobs are then included in
# the GitHub branch protection rule which prevents merges unless all other
# jobs are passing. This makes it easier to manage the list of jobs via this
# yml file and to prevent accidentally adding new jobs without also updating
# the branch protections.
#
# Unfortunately this requires two jobs because the branch protection
# considers skipped jobs as successful. The status check functions like
# success() can only be in an `if` condition.
#
# Beware that success() is false if any dependent job is skipped. See
# https://github.com/orgs/community/discussions/45058. This means there
# cannot be optional jobs. One workaround is to check for all other
# statuses:
# (contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'failure'))
# but that is a mess.
success:
name: Success gate
runs-on: ubuntu-latest
needs:
- test
- rustfmt
if: "success()"
steps:
- name: mark the job as a success
run: echo success
failure:
name: Failure gate
runs-on: ubuntu-latest
needs:
- test
- rustfmt
if: "!success()"
steps:
- name: mark the job as a failure
run: |
echo One or more jobs failed
exit 1