chore: improve CI workflows #78
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: cd | |
on: [push, pull_request] | |
env: | |
SOLC_VERSION: ${{ secrets.SOLC_VERSION }} | |
SOLIDITY_OPTIMIZER: ${{ secrets.SOLIDITY_OPTIMIZER }} | |
jobs: | |
cd: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node: [20.x] | |
python: [3.9.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Changed sol files check | |
uses: tj-actions/changed-files@v45 | |
id: changed-sol-files | |
with: | |
files: contracts/*.sol | |
- name: Setup Python | |
if: steps.changed-sol-files.outputs.any_changed == 'true' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Analyzer tools | |
if: steps.changed-sol-files.outputs.any_changed == 'true' | |
run: pip3 install --use-deprecated=legacy-resolver slither-analyzer==0.10.4 mythril==0.24.8 & | |
- name: Setup Solc | |
if: steps.changed-sol-files.outputs.any_changed == 'true' | |
uses: pontem-network/get-solc@f67593db4487ac96b4bf8031123a6deefc399b2e | |
with: | |
version: v${{ env.SOLC_VERSION }} | |
- name: Install dependencies with dev deps | |
run: yarn install --production=false --ignore-scripts | |
- name: Analyze contracts with Mythril | |
if: steps.changed-sol-files.outputs.any_changed == 'true' | |
run: myth analyze --solc-json mythril.config.json contracts/*.sol & | |
- name: Analyze contracts with Slither | |
if: steps.changed-sol-files.outputs.any_changed == 'true' | |
run: slither contracts/ & | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Hardhat compile | |
run: yarn run hardhat compile --force | |
- name: Tests | |
run: yarn run hardhat test --no-compile & | |
- name: Format and lint | |
run: yarn tsc --noEmit && yarn prettier '**/{*,''}.{json,js,ts,sol}' --check && yarn eslint '**/{*,''}.{json,js,ts}' && yarn solhint 'contracts/*.sol' & |