## Summary **CI: Main-branch Argos baselines** - Run storybook build + screenshot capture on `push` to `main` in CI UI workflow - Add `dispatch-main` job in visual regression dispatch to forward main-branch screenshots to ci-privileged - Simplify `dispatch-pr` by inlining the artifact name and removing unused `project` output **Local visual diff support** - Add `scripts/visual-diff.sh` for running Argos uploads locally via tunnel - Add `storybook:visual-diff` Nx target wrapping the script (depends on `storybook:build`) - Honor `STORYBOOK_URL` env in `vitest.config.ts` to reuse pre-served static builds (mirrors twenty-front pattern) - Support `ARGOS_BUILD_NAME`, `ARGOS_REFERENCE_BRANCH` env overrides in vitest plugin config ## Context Argos builds on PRs are all "Orphan" because there's no reference build on `main` to compare against. The CI changes add the missing piece: every merge to main now produces screenshots and uploads them to Argos as reference builds. The local visual diff script enables developers to run visual regression checks from their machine against the self-hosted Argos instance via `kubectl port-forward` (set up by the twenty-infra `argos-tunnel` command). ## Related - twentyhq/twenty-argos#1 (backend config for self-hosted HTTPS redirect) - twentyhq/twenty-infra#709 (argos-tunnel super CLI command + self-hosted mode) ## Test plan - [ ] Verify CI UI runs on next push to main and produces the `argos-screenshots-twenty-ui` artifact - [ ] Verify `dispatch-main` triggers and uploads screenshots to Argos - [ ] Verify subsequent PR builds show diffs against the main baseline instead of "Orphan" - [ ] Run `ARGOS_TOKEN=<token> npx nx storybook:visual-diff twenty-ui` locally with tunnel active
39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
if [[ -f "$SCRIPT_DIR/.env" ]]; then
|
||
set -a
|
||
source "$SCRIPT_DIR/.env"
|
||
set +a
|
||
fi
|
||
|
||
ARGOS_API_BASE_URL="${ARGOS_API_BASE_URL:-http://127.0.0.1:4002/v2/}"
|
||
ARGOS_TOKEN="${ARGOS_TOKEN:?ARGOS_TOKEN is required – set it in packages/twenty-ui/.env}"
|
||
|
||
USERNAME=$(whoami)
|
||
BRANCH="${ARGOS_BRANCH:-$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")}"
|
||
COMMIT="${ARGOS_COMMIT:-$(git rev-parse HEAD 2>/dev/null || echo "unknown")}"
|
||
|
||
export ARGOS_API_BASE_URL
|
||
export ARGOS_TOKEN
|
||
export ARGOS_BUILD_NAME="${USERNAME}/twenty-ui"
|
||
export ARGOS_BRANCH="$BRANCH"
|
||
export ARGOS_COMMIT="$COMMIT"
|
||
|
||
echo "Argos visual diff"
|
||
echo " API: $ARGOS_API_BASE_URL"
|
||
echo " Build name: $ARGOS_BUILD_NAME"
|
||
echo " Branch: $ARGOS_BRANCH"
|
||
echo " Commit: ${ARGOS_COMMIT:0:12}"
|
||
echo ""
|
||
|
||
npx http-server storybook-static --port 6007 --silent &
|
||
HTTP_PID=$!
|
||
trap "kill $HTTP_PID 2>/dev/null || true" EXIT
|
||
|
||
for i in $(seq 1 30); do curl -sf http://localhost:6007 > /dev/null 2>&1 && break; sleep 1; done
|
||
|
||
export STORYBOOK_URL="http://localhost:6007"
|
||
npx vitest run
|