From 9a97564b7ccd691d5db25d2e081c45ab5b83fb31 Mon Sep 17 00:00:00 2001 From: Adrian Hesketh Date: Fri, 27 Dec 2024 12:04:26 +0000 Subject: [PATCH] docs: document committing templ files, fixes #1007 --- docs/docs/09-developer-tools/06-cicd.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/docs/09-developer-tools/06-cicd.md diff --git a/docs/docs/09-developer-tools/06-cicd.md b/docs/docs/09-developer-tools/06-cicd.md new file mode 100644 index 00000000..2aa131d4 --- /dev/null +++ b/docs/docs/09-developer-tools/06-cicd.md @@ -0,0 +1,12 @@ +# Ensuring templ files have been committed + +It's common practice to commit generated `*_templ.go` files to your source code repository, so that your codebase is always in a state where it can be built and run without needing to run `templ generate`, e.g. by running `go install` on your project, or by importing it as a dependency in another project. + +In your CI/CD pipeline, if you want to check that `templ generate` has been ran on all templ files (with the same version of templ used by the CI/CD pipeline), you can run `templ generate` again. + +If any files have changed, then the pipeline should fail, as this would indicate that the generated files are not up-to-date with the templ files. + +```bash +templ generate +git diff --exit-code +```