Skip to content

Commit 0579211

Browse files
committed
ci(examples): keep hardhat process alive, kill afterwards
1 parent d17f290 commit 0579211

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.github/workflows/use-cases.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
timeout-minutes: 15
1111
env:
1212
VITE_ALCHEMY_API_KEY: ${{ secrets.VITE_ALCHEMY_API_KEY }}
13+
HARDHAT_KEEPALIVE: 'true'
1314

1415
steps:
1516
- name: Checkout
@@ -35,4 +36,4 @@ jobs:
3536
with:
3637
timeout_minutes: 20
3738
max_attempts: 3
38-
command: npx turbo test:ci --cache-dir=".cache" --concurrency=1 --filter="./examples/zora-mint"
39+
command: npx turbo test:ci --cache-dir=".cache" --concurrency=1 --filter="./examples/*" || kill $(lsof -t -i:8545)

test/src/setup.hardhat.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ function createHardhatProcess(): Promise<ChildProcessWithoutNullStreams> {
4141

4242
export async function setup({}: GlobalSetupContext) {
4343
const pids = await findProcess('port', 8545);
44-
let process: ChildProcessWithoutNullStreams;
44+
let proc: ChildProcessWithoutNullStreams;
4545
if (pids.length)
4646
console.log('hardhat process already running, not starting a new one');
4747
else {
48-
process = await createHardhatProcess();
48+
proc = await createHardhatProcess();
4949
console.log('hardhat started successfully');
5050
}
5151

5252
return function () {
53-
if (process && !process.killed) {
54-
process.kill();
53+
if (!process.env.HARDHAT_KEEPALIVE && proc && !proc.killed) {
54+
proc.kill();
5555
}
5656
};
5757
}

turbo.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://turbo.build/schema.json",
3-
"globalPassThroughEnv": ["VITE_ALCHEMY_API_KEY"],
3+
"globalPassThroughEnv": ["VITE_ALCHEMY_API_KEY", "HARDHAT_KEEPALIVE"],
44
"tasks": {
55
"build": {
66
"dependsOn": ["^build"],

0 commit comments

Comments
 (0)