Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DroneCI pipeline stage to validate loki example configs; create example configuration files #4358

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ local manifest(apps) = pipeline('manifest') {
image: 'koalaman/shellcheck-alpine:stable',
commands: ['apk add make bash && make lint-scripts'],
},
make('loki', container=false) { depends_on: ['clone'] },
make('validate-example-configs', container=false) { depends_on: ['loki'] },
make('check-example-config-doc', container=false) { depends_on: ['clone'] },
],
},
] + [
Expand Down
23 changes: 22 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ steps:
commands:
- apk add make bash && make lint-scripts

- name: loki
image: grafana/loki-build-image:0.17.0
commands:
- make BUILD_IN_CONTAINER=false loki
depends_on:
- clone

- name: validate-example-configs
image: grafana/loki-build-image:0.17.0
commands:
- make BUILD_IN_CONTAINER=false validate-example-configs
depends_on:
- loki

- name: check-example-config-doc
image: grafana/loki-build-image:0.17.0
commands:
- make BUILD_IN_CONTAINER=false check-example-config-doc
depends_on:
- clone

---
kind: pipeline
name: docker-amd64
Expand Down Expand Up @@ -973,6 +994,6 @@ get:

---
kind: signature
hmac: b70be41d1a7f91c11af945a34bdbdc7a4f7613cf830c13f5438dba0bf33a1ec5
hmac: f1681daaa15376eb15eae5dd623a3ec19544b0447506aba2d59a92f0fd8fee49

...
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.PHONY: bigtable-backup, push-bigtable-backup
.PHONY: benchmark-store, drone, check-mod
.PHONY: migrate migrate-image lint-markdown ragel
.PHONY: validate-example-configs generate-example-config-doc check-example-config-doc

SHELL = /usr/bin/env bash

Expand Down Expand Up @@ -635,3 +636,30 @@ format:
-type f -name '*.go' -exec gofmt -w -s {} \;
find . $(DONT_FIND) -name '*.pb.go' -prune -o -name '*.y.go' -prune -o -name '*.rl.go' -prune -o \
-type f -name '*.go' -exec goimports -w -local github.com/grafana/loki {} \;

###################
# Example Configs #
###################

# Validate the example configurations that we provide in ./docs/sources/configuration/examples
validate-example-configs: loki
for f in ./docs/sources/configuration/examples/*.yaml; do echo "Validating provided example config: $$f" && ./cmd/loki/loki -config.file=$$f -verify-config || exit 1; done
owen-d marked this conversation as resolved.
Show resolved Hide resolved

# Dynamically generate ./docs/sources/configuration/examples.md using the example configs that we provide.
# This target should be run if any of our example configs change.
generate-example-config-doc:
echo "Removing existing doc at loki/docs/configuration/examples.md and re-generating. . ."
# Title and Heading
echo -e "---\ntitle: Examples\n---\n # Loki Configuration Examples" > ./docs/sources/configuration/examples.md
# Append each configuration and its file name to examples.md
for f in ./docs/sources/configuration/examples/*.yaml; do echo -e "\n## $$(basename $$f)\n\n\`\`\`yaml\n$$(cat $$f)\n\`\`\`\n" >> ./docs/sources/configuration/examples.md; done

# Fail our CI build if changes are made to example configurations but our doc is not updated
check-example-config-doc: generate-example-config-doc
@if ! (git diff --exit-code ./docs/sources/configuration/examples.md); then \
echo -e "\nChanges found in generated example configuration doc"; \
echo "Run 'make generate-example-config-doc' and commit the changes to fix this error."; \
echo "If you are actively developing these files you can ignore this error"; \
echo -e "(Don't forget to check in the generated files when finished)\n"; \
exit 1; \
fi
Loading