From df8d47fa7190e5ef52331ec9014401e1b79c32e2 Mon Sep 17 00:00:00 2001 From: shreyaabaranwal Date: Thu, 25 Jun 2026 21:04:30 +0530 Subject: [PATCH] fix(ci): make git describe robust against shallow checkouts actions/checkout defaults to a shallow clone without tags, so git describe --tags exits 128 and the version ends up empty. This produces malformed image tags and causes e2e image lookups (e.g. TestCore_PythonUserDepsRemote) to fail with image not found. - Set fetch-depth: 0 on all checkout steps so tags are available - Fall back gracefully in Makefile and hack/release.sh when no matching tag is found Signed-off-by: shreyaabaranwal --- .github/workflows/functions.yaml | 22 ++++++++++++++++++++++ Makefile | 4 ++-- hack/release.sh | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functions.yaml b/.github/workflows/functions.yaml index ccf95aa404..9962acf377 100644 --- a/.github/workflows/functions.yaml +++ b/.github/workflows/functions.yaml @@ -38,6 +38,8 @@ jobs: timeout-minutes: 15 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - name: Check and Lint @@ -72,6 +74,8 @@ jobs: run: git config --global core.autocrlf false - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - name: Run Unit Tests @@ -109,6 +113,8 @@ jobs: run: git config --global core.autocrlf false - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main # Toolchains @@ -150,6 +156,8 @@ jobs: KUBECONFIG: ${{github.workspace}}/hack/bin/kubeconfig.yaml steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: endersonmenezes/free-disk-space@v3 with: @@ -211,6 +219,8 @@ jobs: FUNC_CLUSTER_KEDA: "false" # these tests don't use KEDA; skip it to free cluster CPU (PR #3914 'Insufficient cpu') steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: endersonmenezes/free-disk-space@v3 with: @@ -272,6 +282,8 @@ jobs: FUNC_E2E_VERBOSE: true steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: endersonmenezes/free-disk-space@v3 @@ -341,6 +353,8 @@ jobs: FUNC_E2E_MATRIX_RUNTIMES: ${{ matrix.runtime }} steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: endersonmenezes/free-disk-space@v3 with: @@ -419,6 +433,8 @@ jobs: FUNC_E2E_VERBOSE: true steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: endersonmenezes/free-disk-space@v3 with: @@ -476,6 +492,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - name: Build Platform Binaries run: make cross-platform @@ -522,6 +540,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: docker/setup-qemu-action@v3 - name: Login to GitHub Container Registry @@ -565,6 +585,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: knative/actions/setup-go@main - uses: imjasonh/setup-ko@v0.6 - run: ko build --platform=linux/ppc64le,linux/s390x,linux/amd64,linux/arm64 -B ./cmd/func diff --git a/Makefile b/Makefile index 9d4c6db593..08824f8242 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,8 @@ BIN_GOIMPORTS ?= "$(PWD)/bin/goimports" HASH := $(shell git rev-parse --short HEAD 2>/dev/null) VTAG := $(shell git tag --points-at HEAD | head -1) VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG)) -VERS ?= $(shell git describe --tags --match 'v*') -KVER ?= $(shell git describe --tags --match 'knative-*') +VERS ?= $(shell git describe --tags --match 'v*' 2>/dev/null || echo "v0.0.0") +KVER ?= $(shell git describe --tags --match 'knative-*' 2>/dev/null || echo "knative-v0.0.0") LDFLAGS := -X knative.dev/func/pkg/version.Vers=$(VERS) -X knative.dev/func/pkg/version.Kver=$(KVER) -X knative.dev/func/pkg/version.Hash=$(HASH) diff --git a/hack/release.sh b/hack/release.sh index ac66e1e3a8..ca8eff21ab 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -37,8 +37,8 @@ function build_release() { go_module_version="v0.$(( $(minor_version "$TAG") + 27 )).$(patch_version "$TAG")" fi else - knative_version="$(git describe --tags --match 'knative-*')" - go_module_version="$(git describe --tags --match 'v*')" + knative_version="$(git describe --tags --match 'knative-*' 2>/dev/null || git rev-parse --short HEAD)" + go_module_version="$(git describe --tags --match 'v*' 2>/dev/null || git rev-parse --short HEAD)" fi VERS="${go_module_version}" KVER="${knative_version}" make cross-platform