-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: make required checks passed if skipped
- Loading branch information
Showing
1 changed file
with
36 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ name: main | |
on: | ||
push: | ||
branches: [main] | ||
paths: ["**/*.js", "**/*.json", "**/*.md", "**/*.sol", "**/*.ts", "**/*.yaml", "**/*.yml"] | ||
pull_request: | ||
paths: ["**/*.js", "**/*.json", "**/*.md", "**/*.sol", "**/*.ts", "**/*.yaml", "**/*.yml"] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
|
@@ -37,18 +39,18 @@ jobs: | |
changed-files: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
any_changed: ${{ steps.changed-files.outputs.any_changed }} | ||
modified_files: ${{ steps.changed-files.outputs.modified_files }} | ||
sol_any_changed: ${{ steps.changed-files.outputs.any_changed }} | ||
sol_modified_files: ${{ steps.changed-files.outputs.modified_files }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: packages/**/*.{sol,json,ts} | ||
files: packages/**/*.sol | ||
|
||
compile: | ||
if: needs.changed-files.outputs.any_changed == 'true' | ||
if: needs.changed-files.outputs.sol_any_changed == 'true' | ||
needs: [changed-files, deps] | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -83,9 +85,10 @@ jobs: | |
key: ${{ needs.deps.outputs.cache-key }} | ||
|
||
- run: yarn format | ||
tests: | ||
if: needs.changed-files.outputs.any_changed == 'true' | ||
needs: [changed-files, set-matrix, deps, compile] | ||
|
||
_tests: | ||
if: needs.changed-files.outputs.sol_any_changed == 'true' | ||
needs: [compile] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
|
@@ -105,22 +108,32 @@ jobs: | |
name: all-artifacts | ||
path: packages/ | ||
|
||
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) | ||
- if: contains(needs.changed-files.outputs.sol_modified_files, matrix.dir) | ||
name: Test | ||
run: | | ||
workspace=$(jq -r '.name' packages/${{ matrix.dir }}/package.json) | ||
yarn workspace "$workspace" run test:coverage | ||
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) && github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
- if: contains(needs.changed-files.outputs.sol_modified_files, matrix.dir) && github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
name: Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel: true | ||
flag-name: run ${{ join(matrix.*, '-') }} | ||
|
||
test: | ||
needs: _tests | ||
# workaround for https://github.com/orgs/community/discussions/13690 | ||
# https://stackoverflow.com/a/77066140/9771158 | ||
if: ${{ !(failure() || cancelled()) }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Tests OK (passed or skipped) | ||
run: true | ||
|
||
set-matrix: | ||
if: needs.changed-files.outputs.any_changed == 'true' | ||
if: needs.changed-files.outputs.sol_any_changed == 'true' | ||
needs: changed-files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
|
@@ -133,8 +146,8 @@ jobs: | |
matrix=$(ls -1 packages | jq -Rsc 'split("\n") | map(select(length > 0))') | ||
echo "matrix=$matrix" >> $GITHUB_OUTPUT | ||
slither: | ||
if: needs.changed-files.outputs.any_changed == 'true' | ||
_slither: | ||
if: needs.changed-files.outputs.sol_any_changed == 'true' | ||
needs: [changed-files, set-matrix, deps] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
|
@@ -159,13 +172,13 @@ jobs: | |
with: | ||
path: node_modules | ||
key: ${{ needs.deps.outputs.cache-key }} | ||
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) | ||
- if: contains(needs.changed-files.outputs.sol_modified_files, matrix.dir) | ||
name: Compile contracts | ||
run: | | ||
workspace=$(jq -r '.name' packages/${{ matrix.dir }}/package.json) | ||
yarn workspace "$workspace" run compile | ||
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) | ||
- if: contains(needs.changed-files.outputs.sol_modified_files, matrix.dir) | ||
name: Run slither | ||
uses: crytic/[email protected] | ||
id: slither | ||
|
@@ -177,7 +190,7 @@ jobs: | |
slither-args: --filter-paths "test" --exclude-dependencies --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/ | ||
target: packages/${{ matrix.dir }} | ||
|
||
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) | ||
- if: contains(needs.changed-files.outputs.sol_modified_files, matrix.dir) | ||
name: Upload SARIF files | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
|
@@ -194,3 +207,11 @@ jobs: | |
const header = '# Slither report' | ||
const body = process.env.REPORT | ||
await script({ github, context, header, body }) | ||
slither: | ||
needs: _slither | ||
if: ${{ !(failure() || cancelled()) }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Slither analysis OK (passed or skipped) | ||
run: true |