Skip to content

Commit

Permalink
Merge pull request #22 from VaporFi/ci-workflow
Browse files Browse the repository at this point in the history
feat: add CI, prettier and reduce anti-whale
  • Loading branch information
mejiasd3v authored Apr 25, 2024
2 parents 35073c3 + 37b20ef commit 8ebc567
Show file tree
Hide file tree
Showing 69 changed files with 3,315 additions and 3,359 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: "CI"

env:
API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }}
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"

jobs:
lint:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install pnpm"
uses: pnpm/action-setup@v3
with:
version: 8

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Lint the code"
run: "pnpm run lint"

- 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@v4"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install pnpm"
uses: pnpm/action-setup@v3
with:
version: 8

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Build the contracts and print their size"
run: "forge build --sizes"

- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
test:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install pnpm"
uses: pnpm/action-setup@v3
with:
version: 8

- name: "Install the Node.js dependencies"
run: "pnpm install"

- 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
- name: "Run the tests"
run: "forge test"

- name: "Add test summary"
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint
20 changes: 20 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# directories
broadcast
cache
cache_forge
coverage
node_modules
out
artifacts
typechain-types

# files
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
21 changes: 21 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"plugins": ["prettier-plugin-solidity"],
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf",
"overrides": [
{
"files": ["*.sol"],
"options": {
"printWidth": 120
}
}
]
}
14 changes: 14 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "solhint:recommended",
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.25"],
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"one-contract-per-file": "off"
}
}
Loading

0 comments on commit 8ebc567

Please sign in to comment.