Skip to content

Commit

Permalink
clean up workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed May 3, 2024
1 parent 4c83210 commit 010b0ac
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
detect-changes:
uses: ./.github/workflows/check_diff.yml
with:
pattern: ^bindings/hyperdrivepy/\|^contracts/\|^test/\|^crates/\|^lib/\|^foundry\.toml$\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/rust_test\.yml$
pattern: ^bindings/hyperdrivepy/\|^test/\|^crates/\|^lib/\|^target/\|^foundry\.toml$\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/build_wheels\.yml$

build-wheels-linux:
name: build on linux
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/dynamic_fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Dynamic Fuzz

on:
pull_request:

jobs:
# Check if files in the /test, /crates, or /lib directories or the
# /Cargo.lock, or /Cargo.toml files were changed in this PR.
detect-changes:
uses: ./.github/workflows/check_diff.yml
with:
pattern: ^test/\|^crates/\|^lib/\|^target/\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/dynamic_fuzz\.yml$

test:
name: rust test
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
steps:
- name: Checkout hyperdrive-rs
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}

# NOTE: This is needed to ensure that hyperdrive-wrappers builds correctly.
- name: install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy

- name: Get list of tests from main branch
run: |
git remote update && git fetch && git checkout --track origin/main
sh scripts/list_tests.sh > main_tests.txt
- name: Get list of tests from pull request branch
run: |
git checkout ${{ github.head_ref }}
sh scripts/list_tests.sh > branch_tests.txt
- name: Compare test lists and run new tests
run: |
new_tests=$(diff main_tests.txt branch_tests.txt|awk -F'[>,]' '{gsub(/ /,"")} {print $2} '| sed '/^$/d')
if [ -n "$new_tests" ]; then
echo "New tests found:"
echo "$new_tests"
while IFS= read -r test; do
echo "Running test: $test"
env HYPERDRIVE_FUZZ_RUNS=500 HYPERDRIVE_FAST_FUZZ_RUNS=50000 cargo test $test --
done <<< "$new_tests"
else
echo "No new tests found."
fi
4 changes: 2 additions & 2 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
detect-changes:
uses: ./.github/workflows/check_diff.yml
with:
pattern: ^bindings/hyperdrivepy/\|^contracts/\|^test/\|^crates/\|^lib/\|^foundry\.toml$\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/rust_test\.yml$
pattern: ^bindings/\|^test/\|^crates/\|^lib/\|^target/\|^foundry\.toml$\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/python_test\.yml$

test:
needs: detect-changes
Expand Down Expand Up @@ -53,4 +53,4 @@ jobs:
run: python -m pip install bindings/hyperdrivepy

- name: run pytest
run: python -m pytest .
run: python -m pytest .
6 changes: 3 additions & 3 deletions .github/workflows/rust_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
merge_group:

jobs:
# Check if files in the /contracts, /test, /crates, or /lib directories or the
# /foundry.toml, /Cargo.lock, or /Cargo.toml files were changed in this PR.
# Check if files in the /test, /crates, or /lib directories or the
# /Cargo.lock, or /Cargo.toml files were changed in this PR.
detect-changes:
uses: ./.github/workflows/check_diff.yml
with:
pattern: ^crates/\|^Cargo\.lock$\|^Cargo\.toml$\|^rustfmt\.toml$\|^\.github/workflows/rust_lint\.yml$
pattern: ^test/\|^crates/\|^lib/\|^target/\|^Cargo\.lock$\|^Cargo\.toml$\|^rustfmt\.toml$\|^\.github/workflows/rust_lint\.yml$

lint:
name: rust lint
Expand Down
30 changes: 3 additions & 27 deletions .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
merge_group:

jobs:
# Check if files in the /contracts, /test, /crates, or /lib directories or the
# /foundry.toml, /Cargo.lock, or /Cargo.toml files were changed in this PR.
# Check if files in the /test, /crates, or /lib directories or the
# /Cargo.lock, or /Cargo.toml files were changed in this PR.
detect-changes:
uses: ./.github/workflows/check_diff.yml
with:
pattern: ^contracts/\|^test/\|^crates/\|^lib/\|^foundry\.toml$\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/rust_test\.yml$
pattern: ^test/\|^crates/\|^lib/\|^target/\|^Cargo\.lock$\|^Cargo\.toml$\|^\.github/workflows/rust_test\.yml$

test:
name: rust test
Expand All @@ -39,29 +39,5 @@ jobs:
override: true
components: rustfmt, clippy

- name: Get list of tests from main branch
run: |
git remote update && git fetch && git checkout --track origin/main
sh scripts/list_tests.sh > main_tests.txt
- name: Get list of tests from pull request branch
run: |
git checkout ${{ github.head_ref }}
sh scripts/list_tests.sh > branch_tests.txt
- name: Compare test lists and run new tests
run: |
new_tests=$(diff main_tests.txt branch_tests.txt|awk -F'[>,]' '{gsub(/ /,"")} {print $2} '| sed '/^$/d')
if [ -n "$new_tests" ]; then
echo "New tests found:"
echo "$new_tests"
while IFS= read -r test; do
echo "Running test: $test"
env HYPERDRIVE_FUZZ_RUNS=500 HYPERDRIVE_FAST_FUZZ_RUNS=50000 cargo test $test --
done <<< "$new_tests"
else
echo "No new tests found."
fi
- name: test
run: make test

0 comments on commit 010b0ac

Please sign in to comment.