Skip to content

Commit

Permalink
Tests & ESLint Improvements (#7012)
Browse files Browse the repository at this point in the history
* jest speed up

* extra fixes

* test

* test

* revert

* eslint speedup

* new version

* remoce cache

* fix

* test

* fix

* try again

* +

* add token

* delete all in once

* change cache strategy

* fix

* add ifs

* test multi cache

* test

* test

* done

* fix

* Update build.yml
  • Loading branch information
avkos authored May 2, 2024
1 parent b413ebd commit 88b7e2e
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 36 deletions.
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/[email protected]
- 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

1 comment on commit 88b7e2e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 88b7e2e Previous: 6c075db Ratio
processingTx 9219 ops/sec (±3.36%) 9301 ops/sec (±4.81%) 1.01
processingContractDeploy 38213 ops/sec (±7.03%) 39129 ops/sec (±7.62%) 1.02
processingContractMethodSend 19245 ops/sec (±6.02%) 19443 ops/sec (±5.19%) 1.01
processingContractMethodCall 38559 ops/sec (±4.51%) 38971 ops/sec (±6.34%) 1.01
abiEncode 41839 ops/sec (±8.41%) 44252 ops/sec (±6.92%) 1.06
abiDecode 30277 ops/sec (±6.54%) 30419 ops/sec (±8.89%) 1.00
sign 1556 ops/sec (±3.30%) 1656 ops/sec (±4.08%) 1.06
verify 374 ops/sec (±0.46%) 373 ops/sec (±0.78%) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.