Pin tailwindcss and check the committed stylesheet against it (closes #231) #473

Merged
clawbot merged 2 commits from issue-231-pin-tailwind into next 2026-10-03 00:30:57 +02:00
3 changed files with 16 additions and 12 deletions
Showing only changes of commit eed24ff29c - Show all commits
+4 -4
View File
@@ -28,10 +28,10 @@ jobs:
- name: Fingerprint the build context - name: Fingerprint the build context
# Writes the hash of the commit being checked into the context, which # Writes the hash of the commit being checked into the context, which
# invalidates the `COPY . .` layer of both check stages: a commit # invalidates the `COPY . .` layer of every check stage: a commit
# that was never linted, format-checked, tested and built cannot # that was never linted, format-checked, stylesheet-checked, tested
# report success from cache. # and built cannot report success from cache.
run: git rev-parse HEAD > .ci-fingerprint run: git rev-parse HEAD > .ci-fingerprint
- name: Build Docker image (runs make fmt-check, golangci-lint, make test, make build) - name: Build Docker image (runs make fmt-check, golangci-lint, the stylesheet check, make test, make build)
run: script/cibuild run: script/cibuild
+5 -1
View File
@@ -55,8 +55,12 @@ RUN tailwindcss -i static/css/input.css -o /out/tailwind.css --minify
FROM scratch AS css-output FROM scratch AS css-output
COPY --from=css /out/tailwind.css / COPY --from=css /out/tailwind.css /
# Both files are split after each "}", one rule per line, so that when they
# differ the diff shows the rules that differ.
FROM css AS css-check FROM css AS css-check
RUN cmp /out/tailwind.css static/css/tailwind.css || { \ RUN sed 's/}/}\n/g' static/css/tailwind.css > /tmp/committed.css \
&& sed 's/}/}\n/g' /out/tailwind.css > /tmp/generated.css \
&& diff -U0 /tmp/committed.css /tmp/generated.css || { \
echo "static/css/tailwind.css is not what make css generates; run make css" >&2; \ echo "static/css/tailwind.css is not what make css generates; run make css" >&2; \
exit 1; \ exit 1; \
} }
+7 -7
View File
@@ -1398,13 +1398,13 @@ the `dist.integrity` hash listed at
## Stylesheet ## Stylesheet
`static/css/tailwind.css` is generated by Tailwind and committed. To change the `static/css/tailwind.css` is generated by Tailwind and committed. To change the
styles, edit the templates, `static/js/app.js` or `static/css/input.css`, run styles, edit the templates, `static/js/app.js`,
`make css`, and commit the regenerated file with the change. Tailwind takes `internal/handlers/recent_events.go` or `static/css/input.css`, run `make css`,
classes only from the files that `input.css` names in its `@source` lines; a and commit the regenerated file with the change. Tailwind takes classes only
class written in any other file is not generated until that file is named there from the files that `input.css` names in its `@source` lines; a class written in
too. `make check` and the image build fail when the committed file differs from any other file is not generated until that file is named there too. `make check`
what `make css` generates. `static/css/style.css` is hand-written and is not and the image build fail when the committed file differs from what `make css`
generated. generates. `static/css/style.css` is hand-written and is not generated.
`make css` runs the Tailwind standalone CLI in Docker, at the version and sha256 `make css` runs the Tailwind standalone CLI in Docker, at the version and sha256
pinned in the Dockerfile's stylesheet stages; it is never installed on the host. pinned in the Dockerfile's stylesheet stages; it is never installed on the host.