test: ?????????

pull/390/head
Michael Smith 5 months ago
parent e28138adb7
commit df53f96951

@ -16,9 +16,9 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up job - name: Check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Terraform (replace with Coder action if possible) - name: Set up Terraform (REPLACE WITH CODER ACTION WHEN DONE)
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with: with:
terraform_version: 1.9.8 terraform_version: 1.9.8
@ -29,9 +29,9 @@ jobs:
bun-version: latest bun-version: latest
- name: Install dependencies - name: Install dependencies
run: bun install run: bun install
- name: Verify that Terraform is installed - name: Verify that Terraform is installed (REMOVE WHEN DONE)
run: which terraform run: which terraform
- name: Verify that Node.js is installed - name: Verify that Node.js is installed (REMOVE WHEN DONE)
run: which node run: which node
- name: Run tests - name: Run tests
run: bun test run: bun test

@ -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;

@ -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 combinedEnv: Record<string, string | undefined> = {
...process.env,
...(customEnv ?? {}),
};
for (const [key, value] of Object.entries(vars)) { for (const [key, value] of Object.entries(vars)) {
combinedEnv[`TF_VAR_${key}`] = String(value); if (value !== null) {
combinedEnv[`TF_VAR_${key}`] = String(value);
}
} }
const proc = spawn( const proc = spawn(

Loading…
Cancel
Save