From 54bdcba11fb1123b232cec9468f648c8b9b64ef2 Mon Sep 17 00:00:00 2001 From: Micah Villmow <4211002+mvillmow@users.noreply.github.com> Date: Tue, 12 May 2026 17:20:41 -0700 Subject: [PATCH] ci: add promtail config validation step (#193) Adds a CI step that runs `promtail -check-syntax` against configs/promtail.yml using the same image version pinned in docker-compose.yml. Mirrors the validation as a `just validate-promtail` recipe and chains it into the existing `just validate` target so local runs catch syntax regressions before push. Closes #193 Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/ci.yml | 14 ++++++++++++++ justfile | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 746a67c..6e8a468 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,20 @@ jobs: rules/atlas-alerts.yml \ docker-compose.yml + - name: Validate Promtail config syntax + run: | + # Run promtail -check-syntax against the committed config inside + # the same image used by the compose stack. The config references + # env vars; promtail expands them at parse time when + # -config.expand-env=true, with missing vars resolving to an empty + # string — fine for a syntax-only check. + docker run --rm \ + -v "$PWD/configs/promtail.yml:/etc/promtail/promtail.yml:ro" \ + grafana/promtail:3.1.2 \ + -config.file=/etc/promtail/promtail.yml \ + -config.expand-env=true \ + -check-syntax + - name: Validate Grafana dashboard JSON run: | for f in dashboards/*.json; do diff --git a/justfile b/justfile index 9566cab..9327877 100644 --- a/justfile +++ b/justfile @@ -78,7 +78,7 @@ clean: {{compose_cmd}} down -v # Validate docker-compose config, YAML files, and required runtime files -validate: check-env-example +validate: check-env-example validate-promtail #!/usr/bin/env bash set -euo pipefail {{compose_cmd}} config --quiet @@ -93,6 +93,17 @@ validate: check-env-example check-env-example: @bash scripts/check-env-example.sh +# Validate promtail config syntax via the official image's -check-syntax +validate-promtail: + @echo "Validating configs/promtail.yml ..." + {{container_cmd}} run --rm \ + -v "$(pwd)/configs/promtail.yml:/etc/promtail/promtail.yml:ro" \ + grafana/promtail:3.1.2 \ + -config.file=/etc/promtail/promtail.yml \ + -config.expand-env=true \ + -check-syntax + @echo "promtail config OK." + # Hot-reload dev loop for the dashboard (templ generate --watch + air in parallel) dev: @command -v templ >/dev/null 2>&1 || { echo "templ not found on PATH. Install: go install github.com/a-h/templ/cmd/templ@v0.3.1001"; exit 1; }