Skip to content

Commit

Permalink
upgrade packages + foundry setup + start fixes test (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeNervoXS authored Dec 14, 2022
1 parent 51a4394 commit 873b5e7
Show file tree
Hide file tree
Showing 104 changed files with 4,648 additions and 4,530 deletions.
11 changes: 6 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
plugins: ['mocha-no-only', 'promise', 'prettier', '@typescript-eslint'],
plugins: ['mocha-no-only', 'promise', 'prettier', '@typescript-eslint', 'simple-import-sort', 'mocha'],
env: {
browser: true,
node: true,
Expand All @@ -28,7 +28,7 @@ module.exports = {
'prettier/prettier': 'error',
// Code style
'array-bracket-spacing': ['off'],
camelcase: ['error', { properties: 'always', ignoreImports: true, allow: ['.*__factory$'] }],
camelcase: ['error', { properties: 'always', allow: ['(.*?)__factory'] }],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': ['error', { before: false, after: true }],
'dot-notation': ['error', { allowKeywords: true, allowPattern: '' }],
Expand All @@ -43,18 +43,19 @@ module.exports = {
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
'no-redeclare': ['error', { builtinGlobals: true }],
'no-trailing-spaces': ['error', { skipBlankLines: false }],
'no-unused-expressions': 'off',
'no-non-null-asserted-optional-chain': 'off',
'no-undef': 'error',
'no-use-before-define': 'off',
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'error',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'space-before-function-paren': 0,
'@typescript-eslint/no-non-null-assertion': 0,

'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'mocha-no-only/mocha-no-only': ['error'],

'promise/always-return': 'off',
'promise/avoid-new': 'off',
},
Expand Down
59 changes: 47 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ on:
required: true
options:
- all
- run-compile
- hardhat-tests
- foundry-tests
pull_request:
types:
- ready_for_review
- review_requested
pull_request_review:
types: [submitted]

defaults:
run:
shell: bash

jobs:
run-linters:
if: github.ref == 'refs/heads/main' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -33,17 +41,15 @@ jobs:
restore-keys: yarn-
- name: Install dependencies
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set //registry.npmjs.org/
yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Run solhint
run: yarn lint:sol
- name: Run eslint
run: yarn lint:js:fix

run-compile:
if: ${{ github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'unit_tests' }}
hardhat-tests:
if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'hardhat-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -57,17 +63,46 @@ jobs:
restore-keys: yarn-
- name: Install dependencies
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set //registry.npmjs.org/
yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# This is required separately from yarn test because it generates the typechain definitions
- name: Compile
run: yarn compile
run: yarn hardhat:compile
- run: export NODE_OPTIONS=--max_old_space_size=11264
- name: Run unit tests
run: yarn test
run: yarn hardhat:test
env:
ENABLE_GAS_REPORT: true
CI: true
ETH_NODE_URI_ETH_FOUNDRY: ${{secrets.ETH_NODE_URI_ETH_FOUNDRY}}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_FORK: ${{ secrets.ETH_NODE_URI_FORK }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

foundry-tests:
if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'foundry-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/cache@v2
with:
path: node_modules
key: yarn-${{ hashFiles('yarn.lock') }}
restore-keys: yarn-
- run: yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Foundry tests
run: yarn foundry:test
env:
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_GOERLI: ${{ secrets.ETH_NODE_URI_GOERLI }}
ETH_NODE_URI_FANTOM: ${{ secrets.ETH_NODE_URI_FANTOM }}
33 changes: 12 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,44 @@ __pycache__
.idea
.DS_Store
.deps
.vscode
.docs
.env
node_modules
tenderly.yaml
settings.json
.mocharc.json
venv

# Build output
cache
/cache
/cache-hh
build
export
**/artifacts
.openzeppelin
docgen/docs
docgen/SUMMARY.md
solidity-flattenedContracts
./crytic-export
typechain

slither-audit.txt
slither
slither.db.json

# Test output
coverage
coverage.json
lcov.info

# Running output
gas-report.txt
gasReporterOutput.json
addresses.json
blockchain_db
ganache*
yarn-error.log
broadcast

# deployments
deployments/*
!deployments/kovan
!deployments/rinkeby
!deployments/mainnet
!deployments/polygon
deployments/localhost
deployments/mainnetForkRemote

# bin
bin

# temporary delete
test/perpetualManager/perpetualManagerChangeBase.test.js
typechain/cacheIndex.ts

# used for storing temporary vyper artifacts
vyper_temp_dir
# foundry
/out
/cache-forge
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": "ts-node/register/files",
"mochaExplorer.files": "test/**/*.ts",
"timeout": 20000
}
36 changes: 18 additions & 18 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"arrowParens": "avoid",
"jsxSingleQuote": true,
"singleQuote": true,
"printWidth": 120,
"semi": true,
"trailingComma": "all",
"useTabs": false,
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 120,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
}
}
]
"arrowParens": "avoid",
"jsxSingleQuote": true,
"singleQuote": true,
"printWidth": 120,
"semi": true,
"trailingComma": "all",
"useTabs": false,
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 120,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
}
}
]
}
14 changes: 10 additions & 4 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "warning",
"avoid-call-value": "warn",
"avoid-low-level-calls": "warn",
"avoid-tx-origin": "warn",
"const-name-snakecase": "warn",
"contract-name-camelcase": "warn",
"imports-on-top": "warn",
"prettier/prettier": "warn",
"ordering": "off",
"mark-callable-contracts": "off",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"compiler-version": "off",
"private-vars-leading-underscore": "off",
"private-vars-leading-underscore": "warn",
"reentrancy": "warn",
"reason-string": "off",
"const-name-snakecase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }]
"func-visibility": ["warn", { "ignoreConstructors": true }]
}
}
3 changes: 0 additions & 3 deletions .solhintignore

This file was deleted.

6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"python.terminal.activateEnvironment": true,
"python.defaultInterpreterPath": "/opt/anaconda3/envs/angle/bin/python",
"python.terminal.activateEnvInCurrentTerminal": false,
"python.terminal.executeInFileDir": false
}
Loading

0 comments on commit 873b5e7

Please sign in to comment.