Skip to content

[release-1.23] fix: source func CLI version from build ldflags - #4030

Merged
knative-prow[bot] merged 2 commits into
knative:release-1.23from
knative-prow-robot:cherry-pick-4029-to-release-1.23
Sep 1, 2026
Merged

[release-1.23] fix: source func CLI version from build ldflags#4030
knative-prow[bot] merged 2 commits into
knative:release-1.23from
knative-prow-robot:cherry-pick-4029-to-release-1.23

Conversation

@knative-prow-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #4029

`func config ci` now sources the func CLI version used in generated GitHub Actions workflows from the binary's build-time version (set via ldflags), instead of a hardcoded string. Dev builds between releases emit the nearest real release tag by stripping the git describe suffix.

/kind bug

@knative-prow knative-prow Bot added the kind/bug Bugs label Sep 1, 2026
@knative-prow knative-prow Bot added the size/S 🤖 PR changes 10-29 lines, ignoring generated files. label Sep 1, 2026
@matejvasek

Copy link
Copy Markdown
Contributor

Note: this analysis was generated by an AI assistant (Claude).

Why CI is failing

The real failure is the Prow check unit-tests_func_release-1.23. The other red checks are unrelated infra/flakes (see below).

Root cause

TestNewConfigCICmd_WritesWorkflowFileToFSWithCorrectYAMLStructure (cmd/config_ci_int_test.go:86) fails:

assertion failed: missing 'version: knative-v1.23.0' in:
   ...
   version: knative-v1.23.1

The test asserts the generated workflow contains version: + github.DefaultFuncCliVersion (the compiled-in constant, knative-v1.23.0), but the emitted value is knative-v1.23.1.

This is a direct consequence of this PR. The config ci command now sources the version from build ldflags:

FuncCliVersion: gitDescribeSuffix.ReplaceAllString(version.Kver, "")

The integration test drives the real command, so the emitted version now depends on version.Kver, which the Makefile injects from git describe --tags --match 'knative-*'. In Prow's checkout (full history + tags), that resolves to knative-v1.23.1 (the latest tag on release-1.23); the regex only strips the -N-gHASH suffix, leaving 1.23.1, which doesn't equal the hardcoded default 1.23.0.

Why the GitHub-Actions "Unit Tests (ubuntu-latest)" check passes for the same test: actions/checkout is shallow and fetches no tags, so git describe yields nothing → version.Kver is empty → the code falls back through setEmptyFieldsToDefaults to DefaultFuncCliVersion (1.23.0), which matches. So the test is now environment-dependent — it only passes when the build's git-describe version happens to equal the compiled-in default.

Suggested fix

Make the test robust to the build-injected version instead of hardcoding the default. Either:

  • set version.Kver to a known value in the test (e.g. "" to force the default fallback), or
  • compute the expected version in the test the same way the code does (strip the suffix from version.Kver, fall back to DefaultFuncCliVersion).

Unrelated red checks

  • style / Golang / Lint — golangci-lint hit a typecheck error because it couldn't download a module: go.opentelemetry.io/otel@v1.44.0: read "https://proxy.golang.org/...": stream error ... INTERNAL_ERROR. Transient network failure; a re-run should clear it.
  • E2E - Runtimes (node) and E2E - Config CI GitHub Workflows — both fail in the deploy step with failed to get credentials: loading registries configuration "/etc/containers/registries.conf": mixing sysregistry v1/v2 is not supported. A runner/cluster config problem, not this PR.

@knative-prow knative-prow Bot added size/M 🤖 PR changes 30-99 lines, ignoring generated files. and removed size/S 🤖 PR changes 10-29 lines, ignoring generated files. labels Sep 1, 2026
@matejvasek

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added lgtm 🤖 PR is ready to be merged. approved 🤖 PR has been approved by an approver from all required OWNERS files. labels Sep 1, 2026
pmeida and others added 2 commits September 1, 2026 21:37
The func CLI version in generated GitHub workflows was hardcoded
to a specific release (knative-v1.22.0), meaning it would silently
go stale as new releases shipped.

FuncCliVersion is now sourced from version.Kver, which is set via
ldflags at build time to the current release tag. The git describe
suffix (e.g. "-22-g2871d3bf") is stripped so that dev builds between
releases still emit a real, installable tag rather than a ref that
does not exist on GitHub releases.

When version.Kver is empty (plain go build without ldflags, or the
package used as a library), the field falls back to
DefaultFuncCliVersion.
The integration test asserted the generated workflow contains
github.DefaultFuncCliVersion, but the command now sources the version
from version.Kver (injected via -ldflags). On release-1.23 the branch's
latest tag is knative-v1.23.1, so the emitted version did not match the
compiled-in default (knative-v1.23.0) and the test failed. Pin
version.Kver in the test so the output is independent of the build/branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
@matejvasek
matejvasek force-pushed the cherry-pick-4029-to-release-1.23 branch from babb322 to 92a41c0 Compare September 1, 2026 19:38
@knative-prow knative-prow Bot removed the lgtm 🤖 PR is ready to be merged. label Sep 1, 2026
@matejvasek

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Sep 1, 2026
@knative-prow

knative-prow Bot commented Sep 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knative-prow-robot, matejvasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow
knative-prow Bot merged commit aff9ef3 into knative:release-1.23 Sep 1, 2026
70 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. kind/bug Bugs lgtm 🤖 PR is ready to be merged. size/M 🤖 PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants