-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 06e8fb9
Showing
29 changed files
with
2,034 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export API_KEY_ALCHEMY="YOUR_API_KEY_ALCHEMY" | ||
export API_KEY_ARBISCAN="YOUR_API_KEY_ARBISCAN" | ||
export API_KEY_BSCSCAN="YOUR_API_KEY_BSCSCAN" | ||
export API_KEY_ETHERSCAN="YOUR_API_KEY_ETHERSCAN" | ||
export API_KEY_GNOSISSCAN="YOUR_API_KEY_GNOSISSCAN" | ||
export API_KEY_INFURA="YOUR_API_KEY_INFURA" | ||
export API_KEY_OPTIMISTIC_ETHERSCAN="YOUR_API_KEY_OPTIMISTIC_ETHERSCAN" | ||
export API_KEY_POLYGONSCAN="YOUR_API_KEY_POLYGONSCAN" | ||
export API_KEY_SNOWTRACE="YOUR_API_KEY_SNOWTRACE" | ||
export MNEMONIC="YOUR_MNEMONIC" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/** linguist-vendored |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca | ||
set -euo pipefail | ||
|
||
# Define the input vars | ||
GITHUB_REPOSITORY=${1?Error: Please pass username/repo, e.g. prb/foundry-template} | ||
GITHUB_REPOSITORY_OWNER=${2?Error: Please pass username, e.g. prb} | ||
GITHUB_REPOSITORY_DESCRIPTION=${3:-""} # If null then replace with empty string | ||
|
||
echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY" | ||
echo "GITHUB_REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER" | ||
echo "GITHUB_REPOSITORY_DESCRIPTION: $GITHUB_REPOSITORY_DESCRIPTION" | ||
|
||
# Create a new package.json file with the new values | ||
JQ_OUTPUT_PACKAGE=$( | ||
jq \ | ||
--arg NAME "@$GITHUB_REPOSITORY" \ | ||
--arg AUTHOR "$GITHUB_REPOSITORY_OWNER https://github.com/$GITHUB_REPOSITORY_OWNER" \ | ||
--arg REPOSITORY "github:@$GITHUB_REPOSITORY" \ | ||
--arg BUGS "https://github.com/$GITHUB_REPOSITORY/issues" \ | ||
--arg HOMEPAGE "https://github.com/$GITHUB_REPOSITORY#readme" \ | ||
--arg VERSION "0.0.1" \ | ||
--arg DESCRIPTION "$GITHUB_REPOSITORY_DESCRIPTION" \ | ||
'.name = $NAME | .author = $AUTHOR | .repository = $REPOSITORY | | ||
.bugs = $BUGS | .homepage = $HOMEPAGE | .version = $VERSION | .description = $DESCRIPTION' \ | ||
package.json | ||
) | ||
|
||
# Create a new package-lock.json file with the new values | ||
JQ_OUTPUTPACKAGE_LOCK=$( | ||
jq \ | ||
--arg VERSION "0.0.1" \ | ||
'.version = $VERSION | .packages."".version = $VERSION' \ | ||
package-lock.json | ||
) | ||
|
||
# Save the new version of the package.json and package-lock.json files | ||
echo "$JQ_OUTPUT_PACKAGE" >package.json | ||
echo "$JQ_OUTPUTPACKAGE_LOCK" >package-lock.json | ||
|
||
# Make sed command compatible in both Mac and Linux environments | ||
# Reference: https://stackoverflow.com/a/38595160/8696958 | ||
sedi() { | ||
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@" | ||
} | ||
|
||
# Rename instances of "0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry" to the new repo name in README.md for badges only | ||
sedi "/github-editor-url/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-quality-url/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-quality-badge/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-test-url/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-test-badge/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-static-analysis-url/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-static-analysis-badge/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-release-url/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" | ||
sedi "/gha-release-badge/ s|0x90d2b2b7fb7599eebb6e7a32980857d8/template-foundry|"${GITHUB_REPOSITORY}"|;" "README.md" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Quality checks | ||
|
||
env: | ||
FOUNDRY_PROFILE: "ci" | ||
|
||
# This CI workflow is responsible of running the linter and building the contracts. | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Install the Node.js dependencies | ||
run: npm ci | ||
|
||
- name: Run the linter and the formatter in check mode | ||
run: make quality | ||
|
||
- name: Add lint summary | ||
run: | | ||
echo "## Lint result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Compile the contracts and print their size | ||
run: make compile-s | ||
|
||
- name: Add compile summary | ||
run: | | ||
echo "## Build result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Release on tag | ||
|
||
# Trigger the create release workflow when a new tag | ||
# respecting the pattern `v*` is pushed to the repository and deploy | ||
# the new version of the documentation on the `gh-pages` branch. | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: "marvinpinto/action-automatic-releases@v1.2.1" | ||
with: | ||
# TODO: YOU MUST CONFIGURE THIS TOKEN BY OURSEFL. CHECK THE README FOR MORE INFORMATION. | ||
repo_token: "${{ secrets.RELEASE_TOKEN }}" | ||
prerelease: false | ||
|
||
deploy-doc: | ||
needs: ["release"] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Build the documentation | ||
run: make doc | ||
|
||
- name: Deploy the documentation | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: docs/book | ||
branch: gh-pages |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: "Create" | ||
|
||
# The workflow will run only when the "Use this template" button is used | ||
on: | ||
create: | ||
|
||
jobs: | ||
create: | ||
# We only run this action when the repository isn't the template repository. References: | ||
# - https://docs.github.com/en/actions/learn-github-actions/contexts | ||
# - https://docs.github.com/en/actions/learn-github-actions/expressions | ||
if: ${{ !github.event.repository.is_template }} | ||
permissions: "write-all" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Check out the repo" | ||
uses: "actions/checkout@v3" | ||
|
||
- name: "Update package.json" | ||
env: | ||
GITHUB_REPOSITORY_DESCRIPTION: ${{ github.event.repository.description }} | ||
run: | ||
./.github/scripts/setup-packagejson.sh "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" | ||
"$GITHUB_REPOSITORY_DESCRIPTION" | ||
|
||
- name: "Add rename summary" | ||
run: | | ||
echo "## Commit result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | ||
- name: "Remove files not needed in the user's copy of the template" | ||
run: | | ||
rm -f "./.github/FUNDING.yml" | ||
rm -f "./.github/scripts/setup-packagejson.sh" | ||
rm -f "./.github/workflows/setup-template.yml" | ||
- name: "Add remove summary" | ||
run: | | ||
echo "## Remove result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | ||
- name: "Update commit" | ||
uses: "stefanzweifel/git-auto-commit-action@v4" | ||
with: | ||
commit_message: "🎉 initialize the project using @0x90d2b2b7fb7599eebb6e7a32980857d8 template" | ||
commit_options: "--amend" | ||
push_options: "--force" | ||
skip_fetch: true | ||
|
||
- name: "Add commit summary" | ||
run: | | ||
echo "## Commit result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Static analysis | ||
|
||
# This CI workflow is responsible of running static analysis on the codebase. | ||
# The workflow will fail if the tool find a medium or high severity issue. | ||
env: | ||
FOUNDRY_PROFILE: "ci" | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- src/** | ||
- .github/workflows/static-analysis.yml | ||
- slither.config.json | ||
- foundry.toml | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- src/** | ||
- .github/workflows/static-analysis.yml | ||
- slither.config.json | ||
- foundry.toml | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Python3 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Install Slither | ||
run: pip install slither-analyzer | ||
|
||
- name: Run static analysis using Slither | ||
run: slither . --fail-medium |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Tests | ||
|
||
env: | ||
API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }} | ||
API_KEY_ETHERSCAN: ${{ secrets.API_KEY_ETHERSCAN }} | ||
API_KEY_INFURA: ${{ secrets.API_KEY_INFURA }} | ||
FOUNDRY_PROFILE: "ci" | ||
MNEMONIC: ${{ secrets.MNEMONIC }} | ||
|
||
# This CI workflow is responsible of running the tests. | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
# TODO: Make this permission more granular | ||
permissions: write-all | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Show the Foundry config | ||
run: forge config | ||
|
||
- name: Generate a fuzz seed that changes weekly to avoid burning through RPC allowance | ||
run: > | ||
echo "FOUNDRY_FUZZ_SEED=$( | ||
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) | ||
)" >> $GITHUB_ENV | ||
# TODO: Rework the job to correctly print the output of the test command | ||
- name: Run tests with gas reporting | ||
run: forge test --gas-report > gasreport.ansi | ||
|
||
- name: Compare gas reports | ||
uses: Rubilmax/foundry-gas-diff@v3.14 | ||
with: | ||
summaryQuantile: 0.8 # only display the 20% most significant gas diffs in the summary | ||
sortCriteria: avg,max # sort diff rows by criteria | ||
sortOrders: desc,asc # and directions | ||
id: gas_diff | ||
|
||
# Comment on the PR with the gas diff | ||
- name: Add gas diff to sticky comment | ||
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
# delete the comment in case changes no longer impact gas costs | ||
delete: ${{ !steps.gas_diff.outputs.markdown }} | ||
message: ${{ steps.gas_diff.outputs.markdown }} | ||
|
||
coverage: | ||
needs: ["test"] | ||
permissions: write-all | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Check out the repo" | ||
uses: "actions/checkout@v3" | ||
with: | ||
submodules: "recursive" | ||
|
||
- name: "Install Foundry" | ||
uses: "foundry-rs/foundry-toolchain@v1" | ||
|
||
- name: Setup lcov | ||
uses: hrishikesh-kadam/setup-lcov@v1 | ||
|
||
- name: "Generate the coverage report" | ||
# contracts in the test/ and script/ directory are excluded fron the report | ||
# the precompute internal version of the library is also excluded from the report as | ||
# it is highly experimental and to meant to be used at all | ||
run: "forge coverage --report lcov && lcov --remove lcov.info \ | ||
-o lcov.info 'test/*' 'script/*'" | ||
|
||
- name: "Add coverage summary" | ||
run: | | ||
echo "## Coverage result" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | ||
- name: Report code coverage | ||
uses: zgosalvez/github-actions-report-lcov@v3 | ||
with: | ||
coverage-files: lcov.info | ||
# uncomment the following line to enforce a minimum coverage | ||
# minimum-coverage: 80 | ||
artifact-name: code-coverage-report | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
update-comment: true |
Oops, something went wrong.