From bf1b67e948d7df21b491c83036c204ce1f0c22f2 Mon Sep 17 00:00:00 2001 From: Dzmitry Lahunouski Date: Thu, 28 Dec 2023 12:35:53 +0000 Subject: [PATCH] split jobs --- .../actions/{setup.yml => setup/action.yml} | 10 ++- .github/workflows/quality-gate.yml | 61 +++++++++++-------- 2 files changed, 41 insertions(+), 30 deletions(-) rename .github/actions/{setup.yml => setup/action.yml} (55%) diff --git a/.github/actions/setup.yml b/.github/actions/setup/action.yml similarity index 55% rename from .github/actions/setup.yml rename to .github/actions/setup/action.yml index bdd0a56..ad92f66 100644 --- a/.github/actions/setup.yml +++ b/.github/actions/setup/action.yml @@ -1,4 +1,5 @@ name: Setup +description: Install foundry and npm dependencies to reuse them in workflows and jobs runs: using: composite @@ -9,13 +10,16 @@ runs: node-version: 18.x - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 + - run: ls -alt + shell: bash - uses: actions/cache@v3 id: cache with: path: | - '**/node_modules' - '**/lib/forge-std' - key: ${{ hashFiles('**/lib/forge-std/package.json') }}-${{ hashFiles('**/package-lock.json') }} + './node_modules' + './lib/forge-std' + key: ${{ runner.os }}-${{ hashFiles('./lib/forge-std/package.json') }}-${{ hashFiles('./package-lock.json') }} - name: Install dependencies + shell: bash run: make install-ci if: steps.cache.outputs.cache-hit != 'true' \ No newline at end of file diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index a8d0ed8..5ccb452 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -2,36 +2,43 @@ name: Quality Gate on: push: -concurrency: ${{ github.workflow }}-${{ github.ref }} +concurrency: + group: quality-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + packages: read jobs: - build_and_validate: + lint: runs-on: ubuntu-latest - permissions: - contents: read - packages: read - security-events: write steps: - uses: actions/checkout@v4 - - name: Set up environment - uses: ./.github/actions/setup - - name: code quality - run: make lint - - name: Run harhat compilation - run: make compile - - name: Run unit tests - run: make test - - name: Run demo deployment - run: make deploy - - name: Run Slither - uses: crytic/slither-action@v0.3.0 - id: slither - with: - target: 'src/' - sarif: results.sarif - fail-on: none - ignore-compile: true - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v2 + - uses: ./.github/actions/setup + - run: make lint + + check-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: make compile + - run: make deploy + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: make test + + slither: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: rm foundry.toml + - uses: crytic/slither-action@v0.3.0 with: - sarif_file: ${{ steps.slither.outputs.sarif }} + node-version: 18.15