针对 CSS 完整性、计算的样式、视觉回退和安全的 Docker 升级提供了发布门槛。
English is the default project language. 简体中文 · v0.3.0 notes · Launch article
Frontend Promotion Guard (FPG) is a reusable release gate for failures that ordinary health checks miss: the build succeeds, HTTP returns 200, and the container is healthy, while production CSS or layout is broken.
FPG audits emitted CSS, evaluates real browser-computed styles, compares screenshots across routes and viewports, accepts an isolated candidate container, promotes only after acceptance, and restores the previous image when production re-verification fails. Every run produces a static HTML evidence report.
FPG does not replace functional testing, security testing, or human acceptance. A human must confirm a correct page before explicitly updating visual baselines.
FPG is not a mandatory deployment step after every frontend edit. Choose the level by the current objective:
| Level | When to run | Command and boundary |
|---|---|---|
| Targeted check | One feature or defect is still being implemented | Use the project's focused test first. Run fpg audit only when emitted CSS is the risk. It does not start browsers, build images, restart services, or inspect unrelated routes. |
| Module gate | A related batch is ready on an already running target | Run fpg verify for the configured routes and viewports. It observes the target but does not build images, restart services, or promote a release. |
| Release gate | A deployment or release was explicitly requested, the deployed environment is required for acceptance, or an agreed release checkpoint was reached | Run fpg promote. This command builds or starts the candidate, mutates container state after acceptance, re-verifies production, and may roll back. |
A passing FPG report proves only the configured release checks. It does not prove that the feature's business behavior is complete. Finish the targeted business flow before escalating to a broader gate, and run a shared gate once per agreed batch rather than once per checklist item.
These two screenshots show the kind of release that can pass a build, return HTTP 200, and still be visibly wrong. The first page has lost its intended layout and controls; the second is the same area after the frontend assets are served correctly.
| Broken after release | Correct rendering |
|---|---|
The images are illustrative incident evidence, not visual baselines for this repository. FPG catches the underlying class of failure with CSS checks, computed-style assertions, and screenshot comparison before promotion.
Node.js 20+ and a system Chrome or Edge are required. Docker is optional unless promote or rollback is used.
npm install
npm run build
cp fpg.example.yml fpg.yml
node dist/cli.js audit --config fpg.yml
node dist/cli.js baseline update --config fpg.yml
node dist/cli.js verify --config fpg.ymlPowerShell:
.\scripts\fpg.ps1 verify --config .\fpg.ymlSet browserPath or FPG_BROWSER_PATH to override system browser discovery. Relative paths resolve from the YAML file. Routes, selectors, viewports, thresholds, evidence and baseline directories, retention, image names, ports, container names, and Docker arguments are configurable; see fpg.example.yml.
audit, capture, compare, verify, baseline update, promote, rollback IMAGE, and report are available. Only baseline update writes baselines. A failed test never replaces them.
The HTML report includes baseline, current, and diff images, immutable image IDs, Git commit, runtime and browser versions, stage timings, test results, final production state, and rollback state. External commands are spawned with argument arrays rather than shell strings. Common Cookie, Authorization, token, API key, password, and secret patterns are redacted from command output; configuration files must still contain no secrets.
Configuration is validated before a browser or Docker operation starts. Set docker.requireImmutableImage: true to require a digest or image ID for an existing candidate and explicit rollback. FPG records the resolved candidate, previous production, and final production image IDs even when ordinary tags are used.
promote and rollback share a repository-local release lock. Concurrent release operations fail with the lock owner's PID, start time, and commit. CI workflows should also use native workflow concurrency because a local lock cannot coordinate separate runners.
- uses: Reality_JH/[email protected]
with:
config: fpg.yml
command: verify
- if: always()
uses: actions/upload-artifact@v4
with:
name: frontend-promotion-evidence
path: release-evidenceBuild and start the target before this step. See .github/workflows/example.yml for a runnable Vite/React example and .github/workflows/matrix.yml for the cross-platform matrix.
The Action defaults to the non-mutating verify command. A release workflow that intentionally uses command: promote must also set confirm-promotion: true; ordinary pull-request and feature workflows should not set it.
Maintainer: Reality_JH. Use repository Issues for ordinary questions. Report security issues to [email protected]; do not include credentials, cookies, tokens, or business data in public issues.
npm run license:checkEvery push and pull request scans production dependency licenses and runs the npm production vulnerability audit at high severity. The allowlist and license record are documented in THIRD_PARTY_LICENSES.md.
.github/workflows/matrix.yml runs Node 20 and 22 browser, test, and license checks on Ubuntu, Windows, and macOS. Its Ubuntu Docker job executes four end-to-end scenarios: successful promotion, candidate rejection without production mutation, production failure with verified restoration, and rollback verification failure. Every scenario asserts the final production container image ID.
baseline update writes visual-baselines/manifest.json with a SHA-256 digest for every approved image. The GitHub Action intentionally does not allow baseline updates. Update baselines locally, review the old image, current image, and diff, then commit image and manifest changes through a pull request. Pin the runner OS, browser major version, and fonts when pixel stability matters.
npm run typecheck
npm run build
npm test
npm run example:buildThe locked dependency license audit is in THIRD_PARTY_LICENSES.md. This project is MIT licensed.
暂无开放 Issues,或尚未同步最近议题。