From 5839a579d6cf869ca3b0990a41449526172337eb Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 26 Aug 2024 12:51:49 -0700 Subject: [PATCH] Test --- .github/workflows/main.yml | 200 +++++++++++++++++++--------------- .github/workflows/preview.yml | 38 +++++++ 2 files changed, 153 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0dfd2da3a..08fe5b4d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 000000000..34c017a46 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,38 @@ +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 + 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 ..