From d0a0f662341af40ca19e12ec9854704adf234207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Dobos-Kov=C3=A1cs?= <3751182+as3810t@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:36:29 +0000 Subject: [PATCH 1/4] Move slither --- .github/workflows/PR.yml | 22 ----- .github/workflows/ci.yml | 176 ++++++++++++++++++++++----------------- 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 98e5417..8a6eebf 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -96,25 +96,3 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} working-directory: . update-comment: true - slither: - name: Slither - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup reviewdog - uses: reviewdog/action-setup@v1 - with: - reviewdog_version: latest - - name: Run Slither - uses: crytic/slither-action@v0.4.0 - id: slither - with: - node-version: 20 - sarif: 'results.sarif' - fail-on: none - slither-args: --filter-paths node_modules/ - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.slither.outputs.sarif }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8a2c09..2a13155 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,79 +1,103 @@ name: CI -on: - push: - workflow_dispatch: +on: + push: + workflow_dispatch: jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Build contracts - id: build - run: npm run compile - - name: "Add build summary" - if: ${{ success() || failure() }} - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - - name: "Add build result (success)" - if: ${{ success() && steps.build.outcome == 'success' }} - run: | - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - name: "Add build result (failed)" - if: ${{ failure() && steps.build.outcome == 'failure' }} - run: | - echo "❌ Failed" >> $GITHUB_STEP_SUMMARY - test: - name: Test - runs-on: ubuntu-latest - needs: [build] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Test contracts - id: run_tests - run: | - (npm run --silent test >> /tmp/TEST_OUTPUT) || FAILED=1 - { - echo "test_output<> "$GITHUB_OUTPUT" - cat /tmp/TEST_OUTPUT - if [ ${FAILED:-0} -eq 1 ] - then - exit 1 - fi - - name: "Add test summary" - if: ${{ success() || failure() }} - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "${{steps.run_tests.outputs.test_output}}" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - name: "Add test result (success)" - if: ${{ success() && steps.run_tests.outcome == 'success' }} - run: | - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - name: "Add test result (failed)" - if: ${{ failure() && steps.run_tests.outcome == 'failure' }} - run: | - echo "❌ Failed" >> $GITHUB_STEP_SUMMARY + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Build contracts + id: build + run: npm run compile + - name: 'Add build summary' + if: ${{ success() || failure() }} + run: | + echo "## Build result" >> $GITHUB_STEP_SUMMARY + - name: 'Add build result (success)' + if: ${{ success() && steps.build.outcome == 'success' }} + run: | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + - name: 'Add build result (failed)' + if: ${{ failure() && steps.build.outcome == 'failure' }} + run: | + echo "❌ Failed" >> $GITHUB_STEP_SUMMARY + test: + name: Test + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Test contracts + id: run_tests + run: | + (npm run --silent test >> /tmp/TEST_OUTPUT) || FAILED=1 + { + echo "test_output<> "$GITHUB_OUTPUT" + cat /tmp/TEST_OUTPUT + if [ ${FAILED:-0} -eq 1 ] + then + exit 1 + fi + - name: 'Add test summary' + if: ${{ success() || failure() }} + run: | + echo "## Tests result" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "${{steps.run_tests.outputs.test_output}}" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + - name: 'Add test result (success)' + if: ${{ success() && steps.run_tests.outcome == 'success' }} + run: | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + - name: 'Add test result (failed)' + if: ${{ failure() && steps.run_tests.outcome == 'failure' }} + run: | + echo "❌ Failed" >> $GITHUB_STEP_SUMMARY + + slither: + name: Slither + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup reviewdog + uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest + - name: Run Slither + uses: crytic/slither-action@v0.4.0 + id: slither + with: + node-version: 20 + sarif: 'results.sarif' + fail-on: none + slither-args: --filter-paths node_modules/ + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.slither.outputs.sarif }} From 2259554807a91236d4d647be1bdb7cf6ca990bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Dobos-Kov=C3=A1cs?= <3751182+as3810t@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:41:32 +0000 Subject: [PATCH 2/4] Update CI --- .github/workflows/ci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a13155..8b95f02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,20 +84,20 @@ jobs: needs: [build] steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Setup reviewdog - uses: reviewdog/action-setup@v1 - with: - reviewdog_version: latest + uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest - name: Run Slither - uses: crytic/slither-action@v0.4.0 - id: slither - with: - node-version: 20 - sarif: 'results.sarif' - fail-on: none - slither-args: --filter-paths node_modules/ + uses: crytic/slither-action@v0.4.0 + id: slither + with: + node-version: 20 + sarif: 'results.sarif' + fail-on: none + slither-args: --filter-paths node_modules/ - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.slither.outputs.sarif }} + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.slither.outputs.sarif }} From e30a9985c906d143149a336cdf326cf07eb2069b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Dobos-Kov=C3=A1cs?= <3751182+as3810t@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:56:31 +0000 Subject: [PATCH 3/4] Add checks --- .github/workflows/PR.yml | 6 ++-- .github/workflows/ci.yml | 63 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 8a6eebf..4e0d9ae 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -23,7 +23,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check - filter_mode: nofilter + filter_mode: added prettier: name: Prettier runs-on: ubuntu-latest @@ -41,7 +41,7 @@ jobs: with: github_token: ${{ secrets.github_token }} reporter: github-pr-check - filter_mode: nofilter + filter_mode: added prettier_flags: '**/*.{js,sol,ts,json,jsx,tsx}' solhint: name: Solhint @@ -64,7 +64,7 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-pr-check -level=error -fail-level=none -filter-mode=nofilter -name=solhint + npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-pr-check -level=error -fail-level=none -filter-mode=added -name=solhint coverage: name: Coverage runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b95f02..68785eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,68 @@ jobs: if: ${{ failure() && steps.run_tests.outcome == 'failure' }} run: | echo "❌ Failed" >> $GITHUB_STEP_SUMMARY - + eslint: + name: ESLint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run ESLint + uses: reviewdog/action-eslint@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-check + filter_mode: nofilter + level: info + prettier: + name: Prettier + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - uses: EPMatt/reviewdog-action-prettier@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + filter_mode: nofilter + prettier_flags: '**/*.{js,sol,ts,json,jsx,tsx}' + level: info + solhint: + name: Solhint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Setup reviewdog + uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest + - name: Run solhint + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-check -level=info -fail-level=none -filter-mode=nofilter -name=solhint slither: name: Slither runs-on: ubuntu-latest From 9f1da31faee0dcb312560003f97a29a7cfca0c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Dobos-Kov=C3=A1cs?= <3751182+as3810t@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:03:47 +0000 Subject: [PATCH 4/4] Modify CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68785eb..fc69e4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,6 +80,7 @@ jobs: eslint: name: ESLint runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v4 @@ -100,6 +101,7 @@ jobs: prettier: name: Prettier runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v4 @@ -120,6 +122,7 @@ jobs: solhint: name: Solhint runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v4 @@ -142,6 +145,7 @@ jobs: slither: name: Slither runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' needs: [build] steps: - name: Checkout repository