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

chore: js tooling improvements #609

Merged
merged 17 commits into from
Aug 21, 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
24 changes: 24 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup node
description: Sets up node and pnpm

inputs:
pnpm-version:
description: Version of pnpm to install
required: false
default: "9"
node-version:
description: Version of node to install
required: false
default: "20"

runs:
using: composite
steps:
- uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
- uses: actions/setup-node@v4
id: setup-node
with:
node-version: ${{ inputs.node-version }}
cache: pnpm
13 changes: 13 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Setup rust
description: Sets up rust

runs:
using: composite
steps:
- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
17 changes: 2 additions & 15 deletions .github/workflows/edr-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,8 @@ jobs:
if: github.ref == 'refs/heads/main' || github.repository == github.event.pull_request.head.repo.full_name
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 20
cache: pnpm

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-rust

- name: Install package
run: pnpm install --frozen-lockfile --prefer-offline
Expand Down
53 changes: 8 additions & 45 deletions .github/workflows/edr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
- uses: ./.github/actions/setup-rust

# Install pre-built binaries for cargo hack
- uses: taiki-e/install-action@cargo-hack

- uses: Swatinem/rust-cache@v2

- name: Cargo hack
uses: actions-rs/cargo@v1
with:
Expand All @@ -51,14 +44,7 @@ jobs:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- uses: actions/checkout@v3

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust

- name: Cache EDR RPC cache
uses: actions/cache@v2
Expand Down Expand Up @@ -145,55 +131,32 @@ jobs:
needs: check-edr
steps:
- uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust

- name: Cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps --all-features

prettier:
lint:
name: Run Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: pnpm
- uses: ./.github/actions/setup-node

- name: Install package
run: pnpm install --frozen-lockfile --prefer-offline

- name: Run prettier
run: pnpm run prettier
- name: Run lint script
run: pnpm run lint

edr-napi-typings-file:
name: Check that edr_napi typings file is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: pnpm
- uses: ./.github/actions/setup-node

- name: Install package
run: pnpm install --frozen-lockfile --prefer-offline
Expand Down
40 changes: 5 additions & 35 deletions .github/workflows/edr-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 18
node-version: 20
check-latest: true
cache: pnpm
- name: Install Rust toolchain
Expand Down Expand Up @@ -174,15 +174,7 @@ jobs:
working-directory: ./crates/edr_napi
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: pnpm
- uses: ./.github/actions/setup-node
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Download artifacts
Expand All @@ -208,15 +200,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: pnpm
- uses: ./.github/actions/setup-node
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Download artifacts
Expand Down Expand Up @@ -244,15 +228,9 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup node
uses: actions/setup-node@v3
- uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: pnpm
- name: Install dependencies
run: |
pnpm config set supportedArchitectures.libc "musl"
Expand Down Expand Up @@ -395,15 +373,7 @@ jobs:
working-directory: ./crates/edr_napi
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: pnpm
- uses: ./.github/actions/setup-node
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Download all artifacts
Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/hardhat-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,14 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [18.15]
node: [20]
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Node
uses: actions/setup-node@v2
- uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node }}
cache: pnpm

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust

- name: Install package
run: pnpm install --frozen-lockfile --prefer-offline
Expand All @@ -55,9 +42,6 @@ jobs:
hardhat-tests/test/internal/hardhat-network/stack-traces/test-files/artifacts
key: hardhat-network-stack-traces-tests-${{ hashFiles('hardhat-tests/test/internal/hardhat-network/stack-traces/test-files/**/*.sol') }}-${{ hashFiles('hardhat-tests/test/internal/hardhat-network/stack-traces/test-files/**/test.json') }}-${{ hashFiles('hardhat-tests/test/internal/hardhat-network/stack-traces/**/*.ts') }}

- name: Build
Copy link
Member

Choose a reason for hiding this comment

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

Just validating my understanding: this is not necessary because the test command has a pre-test step that builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly. That wasn't the case before (because the pretest script was only running build:edr), but now both EDR is built and the tests code is type-checked before running the tests.

run: cd hardhat-tests && pnpm build

- name: Run tests
env:
INFURA_URL: ${{ secrets.INFURA_URL }}
Expand All @@ -72,15 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 18.15
cache: pnpm
- uses: ./.github/actions/setup-node

- name: Install package
run: pnpm install --frozen-lockfile --prefer-offline
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: "pnpm"
- uses: ./.github/actions/setup-node

- name: Install Dependencies
run: pnpm install --frozen-lockfile --prefer-offline
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/test-recent-mainnet-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust

- name: Cache EDR RPC cache
uses: actions/cache@v2
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"proseWrap": "never"
"proseWrap": "never",
"trailingComma": "es5"
}
22 changes: 22 additions & 0 deletions .syncpackrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @ts-check

/** @type {import("syncpack").RcFile} */
const config = {
versionGroups: [
// smock only works with ethers v5
{
packages: ["hardhat-edr-smock-test"],
dependencies: ["ethers"],
// latest ethers v5 version
pinVersion: "5.7.2",
},
],
semverGroups: [
{
dependencies: ["typescript"],
range: "~",
},
],
};

module.exports = config;
17 changes: 17 additions & 0 deletions crates/edr_napi/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: [`${__dirname}/../../config/eslint/eslintrc.js`],
parserOptions: {
project: `${__dirname}/tsconfig.json`,
sourceType: "module",
},
rules: {
"@typescript-eslint/restrict-template-expressions": "off",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: true,
},
],
"prefer-template": "off",
},
};
Loading
Loading