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

Tests & ESLint Improvements #7012

Merged
merged 25 commits into from
May 2, 2024
Merged
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
85 changes: 70 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: yarn install --ignore-scripts
- run: npx ts-node scripts/init.ts
- run: yarn build:cjs
- uses: actions/cache/save@v3
- uses: actions/cache/save@v4
with:
path: ./
key: web3-${{ matrix.node }}-${{github.sha}}
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -65,12 +65,63 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
- run: npx ts-node scripts/init.ts
- name: Restore eslint caches
uses: actions/cache/restore@v4
with:
path: |
packages/web3/.eslintcache
packages/web3-core/.eslintcache
packages/web3-eth/.eslintcache
packages/web3-eth-abi/.eslintcache
packages/web3-eth-accounts/.eslintcache
packages/web3-eth-contract/.eslintcache
packages/web3-eth-ens/.eslintcache
packages/web3-eth-iban/.eslintcache
packages/web3-eth-personal/.eslintcache
packages/web3-net/.eslintcache
packages/web3-providers-http/.eslintcache
packages/web3-providers-ws/.eslintcache
packages/web3-rpc-methods/.eslintcache
packages/web3-types/.eslintcache
packages/web3-utils/.eslintcache
packages/web3-validator/.eslintcache
tools/web3-plugin-example/.eslintcache
key: ${{ runner.os }}-eslintcache

- run: yarn lint
- run: gh cache delete "${{ runner.os }}-eslintcache"
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Save eslint caches
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
uses: actions/cache/save@v4
with:
path: |
packages/web3/.eslintcache
packages/web3-core/.eslintcache
packages/web3-eth/.eslintcache
packages/web3-eth-abi/.eslintcache
packages/web3-eth-accounts/.eslintcache
packages/web3-eth-contract/.eslintcache
packages/web3-eth-ens/.eslintcache
packages/web3-eth-iban/.eslintcache
packages/web3-eth-personal/.eslintcache
packages/web3-net/.eslintcache
packages/web3-providers-http/.eslintcache
packages/web3-providers-ws/.eslintcache
packages/web3-rpc-methods/.eslintcache
packages/web3-types/.eslintcache
packages/web3-utils/.eslintcache
packages/web3-validator/.eslintcache
tools/web3-plugin-example/.eslintcache
key: ${{ runner.os }}-eslintcache

build-web:
name: Build Web
Expand All @@ -80,13 +131,13 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
- name: Restore default branch stats
if: github.event_name != 'push'
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: packages/web3/dist/4.x.json
key: web3-bundle-stats-4x-${{github.event.pull_request.base.sha}}
Expand All @@ -101,7 +152,7 @@ jobs:
current-stats-json-path: "packages/web3/dist/${{ github.ref_name }}.json"
base-stats-json-path: "packages/web3/dist/4.x.json"
- name: Cache default branch stats
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
with:
path: packages/web3/dist/${{ github.ref_name }}.json
Expand All @@ -120,7 +171,7 @@ jobs:
with:
architecture: x64
node-version: ${{ matrix.node }}
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-${{ matrix.node }}-${{github.sha}}
Expand All @@ -142,7 +193,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -165,7 +216,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -186,7 +237,7 @@ jobs:
node-version: 18
- uses: browser-actions/setup-firefox@latest
if: matrix.browser == 'firefox'
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -212,7 +263,7 @@ jobs:
with:
cache: yarn
node-version: '18'
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -235,14 +286,14 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
# @octokit/core not supported on node 16, so I can't add it to the package.json
- run: npm install --no-package-lock --no-save --force @octokit/core@5.1.0
- name: Restore main branch benchmark data
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: web3-benchmark-main.json
key: ${{ runner.os }}-web3-benchmark-main.json
Expand Down Expand Up @@ -279,8 +330,12 @@ jobs:
# Enable alert commit comment
alert-threshold: '200%'
comment-always: false
- run: gh cache delete "${{ runner.os }}-web3-benchmark-main.json"
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save main branch benchmark data
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
with:
path: web3-benchmark-main.json
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ packages/web3/.in3/

# benchmark results
benchmark-data.txt

.eslintcache
2 changes: 1 addition & 1 deletion packages/web3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-abi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-ens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-iban/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-personal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-net/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers-ipc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-rpc-methods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build:types": "tsc --build tsconfig.types.json",
"build:web": "npx webpack",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"build:web": "npx webpack",
"build:web:analyze": "npx webpack --config ./webpack.analyze.js",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
1 change: 1 addition & 0 deletions templates/jest.config.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'ts-jest',
{
tsconfig: './test/tsconfig.json',
isolatedModules: true,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-config-base-web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"main": "ts.js",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/web3-packagetemplate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build:esm": "tsc --build tsconfig.esm.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion tools/web3-plugin-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"prebuild": "yarn clean",
"build": "tsc --build",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
Loading