The workflow ran everything in one job: check.sh, then build, then the e2e suite and the smokes. The runner has two job slots and four cores, so the second slot lay idle for the whole run, and a lint error was reported only after the full suite had passed in front of it - six minutes instead of one. Now `gate` and `suite` are two jobs without `needs:`. They start together, both have to pass. The price is contention: while the gate runs, vitest and chromium share four cores, and the suite measures text widths and frame counts, which a loaded machine reports differently. The gate therefore caps vitest at two workers via GM_TEST_WORKERS, so two cores stay free for the browser over the whole overlap. Locally the variable is unset and nothing changes. Measured before the push: the cap costs vitest 4.4s (16.6s -> 21.0s), check.sh exits 0 with it, build ok. Whether the split is worth it is a question for the runner - the expected net gain is about 50s, and the acceptance is a measurement over at least two runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { copyFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { defineConfig, type Plugin } from 'vite';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
/**
|
|
* The workspace folder itself is what nginx serves under https://nockal.com/game-maker/.
|
|
* The Vite source page lives in `web/index.html`; the build writes hashed assets into
|
|
* `dist/` and this plugin copies the built HTML to the folder root so that the site URL
|
|
* loads the production bundle while `api/` and `data/` sit next to it.
|
|
*/
|
|
function publishIndexHtml(): Plugin {
|
|
return {
|
|
name: 'game-maker:publish-index-html',
|
|
apply: 'build',
|
|
closeBundle() {
|
|
copyFileSync(resolve(__dirname, 'dist/index.html'), resolve(__dirname, 'index.html'));
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
root: 'web',
|
|
base: '/game-maker/dist/',
|
|
publicDir: false,
|
|
plugins: [publishIndexHtml()],
|
|
build: {
|
|
outDir: '../dist',
|
|
emptyOutDir: true,
|
|
target: 'es2022',
|
|
sourcemap: true,
|
|
},
|
|
server: {
|
|
port: 5175,
|
|
// During development the PHP API is served by the production nginx; proxy it.
|
|
proxy: {
|
|
'/game-maker/api': {
|
|
target: 'https://nockal.com',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
root: '.',
|
|
include: ['tests/**/*.test.ts'],
|
|
environment: 'node',
|
|
// Unset locally, so vitest keeps its own guess (one worker per core). CI sets it while the
|
|
// gate runs next to the editor suite: the two jobs share four cores, and the suite measures
|
|
// text widths and frame counts, which a machine under full load reports differently.
|
|
maxWorkers: Number(process.env.GM_TEST_WORKERS) || undefined,
|
|
},
|
|
});
|