Skip to content

Slither: add slither analyzer to github workflow #45

Slither: add slither analyzer to github workflow

Slither: add slither analyzer to github workflow #45

Workflow file for this run

name: Unit Testing
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
run-unit-tests:
name: Unit Testing
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node v20
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: "yarn"
- name: Clean build artifacts
run: rm -rf artifacts cache dist typechain-types coverage
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Compile contracts
run: yarn compile
- name: Unit Tests
run: yarn test:hardhat
- name: Generate coverage
run: yarn test:coverage:solidity
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
directory: coverage/
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Check for Solidity changes
uses: dorny/paths-filter@v3
id: contract_changes
with:
filters: |
contracts:
- '**/*.sol'
# Run Slither if Solidity changes are detected
- name: Run Slither
uses: crytic/[email protected]
id: slither
if: steps.contract_changes.outputs.contracts == 'true'
with:
ignore-compile: true
target: "./"
solc-version: "0.8.20"
fail-on: none
slither-args: --filter-paths "openzeppelin" --exclude-informational --exclude-optimization --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
- name: Create/update checklist as PR comment
uses: actions/github-script@v7
if: github.event_name == 'pull_request' && steps.contract_changes.outputs.contracts == 'true'
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 })