-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvitest.global-setup.ts
More file actions
32 lines (29 loc) · 1.04 KB
/
vitest.global-setup.ts
File metadata and controls
32 lines (29 loc) · 1.04 KB
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
import { execSync } from 'node:child_process';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
/**
* Global setup for Vitest - runs once before all tests (separate process).
* - Local: generates .env via envilder if missing, then builds GHA bundle.
* - CI: secrets come from GitHub Actions environment, skips envilder call.
*/
export async function setup() {
const isCI = process.env.CI === 'true';
if (!isCI) {
const envFilePath = resolve(process.cwd(), '.env');
if (!existsSync(envFilePath)) {
console.log('⚙️ .env not found — fetching secrets via envilder...');
execSync('pnpx envilder --map=secrets-map.json --envfile=.env', {
cwd: process.cwd(),
stdio: 'inherit',
});
}
}
console.log('🏗️ Building GitHub Action bundle...');
try {
execSync('pnpm build:gha', { stdio: 'inherit' });
console.log('✅ GitHub Action bundle built successfully');
} catch (error) {
console.error('❌ Failed to build GitHub Action bundle:', error);
throw error;
}
}