-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathdocker-test.mjs
More file actions
35 lines (30 loc) · 952 Bytes
/
docker-test.mjs
File metadata and controls
35 lines (30 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import fastGlob from "fast-glob"
const { glob } = fastGlob
import path from "path"
import { execa } from "execa"
async function main() {
const testFiles = await glob("./dev/docker/ci/*.yml")
const results = await Promise.all(testFiles.map(async (testFile) => {
try {
// the image name
const image = `setup-cpp-${path.basename(testFile, ".yml")}`
// check if the image exists
const imageExists = await execa("docker", ["images", "-q", image])
if (imageExists.exitCode !== 0 || imageExists.stdout.trim() === "") {
console.log(`Image ${image} does not exist`)
return 2
}
await execa("container-structure-test", ["test", "--image", image, "--config", testFile], {
stdio: "inherit",
})
return 0
} catch (error) {
console.error(error.message)
return 1
}
}))
if (results.some((result) => result === 1)) {
process.exit(1)
}
}
await main()