feat(ci): run slither in main workflow #51
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: main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
get-changed-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: packages/**/*.{sol,json,ts} | ||
compile: | ||
if: ${{ needs.get-changed-files.outputs.any_changed == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: yarn | ||
- run: yarn | ||
- run: yarn compile | ||
- name: Upload compilation results | ||
uses: actions/upload-artifacts@v4 | ||
with: | ||
name: all-artifacts | ||
path: packages/**/artifacts/** | ||
style: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: yarn | ||
- run: yarn | ||
- run: yarn format | ||
tests: | ||
if: ${{ needs.get-changed-files.outputs.any_changed == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: yarn | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: all-artifacts | ||
path: packages/ | ||
- run: yarn compile | ||
- run: yarn | ||
- run: yarn test | ||
- if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
name: Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
set-slither-matrix: | ||
if: ${{ needs.get-changed-files.outputs.any_changed == 'true' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set matrix | ||
id: set-matrix | ||
run: | | ||
matrix=$(ls -1 packages | jq -Rsc 'split("\n") | map(select(length > 0))') | ||
echo "matrix=$matrix" >> $GITHUB_OUTPUT | ||
slither: | ||
if: ${{ needs.get-changed-files.outputs.any_changed = 'true' }} | ||
Check failure on line 90 in .github/workflows/main.yml
|
||
needs: set-slither-matrix | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
security-events: write | ||
strategy: | ||
matrix: | ||
dir: ${{ fromJson(needs.set-slither-matrix.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: yarn | ||
- name: Run slither | ||
uses: crytic/[email protected] | ||
id: slither | ||
with: | ||
ignore-compile: true | ||
fail-on: none | ||
sarif: results.sarif | ||
slither-args: --filter-paths "test" --exclude-dependencies --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/ | ||
target: packages/${{ matrix.dir }} | ||
- name: Upload SARIF files | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: ${{ steps.slither.outputs.sarif }} | ||
- name: Create/update checklist as PR comment | ||
uses: actions/github-script@v7 | ||
if: github.even_name == 'pull_request' | ||
env: | ||
REPORT: ${{ steps.slither.stdout }} | ||
with: | ||
script: | | ||
const script = require('.github/scripts/slither-comment') | ||
const header = '# Slither report' | ||
const body = process.env.REPORT | ||
await script({ github, context, header, body }) |