diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000..9e562eb71 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,20 @@ +name: Setup + +runs: + using: composite + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.x + cache: npm + - uses: actions/cache@v3 + id: cache + with: + path: '**/node_modules' + key: npm-v3-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + run: npm ci --prefer-offline + shell: bash + if: steps.cache.outputs.cache-hit != 'true' + env: + SKIP_COMPILE: true diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 000000000..b0f8a8916 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,54 @@ +name: checks + +on: + push: + branches: + - master + - release-v* + pull_request: {} + workflow_dispatch: {} + +concurrency: + group: checks-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up environment + uses: ./.github/actions/setup + - run: npm run lint + + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up environment + uses: ./.github/actions/setup + - run: npm run test + env: + FORCE_COLOR: 1 + ENABLE_GAS_REPORT: true + - run: npm run test:inheritance + - run: npm run test:generation + + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up environment + uses: ./.github/actions/setup + - run: npm run coverage + env: + NODE_OPTIONS: --max_old_space_size=4096 + - uses: codecov/codecov-action@v3 + + slither: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up environment + uses: ./.github/actions/setup + - uses: crytic/slither-action@v0.1.1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 264dc71e5..526fe608c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,17 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 12.x - - uses: actions/cache@v3 - id: cache - with: - path: '**/node_modules' - key: npm-v2-${{ hashFiles('**/package-lock.json') }} - restore-keys: npm-v2- - - run: npm ci - if: steps.cache.outputs.cache-hit != 'true' + - name: Set up environment + uses: ./.github/actions/setup - run: bash scripts/git-user-config.sh - run: node scripts/update-docs-branch.js - run: git push --all origin diff --git a/.github/workflows/slither.yml b/.github/workflows/slither.yml deleted file mode 100644 index 6290d506b..000000000 --- a/.github/workflows/slither.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Slither Analysis -on: - push: - branches: - - master - - release-v* - pull_request: {} - workflow_dispatch: {} - -jobs: - analyze: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 12.x - - uses: actions/cache@v3 - id: cache - with: - path: '**/node_modules' - key: npm-v2-${{ hashFiles('**/package-lock.json') }} - restore-keys: npm-v2- - - run: npm ci - if: steps.cache.outputs.cache-hit != 'true' - - name: Clean project - run: npm run clean - - uses: crytic/slither-action@v0.1.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 3a345c050..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Test - -on: - push: - branches: - - master - - release-v* - pull_request: {} - workflow_dispatch: {} - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 12.x - - uses: actions/cache@v3 - id: cache - with: - path: '**/node_modules' - key: npm-v2-${{ hashFiles('**/package-lock.json') }} - restore-keys: npm-v2- - - run: npm ci - if: steps.cache.outputs.cache-hit != 'true' - - run: npm run lint - - run: npm run test - env: - FORCE_COLOR: 1 - ENABLE_GAS_REPORT: true - - run: npm run test:inheritance - - run: npm run test:generation - - name: Print gas report - run: cat gas-report.txt - - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - uses: actions/setup-node@v3 - with: - node-version: 12.x - - uses: actions/cache@v3 - id: cache - with: - path: '**/node_modules' - key: npm-v2-${{ hashFiles('**/package-lock.json') }} - restore-keys: npm-v2- - - run: npm ci - if: steps.cache.outputs.cache-hit != 'true' - - run: npm run coverage - env: - NODE_OPTIONS: --max_old_space_size=4096 - - uses: codecov/codecov-action@v3 diff --git a/package.json b/package.json index cb1ac5571..6074a4288 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lint:sol": "solhint 'contracts/**/*.sol' && prettier -c 'contracts/**/*.sol'", "lint:sol:fix": "prettier --write \"contracts/**/*.sol\"", "clean": "hardhat clean && rimraf build contracts/build", - "prepare": "npm run clean && env COMPILE_MODE=production npm run compile", + "prepare": "scripts/prepare.sh", "prepack": "scripts/prepack.sh", "generate": "scripts/generate/run.js", "release": "scripts/release/release.sh", diff --git a/scripts/prepare.sh b/scripts/prepare.sh new file mode 100755 index 000000000..7014a7076 --- /dev/null +++ b/scripts/prepare.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ "${SKIP_COMPILE:-}" == true ]; then + exit +fi + +npm run clean +env COMPILE_MODE=production npm run compile