Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Aug 26, 2024
1 parent f0f6155 commit d1dfda9
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 85 deletions.
200 changes: 115 additions & 85 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,105 @@
name: CI
on:
pull_request:
push:
merge_group:

env:
MDBOOK_VERSION: 0.4.40

jobs:
code-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
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: Run tests
run: mdbook test
# code-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
# 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: 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 --locked -- ../src
# - name: Style fmt
# working-directory: style-check
# run: cargo fmt --check
# - name: Check for broken links
# run: |
# 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

style-tests:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand All @@ -40,78 +108,40 @@ jobs:
- 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: |
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
- name: Build the book
env:
SPEC_DENY_WARNINGS: 1
SPEC_RELATIVE: 0
run: mdbook build
- name: Style checks
working-directory: style-check
run: cargo run --locked -- ../src
- name: Style fmt
working-directory: style-check
run: cargo fmt --check
- name: Check for broken links
run: |
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
- name: Upload artifact
# if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
# name: preview-${{ github.event.pull_request.number }}
name: preview-1234
overwrite: true
path: book/**

# 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
# 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
40 changes: 40 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish Preview
on:
workflow_dispatch:
inputs:
pr_num:
description: "PR number"
type: number
required: true

permissions:
contents: read

jobs:
publish:
name: Publish preview to GitHub Pages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# - name: Download preview
# uses: actions/download-artifact@v4
# with:
# name: preview-1234
#github-token: ...
#run-id: ...
- name: Update GitHub Pages
run: |
git config user.name "Deploy from CI"
git config user.email ""
git worktree add --orphan -B gh-pages gh-pages
rm -rf gh-pages/pr-1234
mkdir gh-pages/pr-1234
cd gh-pages/pr-1234
gh workflow run download -n preview-1234
# unzip -n pr-1234.zip -d gh-pages/pr-1234
# cd gh-pages
git add -A
git commit -m 'Preview pr-1234'
git push origin +gh-pages
cd ../..

0 comments on commit d1dfda9

Please sign in to comment.