Update GitHub Actions workflow to trigger on pull requests #74
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unified CI Workflow | |
on: | |
push: | |
pull_request: | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
cache-key: ${{ steps.cache-setup.outputs.cache-key }} | |
steps: | |
- uses: actions/[email protected] | |
- name: Set up Node.js | |
uses: actions/actions/[email protected] | |
with: | |
node-version: '20.x' | |
- name: Cache Node modules and Foundry | |
id: cache-setup | |
uses: actions/[email protected] | |
with: | |
path: | | |
**/node_modules | |
~/.foundry | |
key: ${{ runner.os }}-build-${{ hashFiles('**/yarn.lock') }} | |
- name: Install JavaScript Dependencies | |
if: steps.cache-setup.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: Install Foundry and dependencies | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Install lcov (for genhtml) | |
run: sudo apt-get update && sudo apt-get install -y lcov | |
lint: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Lint sources | |
run: yarn lint:sol | |
unit_test: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Create a fake .secret file | |
run: echo "primary twist rack vendor diagram image used route theme frown either will" > .secret | |
- name: Build Typechain and Foundry | |
run: yarn build | |
- name: Run Forge and Hardhat Tests | |
run: yarn test | |
coverage: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Generate Hardhat & Foundry Coverage Report | |
run: yarn coverage:report | |
- name: Upload Foundry Coverage Report to Codecov | |
uses: codecov/[email protected] | |
with: | |
file: ./coverage/foundry/lcov.info | |
flags: foundry | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload Hardhat Coverage Report to Codecov | |
uses: codecov/[email protected] | |
with: | |
file: ./coverage/lcov.info | |
flags: hardhat | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
slither_analysis: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Run Slither | |
uses: crytic/[email protected] | |
with: | |
slither-version: "0.10.0" | |
fail-on: "none" | |
slither-args: '--filter-paths "contracts/mock|node_modules" --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/contracts/' | |
- name: Create/update checklist as PR comment | |
uses: actions/[email protected] | |
env: | |
REPORT: ${{ steps.slither.outputs.stdout }} | |
with: | |
script: | | |
const script = require('.github/scripts/comment') | |
const header = '# Slither report' | |
const body = process.env.REPORT | |
await script({ github, context, header, body }) |