Build, test and publish #273
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: Build, test and publish | |
on: | |
push: | |
branches: [main, develop] | |
tags: '*' | |
pull_request: | |
branches: [main, develop] | |
schedule: | |
- cron: "33 3 * * 1" | |
jobs: | |
build_hardhat: | |
name: Build and test (Hardhat) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: NPM install globals | |
run: npm install -g hardhat-shorthand solhint | |
- name: NPM install | |
run: npm install | |
- name: Compile contracts | |
run: npm run build | |
# - name: Run all tests | |
# run: npm run test | |
# - name: Archive build artifacts | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: artifacts | |
# path: | | |
# artifacts | |
# - name: Run linter (prettier check and solhint) | |
# run: npm run lint | |
build_foundry: | |
name: Build and test (Foundry) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
- name: Compile contracts | |
run: forge build | |
- name: Run all tests | |
run: forge test -vv | |
- name: Extract contract sizes report | |
run: forge build --sizes | egrep "|([^|]+)|([^|]*)|([^|]*)|" > contract_sizes.log | |
# - name: Archive size log | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: contract_sizes | |
# path: | | |
# contract_sizes.log | |
# publish: | |
# name: Publish npm package to npmjs | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: read | |
# id-token: write | |
# needs: [build_hardhat, build_foundry] | |
# # only run if not on main and hardhat **and** founddry are successful and not dependabot | |
# if: ${{ github.ref != 'refs/heads/main' && contains(join(needs.*.result, ','), 'success') && github.actor != 'dependabot[bot]' }} | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# - name: Download build artifacts | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: artifacts | |
# path: artifacts | |
# - name: Setup node environment | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 20 | |
# registry-url: 'https://registry.npmjs.org' | |
# # latest npm required for provenance | |
# - run: npm install -g npm | |
# - run: npm ci | |
# - name: Set build version identifier | |
# # version is set to current patch + 1 and a build identifier (revision plus seconds to avoid duplicates) is added | |
# run: npm version "`npm version patch --no-git-tag-version`-`git rev-parse --short HEAD`-`date +%s | tail -c4`" --no-git-tag-version | |
# - run: npm publish --tag next --provenance | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} | |
# deployment_test: | |
# name: Execute test deployment on local chain | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: read | |
# # id-token: write | |
# needs: [build_hardhat, build_foundry] | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# with: | |
# submodules: recursive | |
# - name: Install Foundry | |
# uses: foundry-rs/foundry-toolchain@v1 | |
# - name: Setup node environment | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 20 | |
# registry-url: 'https://registry.npmjs.org' | |
# - name: Install dependencies | |
# run: | | |
# npm install -g hardhat-shorthand | |
# npm install | |
# - name: Run deployment script | |
# env: | |
# SKIP_VERIFICATION: true | |
# run: hh run scripts/deploy_all.ts | |