Skip to content

Commit afa67bf

Browse files
authored
fix(test): Clean up docker containers with script (#10454)
This PR adds a script to cleanup any docker containers left over from the node integration tests. - It uses `globby@11` since that is already installed for a couple of our dependencies. - It finds all the `docker-compose.yml` files and runs `docker compose down --volumes` in those directories. - It catches all errors for when docker is not running
1 parent 17f9b04 commit afa67bf

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"build:dev": "yarn build",
1515
"build:transpile": "rollup -c rollup.npm.config.mjs",
1616
"build:types": "tsc -p tsconfig.types.json",
17-
"clean": "rimraf -g **/node_modules && run-p clean:docker:*",
18-
"clean:docker:mysql2": "cd suites/tracing-experimental/mysql2 && docker-compose down --volumes",
17+
"clean": "rimraf -g **/node_modules && run-p clean:docker",
18+
"clean:docker": "node scripts/clean.js",
1919
"prisma:init": "(cd suites/tracing/prisma-orm && ts-node ./setup.ts)",
2020
"prisma:init:new": "(cd suites/tracing-new/prisma-orm && ts-node ./setup.ts)",
2121
"lint": "eslint . --format stylish",
@@ -52,6 +52,9 @@
5252
"proxy": "^2.1.1",
5353
"yargs": "^16.2.0"
5454
},
55+
"devDependencies": {
56+
"globby": "11"
57+
},
5558
"config": {
5659
"mongodbMemoryServer": {
5760
"preferGlobalPath": true,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { execSync } = require('child_process');
2+
const globby = require('globby');
3+
const { dirname, join } = require('path');
4+
5+
const cwd = join(__dirname, '..');
6+
const paths = globby.sync(['suites/**/docker-compose.yml'], { cwd }).map(path => join(cwd, dirname(path)));
7+
8+
// eslint-disable-next-line no-console
9+
console.log('Cleaning up docker containers and volumes...');
10+
11+
for (const path of paths) {
12+
try {
13+
// eslint-disable-next-line no-console
14+
console.log(`docker compose down @ ${path}`);
15+
execSync('docker compose down --volumes', { stdio: 'inherit', cwd: path });
16+
} catch (_) {
17+
//
18+
}
19+
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16753,7 +16753,7 @@ [email protected]:
1675316753
merge2 "^1.2.3"
1675416754
slash "^3.0.0"
1675516755

16756-
[email protected], globby@^11.0.1, globby@^11.0.3, globby@^11.1.0:
16756+
globby@11, globby@11.1.0, globby@^11.0.1, globby@^11.0.3, globby@^11.1.0:
1675716757
version "11.1.0"
1675816758
resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
1675916759
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==

0 commit comments

Comments
 (0)