Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo - reusable github workflows #245

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 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,15 @@ jobs:
uses: ./.github/actions/setup_deps

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

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1

- 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 +45,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
${{ $package_folder }}/cache
${{ $package_folder }}/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
15 changes: 15 additions & 0 deletions .github/workflows/foundry-by-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Foundry

on: push

jobs:
# we need to append a c as to not
# allow an integer here
c-1155:
uses: ./.github/workflows/foundry-base.yml
with:
package: "1155-contracts"
c-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