Skip to content

Commit a19d893

Browse files
author
Luca Forstner
committed
Cleanup
1 parent d7dfb31 commit a19d893

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.github/workflows/canary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Canary Tests'
22
on:
33
schedule:
4-
# Runs "at minute 55 past every hour" (see https://crontab.guru)
4+
# Run every day at midnight
55
- cron: '0 0 * * *'
66
workflow_dispatch:
77
inputs:

packages/e2e-tests/run.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
/* eslint-disable no-console */
23
import * as childProcess from 'child_process';
34
import * as fs from 'fs';
@@ -286,18 +287,21 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
286287
}[] = process.env.CANARY_E2E_TEST ? recipe.canaryVersions ?? [] : recipe.versions ?? [{}];
287288

288289
const versionResults = versionsToRun.map(({ dependencyOverrides }) => {
290+
const packageJsonPath = path.resolve(recipeDirname, 'package.json');
291+
const packageJsonBackupPath = path.resolve(recipeDirname, 'package.json.bak');
292+
289293
if (dependencyOverrides) {
290294
// Back up original package.json
291-
fs.copyFileSync(path.resolve(recipeDirname, 'package.json'), path.resolve(recipeDirname, 'package.json.bak'));
295+
fs.copyFileSync(packageJsonPath, packageJsonBackupPath);
292296

293297
// Override dependencies
294298
const packageJson: { dependencies?: Record<string, string> } = JSON.parse(
295-
fs.readFileSync(path.resolve(recipeDirname, 'package.json'), { encoding: 'utf-8' }),
299+
fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }),
296300
);
297301
packageJson.dependencies = packageJson.dependencies
298302
? { ...packageJson.dependencies, ...dependencyOverrides }
299303
: dependencyOverrides;
300-
fs.writeFileSync(path.resolve(recipeDirname, 'package.json'), JSON.stringify(packageJson, null, 2), {
304+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), {
301305
encoding: 'utf-8',
302306
});
303307
}
@@ -307,9 +311,9 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
307311
} finally {
308312
if (dependencyOverrides) {
309313
// Restore original package.json
310-
fs.rmSync(path.resolve(recipeDirname, 'package.json'), { force: true });
311-
fs.copyFileSync(path.resolve(recipeDirname, 'package.json.bak'), path.resolve(recipeDirname, 'package.json'));
312-
fs.rmSync(path.resolve(recipeDirname, 'package.json.bak'), { force: true });
314+
fs.rmSync(packageJsonPath, { force: true });
315+
fs.copyFileSync(packageJsonBackupPath, packageJsonPath);
316+
fs.rmSync(packageJsonBackupPath, { force: true });
313317
}
314318
}
315319
});
@@ -349,11 +353,9 @@ recipeResults.forEach(recipeResult => {
349353
});
350354
});
351355

352-
groupCIOutput('Cleanup', () => {
353-
// Stop test registry
354-
childProcess.spawnSync(`docker stop ${TEST_REGISTRY_CONTAINER_NAME}`, { encoding: 'utf8', stdio: 'ignore' });
355-
console.log('Successfully stopped test registry container'); // Output from command above is not good so we `ignore` it and emit our own
356-
});
356+
// Stop test registry
357+
childProcess.spawnSync(`docker stop ${TEST_REGISTRY_CONTAINER_NAME}`, { encoding: 'utf8', stdio: 'ignore' });
358+
console.log('Successfully stopped test registry container'); // Output from command above is not good so we `ignore` it and emit our own
357359

358360
if (processShouldExitWithError) {
359361
console.log('Not all tests succeeded.');

0 commit comments

Comments
 (0)