Skip to content

Commit

Permalink
Run book and tests workflows only on relevant PRs (#241)
Browse files Browse the repository at this point in the history
The mutants tests are getting time consuming and there's no need to run
them on every change to the book
  • Loading branch information
sourcefrog authored Jan 11, 2024
2 parents 35ac598 + 4052bbc commit 703295d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
42 changes: 35 additions & 7 deletions .github/workflows/deploy-book.yml → .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
name: Deploy book
name: Book
on:
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
branches:
- main
paths:
- .github/workflows/book.yml
- book/**

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
- uses: Swatinem/rust-cache@v2
- name: Install mdbook and mdbook-linkcheck
uses: taiki-e/install-action@v2
with:
tool: mdbook, mdbook-linkcheck
- name: Build mdbook
run: |
mdbook build book
- name: Archive book output
uses: actions/upload-artifact@v3
if: always()
with:
name: book
path: book/book

deploy:
if: github.repository == 'sourcefrog/cargo-mutants'
if:
github.repository == 'sourcefrog/cargo-mutants' && github.ref_name ==
'main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency: # Allow one concurrent deployment
group: "pages"
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
30 changes: 8 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ on:
branches:
- main
pull_request:
paths:
- ".cargo/**"
- ".github/workflows/tests.yml"
- "Cargo.*"
- "mutants_attrs/**"
- "src/**"
- "testdata/**"
- "tests/**"

# see https://matklad.github.io/2021/09/04/fast-rust-builds.html
env:
Expand Down Expand Up @@ -145,25 +153,3 @@ jobs:
with:
name: mutants.out
path: mutants.out

book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
- uses: Swatinem/rust-cache@v2
- name: Install mdbook and mdbook-linkcheck
uses: taiki-e/install-action@v2
with:
tool: mdbook, mdbook-linkcheck
- name: Build mdbook
run: |
mdbook build book
- name: Archive book output
uses: actions/upload-artifact@v3
if: always()
with:
name: book
path: book/book

0 comments on commit 703295d

Please sign in to comment.