Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
93 lines
2.9 KiB
JavaScript
93 lines
2.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import path from 'node:path';
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
const serverDir = path.join(repoRoot, 'server');
|
|
const nextConfigPath = path.join(serverDir, 'next.config.mjs');
|
|
|
|
const WORKFLOWS_ENTRY = '@alga-psa/workflows/entry';
|
|
|
|
async function runWithEnv(env, fn) {
|
|
const original = { ...process.env };
|
|
try {
|
|
for (const [key, value] of Object.entries(env)) {
|
|
process.env[key] = value;
|
|
}
|
|
return await fn();
|
|
} finally {
|
|
for (const key of Object.keys(process.env)) {
|
|
if (!(key in original)) {
|
|
delete process.env[key];
|
|
}
|
|
}
|
|
for (const [key, value] of Object.entries(original)) {
|
|
process.env[key] = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
async function loadNextConfigFresh() {
|
|
const href = `${pathToFileURL(nextConfigPath).href}?cachebust=${Date.now()}-${Math.random()}`;
|
|
const mod = await import(href);
|
|
return mod.default;
|
|
}
|
|
|
|
function applyWebpackConfig(nextConfig, envLabel) {
|
|
assert.equal(typeof nextConfig.webpack, 'function', `${envLabel}: next.config.mjs missing webpack() export`);
|
|
|
|
const config = {
|
|
resolve: { alias: {}, modules: ['node_modules'], extensionAlias: {}, fallback: {} },
|
|
plugins: [],
|
|
externals: [],
|
|
module: { rules: [] },
|
|
output: { path: path.join(serverDir, '.next'), webassemblyModuleFilename: '' },
|
|
};
|
|
|
|
const result = nextConfig.webpack(config, { isServer: true, dev: false });
|
|
return result ?? config;
|
|
}
|
|
|
|
function assertAlias(config, expected, envLabel) {
|
|
const actual = config?.turbopack?.resolveAlias?.[WORKFLOWS_ENTRY];
|
|
assert.equal(
|
|
actual,
|
|
expected,
|
|
`${envLabel}: turbopack.resolveAlias[${WORKFLOWS_ENTRY}] expected ${expected}, got ${actual}`
|
|
);
|
|
}
|
|
|
|
function assertWebpackAlias(webpackConfig, expected, envLabel) {
|
|
const actual = webpackConfig?.resolve?.alias?.[WORKFLOWS_ENTRY];
|
|
assert.equal(
|
|
actual,
|
|
expected,
|
|
`${envLabel}: webpack resolve.alias[${WORKFLOWS_ENTRY}] expected ${expected}, got ${actual}`
|
|
);
|
|
}
|
|
|
|
await runWithEnv({ EDITION: 'enterprise', NEXT_PUBLIC_EDITION: 'enterprise' }, async () => {
|
|
const eeConfig = await loadNextConfigFresh();
|
|
assertAlias(eeConfig, '../ee/server/src/workflows/entry', 'EE');
|
|
assertWebpackAlias(
|
|
applyWebpackConfig(eeConfig, 'EE'),
|
|
path.join(serverDir, '../ee/server/src/workflows/entry.tsx'),
|
|
'EE'
|
|
);
|
|
});
|
|
|
|
await runWithEnv({ EDITION: 'community', NEXT_PUBLIC_EDITION: 'community' }, async () => {
|
|
const ceConfig = await loadNextConfigFresh();
|
|
assertAlias(ceConfig, './src/empty/workflows/entry', 'CE');
|
|
assertWebpackAlias(
|
|
applyWebpackConfig(ceConfig, 'CE'),
|
|
path.join(serverDir, 'src/empty/workflows/entry.tsx'),
|
|
'CE'
|
|
);
|
|
});
|
|
|
|
console.log('[guard-workflows-entry-edition-selection] OK: env-driven workflows entry alias selection is deterministic');
|