Merge branch 'main' into intendedlinks
This commit is contained in:
19
.github/workflows/ci.yaml
vendored
19
.github/workflows/ci.yaml
vendored
@@ -16,14 +16,23 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Check out code
|
||||||
- uses: coder/coder/.github/actions/setup-tf@main
|
uses: actions/checkout@v4
|
||||||
- uses: oven-sh/setup-bun@v2
|
- name: Set up Terraform
|
||||||
|
uses: coder/coder/.github/actions/setup-tf@main
|
||||||
|
- name: Set up Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
|
# We're using the latest version of Bun for now, but it might be worth
|
||||||
|
# reconsidering. They've pushed breaking changes in patch releases
|
||||||
|
# that have broken our CI.
|
||||||
|
# Our PR where issues started to pop up: https://github.com/coder/modules/pull/383
|
||||||
|
# The Bun PR that broke things: https://github.com/oven-sh/bun/pull/16067
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
- name: Setup
|
- name: Install dependencies
|
||||||
run: bun install
|
run: bun install
|
||||||
- run: bun test
|
- name: Run tests
|
||||||
|
run: bun test
|
||||||
pretty:
|
pretty:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
2
setup.ts
2
setup.ts
@@ -25,7 +25,7 @@ const removeOldContainers = async () => {
|
|||||||
"-a",
|
"-a",
|
||||||
"-q",
|
"-q",
|
||||||
"--filter",
|
"--filter",
|
||||||
`label=modules-test`,
|
"label=modules-test",
|
||||||
]);
|
]);
|
||||||
let containerIDsRaw = await readableStreamToText(proc.stdout);
|
let containerIDsRaw = await readableStreamToText(proc.stdout);
|
||||||
let exitCode = await proc.exited;
|
let exitCode = await proc.exited;
|
||||||
|
|||||||
15
test.ts
15
test.ts
@@ -194,13 +194,18 @@ export const testRequiredVariables = <TVars extends TerraformVariables>(
|
|||||||
export const runTerraformApply = async <TVars extends TerraformVariables>(
|
export const runTerraformApply = async <TVars extends TerraformVariables>(
|
||||||
dir: string,
|
dir: string,
|
||||||
vars: Readonly<TVars>,
|
vars: Readonly<TVars>,
|
||||||
env?: Record<string, string>,
|
customEnv?: Record<string, string>,
|
||||||
): Promise<TerraformState> => {
|
): Promise<TerraformState> => {
|
||||||
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
|
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
|
||||||
|
|
||||||
const combinedEnv = env === undefined ? {} : { ...env };
|
const childEnv: Record<string, string | undefined> = {
|
||||||
for (const [key, value] of Object.entries(vars)) {
|
...process.env,
|
||||||
combinedEnv[`TF_VAR_${key}`] = String(value);
|
...(customEnv ?? {}),
|
||||||
|
};
|
||||||
|
for (const [key, value] of Object.entries(vars) as [string, JsonValue][]) {
|
||||||
|
if (value !== null) {
|
||||||
|
childEnv[`TF_VAR_${key}`] = String(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const proc = spawn(
|
const proc = spawn(
|
||||||
@@ -216,7 +221,7 @@ export const runTerraformApply = async <TVars extends TerraformVariables>(
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
cwd: dir,
|
cwd: dir,
|
||||||
env: combinedEnv,
|
env: childEnv,
|
||||||
stderr: "pipe",
|
stderr: "pipe",
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user