Skip to content

Commit

Permalink
feat: fast miri for PRs (#469)
Browse files Browse the repository at this point in the history
Only run Miri with 1 seed on PRs, but also run Miri on pushes to `main`
with 8 seeds.

I don't have much experience with GitHub actions but this seems to work.

- I PRed this on my fork and merged it.
- The push to main ran the Miri job with 8 seeds
- The original job from `ci.yml` moved to a new `validation.yml` file
which only runs on pushes to `main`.
- Then I opened another PR, which ran Miri with only 1 seed.
- The job ran for 3m 35s, but most of the build artifacts were already
cached.

The only issue I see with this is the caching part of the job. The yml
sets up these keys:

```yml
          key: ci-miri-${{ matrix.config.target }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ci-miri-${{ matrix.config.target }}-
```

which are now duplicated to 2 different jobs in 2 completely different
workflows. I don't know if that's a problem or not.

---------

Co-authored-by: Zicklag <zicklag@katharostech.com>
  • Loading branch information
nelson137 and zicklag authored Sep 27, 2024
1 parent e2a58ae commit 1ecb3dd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 54 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,37 +124,3 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}

miri_tests:
runs-on: ubuntu-latest
name: 📡 Miri tests
steps:
- uses: actions/checkout@v3
- name: 🧰 Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y -q \
libasound2-dev \
libudev-dev
- name: 🧰 Install Miri
run: |
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: ♻️ Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
web-target/
key: ci-miri-${{ matrix.config.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ci-miri-${{ matrix.config.target }}-
- name: 📡 Test with Miri
shell: bash
run: "${GITHUB_WORKSPACE}/.github/miri-test.sh"
env:
NUM_SEEDS: 8
20 changes: 0 additions & 20 deletions .github/workflows/pul-requests.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: ⏮️ Pull Requests

on:
pull_request_target:
types:
- opened
- edited
- synchronize
merge_group:

jobs:
validate_title:
name: 🕵 Validate Conventional PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
name: 🔎 Validate Conventional PR Title
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

miri_tests:
runs-on: ubuntu-latest
name: 📡 Miri tests ( PR )
steps:
- uses: actions/checkout@v3
- name: 🧰 Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y -q \
libasound2-dev \
libudev-dev
- name: 🧰 Install Miri
run: |
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: ♻️ Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
web-target/
key: ci-miri-${{ matrix.config.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ci-miri-${{ matrix.config.target }}-
- name: 📡 Test with Miri
shell: bash
run: "${GITHUB_WORKSPACE}/.github/miri-test.sh"
env:
NUM_SEEDS: 1
41 changes: 41 additions & 0 deletions .github/workflows/validate-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 📝 Validation

on:
push:
branches:
- main

jobs:
miri_tests:
runs-on: ubuntu-latest
name: 📡 Miri tests
steps:
- uses: actions/checkout@v3
- name: 🧰 Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y -q \
libasound2-dev \
libudev-dev
- name: 🧰 Install Miri
run: |
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: ♻️ Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
web-target/
key: ci-miri-${{ matrix.config.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ci-miri-${{ matrix.config.target }}-
- name: 📡 Test with Miri
shell: bash
run: "${GITHUB_WORKSPACE}/.github/miri-test.sh"
env:
NUM_SEEDS: 8

0 comments on commit 1ecb3dd

Please sign in to comment.