Skip to content

Commit 706ace9

Browse files
Validate generated reference docs in CI (#13451)
The check-doc CI step now validates generated markdown files, while a new check-reference-help step validates reference documentation files (help.txt.tmpl, help-all.txt.tmpl, config-descriptor.json, mimir-flags-defaults.json). Both checks always run outside the container. ## Why Previously, operations/mimir/mimir-flags-defaults.json wasn't validated in CI, leading to incorrect values being committed (e.g., 9223372036854776000 instead of 9223372036854775807 for max int64). The reference-help target needs to run outside the container since it executes the compiled mimir binary and config-inspector tool directly. Splitting it into a separate check makes the separation clear and allows check-doc to continue running in the container for markdown validation. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a CI step and Makefile target to validate generated reference docs, corrects gRPC keepalive max int64 defaults, updates flaky-tests ignored list, and removes redundant help/config descriptor tests. > > - **CI**: > - Add `Check Reference Help Documentation` step in `/.github/workflows/test-build-deploy.yml` running `make BUILD_IN_CONTAINER=false check-reference-help`. > - Update `/.github/workflows/flaky-tests.yml` to only ignore `TestOurUpstreamTestCasesAreInSyncWithUpstream`. > - **Build/Makefile**: > - Introduce `check-reference-help` target to verify `cmd/mimir/help.txt.tmpl`, `cmd/mimir/help-all.txt.tmpl`, `cmd/mimir/config-descriptor.json`, and `operations/mimir/mimir-flags-defaults.json` are up to date. > - **Tests**: > - Remove `TestHelp` in `cmd/mimir/main_test.go`. > - Remove `tools/config-inspector/main_test.go` (config descriptor up-to-date test). > - **Data/Fixes**: > - Correct max int64 values in `operations/mimir/mimir-flags-defaults.json` for `server.grpc.keepalive.*` defaults. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 32d5f93. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Signed-off-by: Dimitar Dimitrov <[email protected]>
1 parent 98be465 commit 706ace9

File tree

6 files changed

+16
-88
lines changed

6 files changed

+16
-88
lines changed

.github/workflows/flaky-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ jobs:
5454
time-range: "7d"
5555
top-k: "3"
5656
skip-posting-issues: ${{ github.event_name == 'workflow_dispatch' && inputs.skip-posting-issues || 'false' }}
57-
ignored-tests: "TestOurUpstreamTestCasesAreInSyncWithUpstream,TestConfigDescriptorIsUpToDate" # TestOurUpstreamTestCasesAreInSyncWithUpstream is supposed to block upstream mimir-prometheus updates, so it's also expected to fail. TestConfigDescriptorIsUpToDate is flaky.
57+
ignored-tests: "TestOurUpstreamTestCasesAreInSyncWithUpstream" # TestOurUpstreamTestCasesAreInSyncWithUpstream is supposed to block upstream mimir-prometheus updates, so it's also expected to fail.
5858
env:
5959
GITHUB_TOKEN: ${{ steps.github-token.outputs.token }}

.github/workflows/test-build-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
run: make BUILD_IN_CONTAINER=false check-protos
8080
- name: Check Generated Documentation
8181
run: make BUILD_IN_CONTAINER=false check-doc
82+
- name: Check Reference Help Documentation
83+
run: make BUILD_IN_CONTAINER=false check-reference-help
8284
- name: Check White Noise
8385
run: make BUILD_IN_CONTAINER=false check-white-noise
8486
- name: Check License Header

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ help:
1010
# WARNING: do not commit to a repository!
1111
-include Makefile.local
1212

13-
.PHONY: all test test-with-race integration-tests cover clean images protos exes dist doc clean-doc check-doc push-multiarch-build-image license check-license format check-mixin check-mixin-jb check-mixin-mixtool check-mixin-runbooks check-mixin-mimirtool-rules build-mixin format-mixin check-jsonnet-manifests format-jsonnet-manifests push-multiarch-mimir list-image-targets check-jsonnet-getting-started mixin-screenshots
13+
.PHONY: all test test-with-race integration-tests cover clean images protos exes dist doc clean-doc check-doc check-reference-help push-multiarch-build-image license check-license format check-mixin check-mixin-jb check-mixin-mixtool check-mixin-runbooks check-mixin-mimirtool-rules build-mixin format-mixin check-jsonnet-manifests format-jsonnet-manifests push-multiarch-mimir list-image-targets check-jsonnet-getting-started mixin-screenshots
1414
.DEFAULT_GOAL := all
1515

1616
# Version number
@@ -657,6 +657,15 @@ check-doc: doc
657657
@find . -name "*.md" | xargs git diff --exit-code -- \
658658
|| (echo "Please update generated documentation by running 'make doc' and committing the changes" && false)
659659

660+
check-reference-help: ## Check the reference help documentation is up to date.
661+
check-reference-help: reference-help
662+
@git diff --exit-code -- \
663+
cmd/mimir/help.txt.tmpl \
664+
cmd/mimir/help-all.txt.tmpl \
665+
cmd/mimir/config-descriptor.json \
666+
operations/mimir/mimir-flags-defaults.json \
667+
|| (echo "Please update generated reference documentation by running 'make reference-help' and committing the changes" && false)
668+
660669
# Tool is developed in the grafana/technical-documentation repository:
661670
# https://github.com/grafana/technical-documentation/tree/main/tools/doc-validator
662671
check-doc-validator: ## Check documentation using doc-validator tool

cmd/mimir/main_test.go

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -248,64 +248,6 @@ ruler_storage:
248248
}
249249
}
250250

251-
func TestHelp(t *testing.T) {
252-
for _, tc := range []struct {
253-
name string
254-
arg string
255-
filename string
256-
}{
257-
{
258-
name: "basic",
259-
arg: "-h",
260-
filename: "help.txt.tmpl",
261-
},
262-
{
263-
name: "all",
264-
arg: "-help-all",
265-
filename: "help-all.txt.tmpl",
266-
},
267-
} {
268-
t.Run(tc.name, func(t *testing.T) {
269-
oldArgs, oldStdout, oldStderr, oldTestMode, oldCmdLine := os.Args, os.Stdout, os.Stderr, testMode, flag.CommandLine
270-
restored := false
271-
restoreIfNeeded := func() {
272-
if restored {
273-
return
274-
}
275-
276-
os.Stdout = oldStdout
277-
os.Stderr = oldStderr
278-
os.Args = oldArgs
279-
testMode = oldTestMode
280-
flag.CommandLine = oldCmdLine
281-
restored = true
282-
}
283-
t.Cleanup(restoreIfNeeded)
284-
285-
testMode = true
286-
co := test.CaptureOutput(t)
287-
288-
const cmd = "./cmd/mimir/mimir"
289-
os.Args = []string{cmd, tc.arg}
290-
291-
// reset default flags
292-
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
293-
294-
main()
295-
296-
stdout, stderr := co.Done()
297-
298-
// Restore stdout and stderr before reporting errors to make them visible.
299-
restoreIfNeeded()
300-
301-
expected, err := os.ReadFile(tc.filename)
302-
require.NoError(t, err)
303-
assert.Equalf(t, string(expected), string(stdout), "%s %s output changed; try `make reference-help`", cmd, tc.arg)
304-
assert.Empty(t, stderr)
305-
})
306-
}
307-
}
308-
309251
func testSingle(t *testing.T, arguments []string, configYAML string, stdoutMessage, stderrMessage, stdoutExcluded, stderrExcluded string, assertConfig func(*testing.T, *mimir.Config)) {
310252
t.Helper()
311253
oldArgs, oldStdout, oldStderr, oldTestMode := os.Args, os.Stdout, os.Stderr, testMode

operations/mimir/mimir-flags-defaults.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"server.grpc-max-recv-msg-size-bytes": 104857600,
3636
"server.grpc-max-send-msg-size-bytes": 104857600,
3737
"server.grpc-max-concurrent-streams": 100,
38-
"server.grpc.keepalive.max-connection-idle": 9223372036854776000,
39-
"server.grpc.keepalive.max-connection-age": 9223372036854776000,
40-
"server.grpc.keepalive.max-connection-age-grace": 9223372036854776000,
38+
"server.grpc.keepalive.max-connection-idle": 9223372036854775807,
39+
"server.grpc.keepalive.max-connection-age": 9223372036854775807,
40+
"server.grpc.keepalive.max-connection-age-grace": 9223372036854775807,
4141
"server.grpc.keepalive.time": 7200000000000,
4242
"server.grpc.keepalive.timeout": 20000000000,
4343
"server.grpc.keepalive.min-time-between-pings": 10000000000,

tools/config-inspector/main_test.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)