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

wip: test serialized data errors #5804

Closed
wants to merge 2 commits into from
Closed
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
239 changes: 5 additions & 234 deletions .github/workflows/v-next-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,229 +16,17 @@ concurrency:
cancel-in-progress: true

jobs:
check_dependencies:
name: Check dependency versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Run check
run: node scripts/check-v-next-dependencies.js

check_npm_scripts:
name: Check that the npm scripts are consistent
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Run check
run: node scripts/check-v-next-npm-scripts.js

list-packages:
name: List packages
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.filter.outputs.changes }}
files: ${{ toJSON(steps.filter.outputs) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: yq -p yaml -o json pnpm-lock.yaml | tee pnpm-lock.json
- id: generate
env:
PACKAGE_IGNORE: |
[
".",
"packages/",
"v-next/example-project",
"v-next/hardhat/templates/"
]
COMMON_FILTERS: |
[
".github/workflows/v-next-ci.yml",
"config-v-next/**",
"pnpm-lock.yaml"
]
run: |
echo "filters<<EOF" >> $GITHUB_OUTPUT
node scripts/generate-filters.js |
yq -Po yaml 'with_entries(.key |= sub("^v-next/", ""))' |
tee -a $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
list-files: json
filters: ${{ steps.generate.outputs.filters }}

bundle:
# Depending on list-packages only to check whether pnpm-lock.yaml has changed
# This could be handled by a simpler job, but an extra runner would have to be allocated for it
needs: list-packages

if: |
contains(fromJSON(needs.list-packages.outputs.files).hardhat_files, '.github/workflows/v-next-ci.yml') ||
contains(fromJSON(needs.list-packages.outputs.files).hardhat_files, 'pnpm-lock.yaml')

# Using a matrix strategy even though there's only one package
# because we will want to add, at least, hardhat-toolbox in the future
strategy:
fail-fast: false
matrix:
package: ['hardhat']

name: "[${{ matrix.package }}] bundle"
runs-on: ubuntu-latest
defaults:
run:
working-directory: v-next/${{ matrix.package }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
with:
node-version: 22
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build
run: pnpm build
# https://github.com/pnpm/pnpm/issues/6166
- name: Deploy
run: |
pnpm deploy --config.shamefully-hoist=true --config.hoist=true --config.node-linker=true --config.shared-workspace-lockfile=false --filter="$(jq -r .name package.json)" --prod --no-optional bundle
# We need to move the node_modules links from v-next/hardhat/bundle to bundle because
# https://github.com/pnpm/pnpm/pull/8465 broke modules generation with the set of options we provide
for old_link in $(find v-next/hardhat/bundle -type l); do
echo "Processing link $old_link"
new_link="${old_link#v-next/hardhat/}"
new_link_dir="$(dirname "$new_link")"
old_link_target="$(readlink -f "$old_link")"
mkdir -p "$new_link_dir"
ln -rs "$old_link_target" "$new_link"
new_link_target="$(readlink "$new_link")"
echo "Created link $new_link -> $new_link_target"
done
rm -rf v-next
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}
path: |
v-next/${{ matrix.package }}/bundle

bundle-aggregate:
needs: bundle

if: ${{ !cancelled() }}

name: bundle
runs-on: ubuntu-latest

permissions:
pull-requests: write

steps:
- env:
result: ${{ needs.bundle.result }}
run: |
if [[ "$result" == "failure" ]]; then
exit 1
fi
shell: bash
- uses: actions/download-artifact@v4
- id: download
run: ls -1 | wc -l | xargs -I {} -0 echo "count={}" | tee -a $GITHUB_OUTPUT
shell: bash
- id: comment
if: steps.download.outputs.count != '0'
run: |
echo 'body<<EOF' >> $GITHUB_OUTPUT
for bundle in *; do
echo "# $bundle" | tee -a $GITHUB_OUTPUT
echo '' | tee -a $GITHUB_OUTPUT
echo "Total size of the bundle: "'`'"$(du -sh $bundle --exclude=$bundle/node_modules/.pnpm | cut -f1)"'`' | tee -a $GITHUB_OUTPUT
echo "Total number of dependencies (including transitive): "'`'"$(find $bundle/node_modules/@* $bundle/node_modules -mindepth 1 -maxdepth 1 -type d ! -name '.*' ! -name '@*' | wc -l)"'`' | tee -a $GITHUB_OUTPUT
echo '' | tee -a $GITHUB_OUTPUT
echo '<details>' | tee -a $GITHUB_OUTPUT
echo '<summary>List of dependencies (sorted by size)</summary>' | tee -a $GITHUB_OUTPUT
echo '' | tee -a $GITHUB_OUTPUT
echo '```' | tee -a $GITHUB_OUTPUT
du -shc $bundle/node_modules/@*/* $bundle/node_modules/* |
grep -Ev '/node_modules/@[^/]+$' | sort -rh |
sed "s|$bundle/node_modules/||" | tee -a $GITHUB_OUTPUT
echo '```' | tee -a $GITHUB_OUTPUT
echo '</details>' | tee -a $GITHUB_OUTPUT
echo '' | tee -a $GITHUB_OUTPUT
done
echo 'EOF' >> $GITHUB_OUTPUT
- if: github.event_name == 'pull_request' && steps.download.outputs.count != '0'
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: bundle
message: ${{ steps.comment.outputs.body }}

lint:
needs: list-packages

if: needs.list-packages.outputs.packages != '[]'

strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.list-packages.outputs.packages) }}

name: "[${{ matrix.package }}] lint"
runs-on: ubuntu-latest
defaults:
run:
working-directory: v-next/${{ matrix.package }}

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
with:
node-version: 22
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint

lint-aggregate:
needs: lint

if: ${{ !cancelled() }}

name: lint
runs-on: ubuntu-latest

steps:
- env:
result: ${{ needs.lint.result }}
run: |
if [[ "$result" == "failure" ]]; then
exit 1
fi
shell: bash

ci:
needs: list-packages

if: needs.list-packages.outputs.packages != '[]'

strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.list-packages.outputs.packages) }}
package: [hardhat, hardhat]
command: [test, test2]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
node: [22]
attempt: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

name: "[${{ matrix.package }}] ci on ${{ matrix.os }} (Node ${{ matrix.node }})"
name: "[${{ matrix.package }}] ci on ${{ matrix.os }} with ${{ matrix.command }} (Node ${{ matrix.node }}; attempt ${{ matrix.attempt }})"
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -254,21 +42,4 @@ jobs:
- name: Build
run: pnpm build
- name: Run tests
run: pnpm run test

ci-aggregate:
needs: ci

if: ${{ !cancelled() }}

name: ci
runs-on: ubuntu-latest

steps:
- env:
result: ${{ needs.ci.result }}
run: |
if [[ "$result" == "failure" ]]; then
exit 1
fi
shell: bash
run: pnpm run ${{ matrix.command }}
1 change: 1 addition & 0 deletions v-next/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
"test": "node --import tsx/esm --test --test-reporter=@ignored/hardhat-vnext-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test2": "node --import tsx/esm --test \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test:only": "node --import tsx/esm --test --test-only --test-reporter=@ignored/hardhat-vnext-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"pretest": "pnpm build",
"pretest:only": "pnpm build",
Expand Down
20 changes: 19 additions & 1 deletion v-next/hardhat/test/internal/cli/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import path from "node:path";
import { describe, it } from "node:test";
import { after, before, describe, it } from "node:test";

import { HardhatError } from "@ignored/hardhat-vnext-errors";
import {
Expand All @@ -25,8 +25,22 @@ import {
} from "../../../../src/internal/cli/init/init.js";
import { getTemplates } from "../../../../src/internal/cli/init/template.js";

function disableConsoleLog() {
const originalLog = console.log;

before(() => {
console.log = () => {};
});

after(() => {
console.log = originalLog;
});
}

// NOTE: This uses network to access the npm registry
describe("printWelcomeMessage", () => {
disableConsoleLog();

it("should not throw if latest version of hardhat cannot be retrieved from the registry", async () => {
await printWelcomeMessage();
});
Expand Down Expand Up @@ -150,6 +164,8 @@ describe("copyProjectFiles", () => {
describe("installProjectDependencies", () => {
useTmpDir("installProjectDependencies");

disableConsoleLog();

describe("when install is true", () => {
// This test is skipped because installing dependencies over the network is slow
it.skip("should install the project dependencies", async () => {
Expand All @@ -176,6 +192,8 @@ describe("installProjectDependencies", () => {
describe("initHardhat", async () => {
useTmpDir("initHardhat");

disableConsoleLog();

const templates = await getTemplates();

for (const template of templates) {
Expand Down