Refactor CI workflow and add Slither analysis #102
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: CI Workflow | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: "20.x" | |
cache: "yarn" | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Setup Foundry | |
uses: foundry-rs/[email protected] | |
with: | |
version: nightly | |
- name: Lint, Build, and Test | |
run: | | |
yarn lint:sol | |
yarn build | |
yarn test | |
- name: Install lcov for coverage reporting | |
run: sudo apt-get update && sudo apt-get install -y lcov | |
- 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 }} | |
- name: Run Slither Analysis | |
run: slither . --filter-paths "contracts/mock|node_modules" --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/contracts/ | |
- name: Post Slither Analysis as PR Comment | |
uses: actions/[email protected] | |
with: | |
script: | | |
const header = '# Slither report'; | |
const body = process.env.REPORT; | |
const script = require('.github/scripts/comment'); | |
await script({ github, context, header, body }); | |
env: | |
REPORT: ${{ steps.slither_analysis.outputs.stdout }} |