Skip to content

test: render sloth_version golden label with YAML-correct quoting#826

Open
robbat2 wants to merge 1 commit into
slok:mainfrom
coreweave:rjohnson/upstream-numeric-version-fix
Open

test: render sloth_version golden label with YAML-correct quoting#826
robbat2 wants to merge 1 commit into
slok:mainfrom
coreweave:rjohnson/upstream-numeric-version-fix

Conversation

@robbat2

@robbat2 robbat2 commented Jun 7, 2026

Copy link
Copy Markdown

The Prometheus generate integration tests and the library use-case tests both substitute the build version (from git describe --tags --always) into shared golden .tpl files. When no tag is reachable that resolves to the bare short git SHA, which is all decimal digits ~3.7% of the time (e.g. 6950793). Sloth's YAML serializers quote such a value ("6950793") so it round-trips as a string, but the templates emitted it unquoted, so the assertion failed only on those commits.

Add a shared yamlValue template helper (testutils.GoldenTemplateFuncs) that marshals the version through yaml.v2 — matching both the Prometheus and k8s serializers — and use it for the sloth_version label from both test consumers. The comment line stays raw. The tests now pass for numeric SHAs, hex SHAs, and semver-style versions alike.

The Prometheus generate integration tests and the library use-case tests both
substitute the build version (from `git describe --tags --always`) into shared
golden .tpl files. When no tag is reachable that resolves to the bare short git
SHA, which is all decimal digits ~3.7% of the time (e.g. 6950793). Sloth's YAML
serializers quote such a value ("6950793") so it round-trips as a string, but
the templates emitted it unquoted, so the assertion failed only on those
commits.

Add a shared `yamlValue` template helper (testutils.GoldenTemplateFuncs) that
marshals the version through yaml.v2 — matching both the Prometheus and k8s
serializers — and use it for the sloth_version label from both test consumers.
The comment line stays raw. The tests now pass for numeric SHAs, hex SHAs, and
semver-style versions alike.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@robbat2 robbat2 requested a review from slok as a code owner June 7, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant