Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
- "github-action/action.yml"
- "src/**"
- "tests/**"
- "e2e/**"
- "package.json"
- "pnpm-lock.yaml"
- "tsconfig.json"
Expand Down
50 changes: 38 additions & 12 deletions e2e/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'reflect-metadata';
import { execSync, spawn } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { rm, unlink } from 'node:fs/promises';
import { rm, unlink, writeFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
Expand Down Expand Up @@ -40,25 +40,47 @@ const LOWKEY_VAULT_IMAGE = 'nagyesta/lowkey-vault:7.1.32';
const LOWKEY_VAULT_PORT = 8443;

describe('Envilder (E2E)', () => {
beforeAll(async () => {
await cleanUpSystem();
execSync('pnpm build', { cwd: rootDir, stdio: 'inherit' });
execSync('node --loader ts-node/esm scripts/pack-and-install.ts', {
cwd: rootDir,
stdio: 'inherit',
});
}, 60_000);
// Unique ID per test run prevents race conditions between concurrent CI runs
const runId = randomUUID().slice(0, 8);
const ssmPrefix = `/Test/${runId}`;

const envilder = 'envilder';
const envFilePath = join(rootDir, 'e2e', 'sample', 'cli-validation.env');
const mapFilePath = join(rootDir, 'e2e', 'sample', 'param-map.json');
const mapFilePath = join(rootDir, 'e2e', 'sample', `param-map-${runId}.json`);
const mapFileWithConfigPath = join(
rootDir,
'e2e',
'sample',
'param-map-with-aws-config.json',
`param-map-with-aws-config-${runId}.json`,
);
const singleSsmPath = '/Test/SingleVariable';
const singleSsmPath = `${ssmPrefix}/SingleVariable`;

beforeAll(async () => {
await Promise.all([
writeFile(
mapFilePath,
JSON.stringify({ TOKEN_SECRET: `${ssmPrefix}/Token` }, null, 2),
),
writeFile(
mapFileWithConfigPath,
JSON.stringify(
{
$config: { provider: 'aws' },
TOKEN_SECRET: `${ssmPrefix}/Token`,
},
null,
2,
),
),
]);

await cleanUpSystem();
execSync('pnpm build', { cwd: rootDir, stdio: 'inherit' });
execSync('node --loader ts-node/esm scripts/pack-and-install.ts', {
cwd: rootDir,
stdio: 'inherit',
});
}, 60_000);

beforeEach(async () => {
await cleanUpSsm(mapFilePath, singleSsmPath);
Expand All @@ -72,6 +94,10 @@ describe('Envilder (E2E)', () => {

afterAll(async () => {
await cleanUpSystem();
await Promise.all([
rm(mapFilePath, { force: true }),
rm(mapFileWithConfigPath, { force: true }),
]);
}, 60_000);

it('Should_PrintCorrectVersion_When_VersionFlagIsProvided', async () => {
Expand Down
Loading