hatchmark.yaml is at the root of the repository. Pin the action to a
release tag, so a new Hatchmark release never changes your checks under you. The action installs
the hatchmark package of the same version from npm, so the repository needs no package.json.
Keep the concurrency block: it cancels the run for an older push when a newer one starts, so one
run at a time writes the comment. The action also checks that its commit is still the pull
request’s latest before it publishes anything.
What it does
- Runs
hatchmark check. Each error and warning becomes an annotation on its file and line, so a pull request shows it in the diff. Problems in the files the pull request changed come first. - Runs
hatchmark build, which writes the pages to the project’soutDiras usual, so a later step can publish them. - On a pull request, builds the base branch’s version of the project too, and compares the two builds card by card. A chart counts as changed when its card would be drawn differently: its numbers, its spec, the row it sits in, the theme, or the project’s locale, currency and time zone.
- Renders each changed chart on both sides with
hatchmark render --block, and posts them side by side in one comment. Every later push updates the same comment instead of adding another.
The comment
The comment starts with the check and build results, then one section per changed chart with the base version on the left and the pull request’s on the right. The right side is the pull request merged into the base, as GitHub checks it out. A chart the pull request adds shows only its new version, and removed charts are listed by name. The pictures use the light theme at a 1280 px wide page, with each dashboard’s default filters. Up to 10 charts are drawn; the comment names the rest. Text blocks are not drawn. When the base branch’s version doesn’t build, the comment says so and shows the pull request’s charts without before images.Who can see the results
The images are committed to a branch namedhatchmark-renders in the same repository, which is
why the workflow needs contents: write, and the comment links to them by commit. Anyone who can
read the repository can open them, and so can anyone who can read the pull request comment. The
branch only holds images: it never merges and nothing runs on it.
Treat the images like the comment and the job summary: as part of the repository. In a public
repository, check and build sample data in files, never production data. Deleting the branch
removes it from the branch list, but images already committed can stay reachable by their links
for a while, so don’t rely on deleting it to take data back.
Several projects
Give each project its own step. Each one gets its own comment.Inputs
Both are optional.Data
The action reads the same sources ashatchmark build anywhere else. Files in the repository
just work. For a database or cloud storage source in a private repository, give the step the
environment variables that hatchmark.yaml names, from your repository’s secrets:
Pull requests from forks
GitHub gives a pull request from a fork a read-only token and no repository secrets. The action still checks and builds it, so a project whose sources are files works, while one that needs a database secret fails to build unless it has file samples. It doesn’t render, comment or store images for a fork; the results are in the job summary.The browser
Rendering needs Chrome or Chromium. GitHub-hosted Ubuntu runners have Chrome; on a self-hosted runner without one, the action downloads the Chromium headless shell once, ashatchmark render --install-browser does (render).