Skip to content

Commit

Permalink
made foundry reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Oct 5, 2023
1 parent 8a75dd7 commit d72384a
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 26 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: coverage

on: push
on:
workflow_call:
inputs:
package:
required: true
type: string

env:
# Setting an environment variable with the value of a configuration variable
package_folder: packages/${{ inputs.package }}
FOUNDRY_PROFILE: ci

jobs:
Expand All @@ -21,15 +26,16 @@ jobs:
uses: ./.github/actions/setup_deps

- name: Run Forge coverage
run: yarn run coverage
id: build
run: cd $package_folder && forge coverage

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
with:
working-directory: ./$package_folder

- name: Filter files to ignore
run: |
lcov --rc lcov_branch_coverage=1 \
cd $package_folder && lcov --rc lcov_branch_coverage=1 \
--remove lcov.info \
--output-file lcov.info "*node_modules*" "*test*" "*script*" "*DeploymentConfig*" "*Redeem*" "*deployment*"
Expand All @@ -40,4 +46,4 @@ jobs:
minimum-coverage: 89
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./
working-directory: ./$package_folder
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Foundry

on: push
on:
workflow_call:
inputs:
package:
required: true
type: string

env:
# Setting an environment variable with the value of a configuration variable
package_folder: packages/${{ inputs.package }}
build_artifact: foundry-built-artifacts-${{ inputs.package }}

jobs:
build:
Expand All @@ -14,17 +22,22 @@ jobs:

- name: Build contracts
run: |
forge build
cd $package_folder && forge build
- name: Archive built artifacts
uses: actions/upload-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact
path: |
cache
out
packages/${{ inputs.package }}/cache
packages/${{ inputs.package }}/out
retention-days: 1

coverage:
uses: ./.github/workflows/coverage.yml
with:
package: ${{ inputs.package }}

contract_size_check:
needs: build
strategy:
Expand All @@ -41,11 +54,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Check contract sizes
run: |
forge build --sizes
cd $package_folder && forge build --sizes
test:
needs: build
Expand All @@ -63,11 +76,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Run Forge tests
run: |
forge test -vvv
cd $package_folder && forge test -vvv
test_fork:
needs: build
Expand All @@ -85,11 +98,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Run fork tests
run: |
forge test -vvv --match-test fork
cd $package_folder && forge test -vvv --match-test fork
env:
FORK_TEST_CHAINS: mainnet,goerli,optimism,optimism_goerli,zora,zora_goerli,base_goerli,base
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
Expand All @@ -110,11 +123,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: "Inspect Storage Layout"
continue-on-error: false
run: yarn run storage-inspect:check
run: cd $package_folder && yarn run storage-inspect:check

build_js:
needs: build
Expand All @@ -132,8 +145,8 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Build js package
run: |
yarn prepack
cd $package_folder && yarn prepack
14 changes: 14 additions & 0 deletions .github/workflows/foundry-by-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Foundry

on: push

jobs:
# we need to prepend _ to conform to 1155 standards
_1155:
uses: ./.github/workflows/foundry-base.yml
with:
package: "1155-contracts"
protocol-rewards:
uses: ./.github/workflows/foundry-base.yml
with:
package: "protocol-rewards"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: ./.github/actions/setup_deps

- name: Run prettier
run: yarn run prettier:check
run: yarn lint
2 changes: 2 additions & 0 deletions packages/1155-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"test-gas": "forge test --gas-report",
"prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'wagmi.config.ts'",
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'",
"lint": "yarn run prettier:check",
"coverage": "forge coverage --report lcov",
"write-gas-report": "forge test --gas-report > gasreport.ansi",
"prepack": "yarn wagmi && yarn bundle-configs && yarn build",
"update-new-deployment-addresses": "node script/copy-deployed-contracts.mjs deploy",
"update-contract-version": "node script/update-contract-version.mjs",
"build:contracts": "forge build",
"build": "tsup",
"bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier",
"wagmi": "wagmi generate",
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol-rewards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"build": "forge build",
"test": "forge test",
"prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'"
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
"lint": "yarn run prettier"
},
"dependencies": {
"ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b",
Expand Down

0 comments on commit d72384a

Please sign in to comment.