Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
as3810t committed Nov 21, 2024
0 parents commit 55434de
Show file tree
Hide file tree
Showing 78 changed files with 17,910 additions and 0 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: PR
on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
filter_mode: added
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: EPMatt/reviewdog-action-prettier@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
filter_mode: added
prettier_flags: '**/*.{js,sol,ts,json,jsx,tsx}'
solhint:
name: Solhint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run solhint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-pr-check -level=error -fail-level=none -filter-mode=added -name=solhint
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1000
- name: Fetch base
run: git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1000
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run coverage
run: SOLIDITY_COVERAGE=true npx hardhat coverage
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v4.1.19
with:
coverage-files: coverage/lcov.info
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: .
update-comment: true
163 changes: 163 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: CI
on:
push:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build contracts
id: build
run: npm run compile
- name: 'Add build summary'
if: ${{ success() || failure() }}
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (success)'
if: ${{ success() && steps.build.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (failed)'
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
test:
name: Test
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test contracts
id: run_tests
run: |
(npm run --silent test >> /tmp/TEST_OUTPUT) || FAILED=1
{
echo "test_output<<RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
cat /tmp/TEST_OUTPUT
echo "RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
} >> "$GITHUB_OUTPUT"
cat /tmp/TEST_OUTPUT
if [ ${FAILED:-0} -eq 1 ]
then
exit 1
fi
- name: 'Add test summary'
if: ${{ success() || failure() }}
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{steps.run_tests.outputs.test_output}}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (success)'
if: ${{ success() && steps.run_tests.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (failed)'
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
eslint:
name: ESLint
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
filter_mode: nofilter
level: info
prettier:
name: Prettier
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: EPMatt/reviewdog-action-prettier@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
filter_mode: nofilter
prettier_flags: '**/*.{js,sol,ts,json,jsx,tsx}'
level: info
solhint:
name: Solhint
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run solhint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-check -level=info -fail-level=none -filter-mode=nofilter -name=solhint
slither:
name: Slither
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Slither
uses: crytic/slither-action@v0.4.0
id: slither
with:
node-version: 20
sarif: 'results.sarif'
fail-on: none
slither-args: --filter-paths node_modules/
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
.env

# Solidity compiler files
/bin

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": "hardhat/register",
"timeout": 5000,
"_": ["test/**/*.ts"]
}
6 changes: 6 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "solhint:recommended",
"rules": {
"func-visibility": ["warn", { "ignoreConstructors": true }]
}
}
18 changes: 18 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint",
"hbenl.vscode-mocha-test-adapter",
"esbenp.prettier-vscode",
"JuanBlanco.solidity",
"ms-vscode.test-adapter-converter",
"hbenl.vscode-test-explorer",
"mhutchie.git-graph",
"MS-SarifVSCode.sarif-viewer"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": ["NomicFoundation.hardhat-solidity"]
}
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Compile (hardhat)",
"request": "launch",
"runtimeArgs": ["hardhat", "compile"],
"runtimeExecutable": "npx",
"skipFiles": ["<node_internals>/**"],
"type": "node",
"console": "integratedTerminal"
},
{
"name": "Test (hardhat)",
"request": "launch",
"runtimeArgs": ["hardhat", "test"],
"runtimeExecutable": "npx",
"skipFiles": ["<node_internals>/**"],
"type": "node",
"console": "integratedTerminal",
"preLaunchTask": "npm: compile"
}
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"workbench.tree.indent": 20,
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"mochaExplorer.exit": true,
"editor.formatOnSave": true,
"solidity.linter": "solhint"
}
Loading

0 comments on commit 55434de

Please sign in to comment.