mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-21 03:06:17 +00:00
## Description Adds a CI workflow that builds and tests a small Foundry project with `foundry-polkadot`'s `forge`, exercising the standard JSON interface between `resolc` and `foundry-polkadot` end-to-end. ## Resolved Issues Closes #513
137 lines
3.9 KiB
YAML
137 lines
3.9 KiB
YAML
name: Test
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
types: [opened, synchronize]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
# without this it will override our rust flags
|
|
rustflags: ""
|
|
components: rustfmt, clippy
|
|
|
|
- name: Install Solc
|
|
uses: ./.github/actions/get-solc
|
|
|
|
- name: Download LLVM
|
|
uses: ./.github/actions/get-llvm
|
|
with:
|
|
target: x86_64-unknown-linux-gnu
|
|
|
|
- name: Set LLVM Environment Variables
|
|
run: |
|
|
echo "LLVM_SYS_221_PREFIX=$(pwd)/llvm-x86_64-unknown-linux-gnu" >> $GITHUB_ENV
|
|
|
|
- name: Install Geth
|
|
run: |
|
|
sudo add-apt-repository -y ppa:ethereum/ethereum
|
|
sudo apt update
|
|
sudo apt install -y ethereum
|
|
|
|
- name: Machete
|
|
uses: bnjbvr/cargo-machete@v0.7.1
|
|
|
|
- name: Format
|
|
run: make format
|
|
|
|
- name: Clippy
|
|
run: make clippy
|
|
|
|
- name: Test cargo workspace
|
|
run: make test-workspace
|
|
|
|
- name: Test docs
|
|
run: make doc
|
|
|
|
# Used as a gate for subjobs that should run only if `test` succeeds
|
|
# and files relevant for the specific job have changed.
|
|
check-changes:
|
|
runs-on: ubuntu-24.04
|
|
outputs:
|
|
should-run-differential-tests: ${{ steps.filter.outputs.should-run-differential-tests }}
|
|
should-run-hardhat-tests: ${{ steps.filter.outputs.should-run-hardhat-tests }}
|
|
should-run-foundry-tests: ${{ steps.filter.outputs.should-run-foundry-tests }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Diff Files
|
|
run: |
|
|
git diff --name-only \
|
|
${{ github.event.pull_request.base.sha || github.event.before }}...HEAD \
|
|
> changed-files.txt
|
|
|
|
- name: Check If Relevant Files Changed
|
|
id: filter
|
|
run: |
|
|
print_changed_files() {
|
|
local file_count
|
|
file_count=$(wc -l < changed-files.txt | tr -d ' ')
|
|
echo "Changed files ($file_count total):"
|
|
sed 's/^/ /' changed-files.txt
|
|
echo
|
|
}
|
|
|
|
has_changes_other_than() {
|
|
local IFS='|'
|
|
local ignored="$*"
|
|
grep -qvE "$ignored" changed-files.txt && echo true || echo false
|
|
}
|
|
|
|
print_changed_files
|
|
|
|
common_ignored=(
|
|
'\.md$'
|
|
'^book/'
|
|
'^docs/'
|
|
'^js/'
|
|
'^package\.json$'
|
|
'^package-lock\.json$'
|
|
)
|
|
|
|
echo "should-run-differential-tests=$(has_changes_other_than \
|
|
"${common_ignored[@]}" \
|
|
'^tooling-projects/' \
|
|
)" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
echo "should-run-hardhat-tests=$(has_changes_other_than \
|
|
"${common_ignored[@]}" \
|
|
'^tooling-projects/foundry' \
|
|
)" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
echo "should-run-foundry-tests=$(has_changes_other_than \
|
|
"${common_ignored[@]}" \
|
|
'^tooling-projects/hardhat' \
|
|
)" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
run-differential-tests:
|
|
needs: [test, check-changes]
|
|
if: ${{ needs.check-changes.outputs.should-run-differential-tests == 'true' }}
|
|
uses: ./.github/workflows/differential-tests.yml
|
|
|
|
run-hardhat-tests:
|
|
needs: [test, check-changes]
|
|
if: ${{ needs.check-changes.outputs.should-run-hardhat-tests == 'true' }}
|
|
uses: ./.github/workflows/hardhat.yml
|
|
|
|
run-foundry-tests:
|
|
needs: [test, check-changes]
|
|
if: ${{ needs.check-changes.outputs.should-run-foundry-tests == 'true' }}
|
|
uses: ./.github/workflows/foundry.yml
|