mirror of
https://github.com/coder/coder.git
synced 2026-06-04 05:28:20 +00:00
5f4ff58f84
Using `go run` inside of a test is fragile, because it means we have to wait for `go` to compile the binary while also constrained on resources by the fact that Playwright and coderd are already running. We should instead compile a coder binary for the current platform before the tests and use it directly.
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { execSync } from "node:child_process";
|
|
import * as path from "node:path";
|
|
|
|
export default function () {
|
|
// If running terraform tests, verify the requirements exist in the
|
|
// environment.
|
|
//
|
|
// These execs will throw an error if the status code is non-zero.
|
|
// So if both these work, then we can launch terraform provisioners.
|
|
let hasTerraform = false;
|
|
let hasDocker = false;
|
|
try {
|
|
execSync("terraform --version");
|
|
hasTerraform = true;
|
|
} catch {
|
|
/* empty */
|
|
}
|
|
|
|
try {
|
|
execSync("docker --version");
|
|
hasDocker = true;
|
|
} catch {
|
|
/* empty */
|
|
}
|
|
|
|
if (!hasTerraform || !hasDocker) {
|
|
const msg = `Terraform provisioners require docker & terraform binaries to function. \n${
|
|
hasTerraform
|
|
? ""
|
|
: "\tThe `terraform` executable is not present in the runtime environment.\n"
|
|
}${
|
|
hasDocker
|
|
? ""
|
|
: "\tThe `docker` executable is not present in the runtime environment.\n"
|
|
}`;
|
|
throw new Error(msg);
|
|
}
|
|
|
|
if (!process.env.CI) {
|
|
console.info("==> make site/e2e/bin/coder");
|
|
execSync("make site/e2e/bin/coder", {
|
|
cwd: path.join(__dirname, "../../../"),
|
|
});
|
|
}
|
|
}
|