Skip to content

Commit

Permalink
Update CI for mdbook-spec.
Browse files Browse the repository at this point in the history
This makes a few changes to CI to handle mdbook-spec:

- Adds a new job for mdbook-spec itself.
- Removes caching, can set this up later.
- Moves `mdbook test` to a separate job. It can be useful to see in the
  CI results to see which jobs are passing or failing.
- Verifies the book builds with mdbook-spec.
- Fix a small oversight that `style-checks` should use `--locked`.
- Add a summary job to make it easier to work with merge queue and
  branch protections.
  • Loading branch information
ehuss committed Jul 23, 2024
1 parent 49fe875 commit 7b033b4
Showing 1 changed file with 77 additions and 16 deletions.
93 changes: 77 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,18 @@ on:

env:
MDBOOK_VERSION: 0.4.40
# When updating, be sure to also update rust-lang/rust.
MDBOOK_SPEC_VERSION: 0.1.0

jobs:
test:
name: Test
code-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ms-${MDBOOK_SPEC_VERSION}
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install nightly -c rust-docs,rustfmt
rustup toolchain install nightly
rustup default nightly
- name: Install mdbook
run: |
Expand All @@ -39,13 +28,37 @@ jobs:
rustup --version
rustc -Vv
mdbook --version
- name: Install mdbook-spec
run: cargo install --locked mdbook-spec@${MDBOOK_SPEC_VERSION}
- name: Run tests
run: mdbook test

style-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install nightly -c rust-docs,rustfmt
rustup default nightly
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Report versions
run: |
rustup --version
rustc -Vv
mdbook --version
- name: Verify the book builds
env:
SPEC_DENY_WARNINGS: 1
run: mdbook build
- name: Style checks
working-directory: style-check
run: cargo run -- ../src
run: cargo run --locked -- ../src
- name: Style fmt
working-directory: style-check
run: cargo fmt --check
Expand All @@ -54,3 +67,51 @@ jobs:
curl -sSLo linkcheck.sh \
https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
sh linkcheck.sh --all reference
mdbook-spec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install nightly -c rustfmt
rustup default nightly
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Report versions
run: |
rustup --version
rustc -Vv
- name: Verify mdbook-spec lockfile is current
working-directory: ./mdbook-spec
run: cargo update -p mdbook-spec --locked
- name: Test mdbook-spec
working-directory: ./mdbook-spec
run: cargo test
- name: Rustfmt check
working-directory: ./mdbook-spec
run: cargo fmt --check

# The success job is here to consolidate the total success/failure state of
# all other jobs. This job is 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.
success:
name: Success gate
if: always()
needs:
- code-tests
- style-tests
- mdbook-spec
runs-on: ubuntu-latest
steps:
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
- name: Done
run: exit 0

0 comments on commit 7b033b4

Please sign in to comment.