Skip to content

Commit 29ddf3b

Browse files
committed
debug
1 parent 066f52b commit 29ddf3b

File tree

3 files changed

+17
-196
lines changed

3 files changed

+17
-196
lines changed

.github/workflows/v-next-ci.yml

+2-179
Original file line numberDiff line numberDiff line change
@@ -57,189 +57,12 @@ jobs:
5757
- name: Run check
5858
run: node scripts/check-v-next-npm-scripts.js
5959

60-
list-packages:
61-
name: List packages
62-
needs: is-v-next
63-
if: ${{ needs.is-v-next.outputs.is_v_next == 'true' }}
64-
runs-on: ubuntu-latest
65-
outputs:
66-
packages: ${{ steps.filter.outputs.changes }}
67-
should_bundle: ${{ contains(steps.filter.outputs.hardhat_files, '.github/workflows/v-next-ci.yml') || contains(steps.filter.outputs.hardhat_files, 'pnpm-lock.yaml') }}
68-
steps:
69-
- uses: actions/checkout@v4
70-
- uses: actions/setup-node@v4
71-
with:
72-
node-version: 22
73-
- run: yq -p yaml -o json pnpm-lock.yaml | tee pnpm-lock.json
74-
- id: generate
75-
env:
76-
PACKAGE_IGNORE: |
77-
[
78-
".",
79-
"packages/",
80-
"v-next/hardhat/templates/"
81-
]
82-
COMMON_FILTERS: |
83-
[
84-
".github/workflows/v-next-ci.yml",
85-
"config-v-next/**",
86-
"pnpm-lock.yaml"
87-
]
88-
run: |
89-
echo "filters<<EOF" >> $GITHUB_OUTPUT
90-
node scripts/generate-filters.js |
91-
yq -Po yaml 'with_entries(.key |= sub("^v-next/", ""))' |
92-
tee -a $GITHUB_OUTPUT
93-
echo "EOF" >> $GITHUB_OUTPUT
94-
- id: filter
95-
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
96-
with:
97-
list-files: json
98-
filters: ${{ steps.generate.outputs.filters }}
99-
base: v-next # TODO: Remove once v-next becomes the default branch
100-
101-
bundle:
102-
# Depending on list-packages only to check whether pnpm-lock.yaml has changed
103-
# This could be handled by a simpler job, but an extra runner would have to be allocated for it
104-
needs: list-packages
105-
106-
if: needs.list-packages.outputs.should_bundle == 'true'
107-
108-
# Using a matrix strategy even though there's only one package
109-
# because we will want to add, at least, hardhat-toolbox in the future
110-
strategy:
111-
fail-fast: false
112-
matrix:
113-
package: ["hardhat"]
114-
115-
name: "[${{ matrix.package }}] bundle"
116-
runs-on: ubuntu-latest
117-
defaults:
118-
run:
119-
working-directory: v-next/${{ matrix.package }}
120-
steps:
121-
- uses: actions/checkout@v4
122-
- uses: ./.github/actions/setup-env
123-
with:
124-
node-version: 22
125-
- name: Install dependencies
126-
run: pnpm install --frozen-lockfile --prefer-offline
127-
- name: Build
128-
run: pnpm build
129-
- name: Deploy
130-
run: |
131-
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
132-
- uses: actions/upload-artifact@v4
133-
with:
134-
name: ${{ matrix.package }}
135-
path: |
136-
v-next/${{ matrix.package }}/bundle
137-
138-
bundle-aggregate:
139-
needs: bundle
140-
141-
if: ${{ !cancelled() }}
142-
143-
name: bundle
144-
runs-on: ubuntu-latest
145-
146-
permissions:
147-
pull-requests: write
148-
149-
steps:
150-
- env:
151-
result: ${{ needs.bundle.result }}
152-
run: |
153-
if [[ "$result" == "failure" ]]; then
154-
exit 1
155-
fi
156-
shell: bash
157-
- uses: actions/download-artifact@v4
158-
- id: download
159-
run: ls -1 | wc -l | xargs -I {} -0 echo "count={}" | tee -a $GITHUB_OUTPUT
160-
shell: bash
161-
- id: comment
162-
if: steps.download.outputs.count != '0'
163-
run: |
164-
echo 'body<<EOF' >> $GITHUB_OUTPUT
165-
for bundle in *; do
166-
echo "# $bundle" | tee -a $GITHUB_OUTPUT
167-
echo '' | tee -a $GITHUB_OUTPUT
168-
echo "Total size of the bundle: "'`'"$(du -sh $bundle --exclude=$bundle/node_modules/.pnpm | cut -f1)"'`' | tee -a $GITHUB_OUTPUT
169-
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
170-
echo '' | tee -a $GITHUB_OUTPUT
171-
echo '<details>' | tee -a $GITHUB_OUTPUT
172-
echo '<summary>List of dependencies (sorted by size)</summary>' | tee -a $GITHUB_OUTPUT
173-
echo '' | tee -a $GITHUB_OUTPUT
174-
echo '```' | tee -a $GITHUB_OUTPUT
175-
du -shc $bundle/node_modules/@*/* $bundle/node_modules/* |
176-
grep -Ev '/node_modules/@[^/]+$' | sort -rh |
177-
sed "s|$bundle/node_modules/||" | tee -a $GITHUB_OUTPUT
178-
echo '```' | tee -a $GITHUB_OUTPUT
179-
echo '</details>' | tee -a $GITHUB_OUTPUT
180-
echo '' | tee -a $GITHUB_OUTPUT
181-
done
182-
echo 'EOF' >> $GITHUB_OUTPUT
183-
- if: github.event_name == 'pull_request' && steps.download.outputs.count != '0'
184-
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
185-
with:
186-
header: bundle
187-
message: ${{ steps.comment.outputs.body }}
188-
189-
lint:
190-
needs: list-packages
191-
192-
if: needs.list-packages.outputs.packages != '[]'
193-
194-
strategy:
195-
fail-fast: false
196-
matrix:
197-
package: ${{ fromJson(needs.list-packages.outputs.packages) }}
198-
199-
name: "[${{ matrix.package }}] lint"
200-
runs-on: ubuntu-latest
201-
defaults:
202-
run:
203-
working-directory: v-next/${{ matrix.package }}
204-
205-
steps:
206-
- uses: actions/checkout@v4
207-
- uses: ./.github/actions/setup-env
208-
with:
209-
node-version: 22
210-
- name: Install dependencies
211-
run: pnpm install --frozen-lockfile --prefer-offline
212-
- name: Build
213-
run: pnpm build
214-
- name: Lint
215-
run: pnpm lint
216-
217-
lint-aggregate:
218-
needs: lint
219-
220-
if: ${{ !cancelled() }}
221-
222-
name: lint
223-
runs-on: ubuntu-latest
224-
225-
steps:
226-
- env:
227-
result: ${{ needs.lint.result }}
228-
run: |
229-
if [[ "$result" == "failure" ]]; then
230-
exit 1
231-
fi
232-
shell: bash
233-
23460
ci:
235-
needs: list-packages
236-
237-
if: needs.list-packages.outputs.packages != '[]'
23861

23962
strategy:
24063
fail-fast: false
24164
matrix:
242-
package: ${{ fromJson(needs.list-packages.outputs.packages) }}
65+
package: ['hardhat']
24366
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
24467
node: [22]
24568

@@ -261,7 +84,7 @@ jobs:
26184
- name: Run tests
26285
env:
26386
__DO_NOT_USE_IS_HARDHAT_CI: true
264-
run: pnpm run test
87+
run: pnpm run test:only
26588

26689
ci-aggregate:
26790
needs: ci

v-next/hardhat-utils/src/fs.ts

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ReadStream, WriteStream } from "node:fs";
22

33
import { createReadStream, createWriteStream } from "node:fs";
4-
import fsPromises from "node:fs/promises";
4+
import fsPromises, { FileHandle, open } from "node:fs/promises";
55
import path from "node:path";
66
import { finished } from "node:stream/promises";
77

@@ -210,13 +210,11 @@ export async function readJsonFileAsStream<T>(
210210
): Promise<T> {
211211
const parser = new JSONParser();
212212

213-
let fileContents: ReadStream;
213+
let fileHandle: FileHandle
214+
let fileReadStream: ReadStream;
214215
try {
215-
fileContents = createReadStream(absolutePathToFile, {
216-
encoding: "utf8",
217-
autoClose: true,
218-
flags: "r",
219-
});
216+
fileHandle = await open(absolutePathToFile, "r");
217+
fileReadStream = fileHandle.createReadStream();
220218
} catch (e) {
221219
ensureError<NodeJS.ErrnoException>(e);
222220

@@ -231,7 +229,7 @@ export async function readJsonFileAsStream<T>(
231229
throw new FileSystemAccessError(e.message, e);
232230
}
233231

234-
const readPipeline = fileContents.pipe(parser);
232+
const readPipeline = fileReadStream.pipe(parser);
235233

236234
// NOTE: We save only the last result as it contains the fully parsed object
237235
let result: T | undefined;
@@ -248,6 +246,8 @@ export async function readJsonFileAsStream<T>(
248246

249247
try {
250248
await finished(readPipeline);
249+
250+
await fileHandle.close();
251251
} catch (e) {
252252
ensureError(e);
253253
throw new FileSystemAccessError(absolutePathToFile, e);
@@ -304,14 +304,11 @@ export async function writeJsonFileAsStream<T>(
304304
await mkdir(dirPath);
305305
}
306306

307-
let fileContents: WriteStream;
307+
let fileHandle: FileHandle
308+
let fileWriteStream: WriteStream;
308309
try {
309-
fileContents = createWriteStream(absolutePathToFile, {
310-
encoding: "utf8",
311-
autoClose: true,
312-
mode: 0o666,
313-
flags: "w",
314-
});
310+
fileHandle = await open(absolutePathToFile, "w");
311+
fileWriteStream = fileHandle.createWriteStream();
315312
} catch (e) {
316313
ensureError<NodeJS.ErrnoException>(e);
317314
// if the directory was created, we should remove it
@@ -326,7 +323,7 @@ export async function writeJsonFileAsStream<T>(
326323
}
327324

328325
const jsonStream = new JsonStreamStringify(object);
329-
const writePipeline = jsonStream.pipe(fileContents);
326+
const writePipeline = jsonStream.pipe(fileWriteStream);
330327

331328
try {
332329
await finished(jsonStream);
@@ -337,6 +334,7 @@ export async function writeJsonFileAsStream<T>(
337334

338335
try {
339336
await finished(writePipeline);
337+
await fileHandle.close();
340338
} catch (e) {
341339
ensureError(e);
342340
throw new FileSystemAccessError(e.message, e);

v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/cache.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("ObjectCache", () => {
5151
await cache.set(randomKey, "randomValue");
5252
assert.equal(await cache.get(randomKey), "randomValue");
5353
});
54-
it("should overwrite the value if the key is present", async () => {
54+
it.only("should overwrite the value if the key is present", async () => {
5555
const randomKey = randomUUID();
5656
await cache.set(randomKey, "randomValue");
5757
assert.equal(await cache.get(randomKey), "randomValue");

0 commit comments

Comments
 (0)