a7fed47932
## Summary - **Username-prefix branches**: Local visual-diff builds now use `charles/main` instead of `main` as the branch name, preventing local runs from creating auto-approved reference builds that could overwrite CI baselines. - **Local merge-base computation**: Computes `ARGOS_REFERENCE_COMMIT` via `git merge-base HEAD main` locally, so the Argos SDK skips `git fetch origin <branch>` — fixing the "fatal: couldn't find remote ref" error when running from non-pushed branches. - **Pass `referenceCommit` to vitest plugin**: Ensures the locally computed merge-base is forwarded to the Argos upload. ## Test plan - [x] Verified local visual-diff works from `main` branch (branch becomes `charles/main`, not auto-approved) - [x] Verified local visual-diff works from a non-pushed branch (`test/local-only-visual-diff` → build uploaded successfully)
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { argosVitestPlugin } from '@argos-ci/storybook/vitest-plugin';
|
|
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
const MINUTES_IN_MS = 60 * 1000;
|
|
|
|
const dirname =
|
|
typeof __dirname !== 'undefined'
|
|
? __dirname
|
|
: path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
projects: [
|
|
{
|
|
extends: './vite.config.ts',
|
|
plugins: [
|
|
storybookTest({
|
|
configDir: path.join(dirname, '.storybook'),
|
|
...(process.env.STORYBOOK_URL
|
|
? { storybookUrl: process.env.STORYBOOK_URL }
|
|
: { storybookScript: 'yarn storybook --no-open --port 6007' }),
|
|
}),
|
|
argosVitestPlugin({
|
|
uploadToArgos: !!process.env.ARGOS_TOKEN,
|
|
token: process.env.ARGOS_TOKEN,
|
|
apiBaseUrl: process.env.ARGOS_API_BASE_URL,
|
|
buildName: process.env.ARGOS_BUILD_NAME || undefined,
|
|
branch: process.env.ARGOS_BRANCH || undefined,
|
|
commit: process.env.ARGOS_COMMIT || undefined,
|
|
referenceCommit: process.env.ARGOS_REFERENCE_COMMIT || undefined,
|
|
}),
|
|
],
|
|
test: {
|
|
name: 'storybook',
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright({}),
|
|
instances: [{ browser: 'chromium' }],
|
|
},
|
|
setupFiles: ['./.storybook/vitest.setup.ts'],
|
|
testTimeout: 5 * MINUTES_IN_MS,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|