Skip to content

Commit 12a125e

Browse files
authored
chore: backport (2026/02/19) (#1258)
2 parents 0deb147 + 71e152d commit 12a125e

49 files changed

Lines changed: 8026 additions & 2969 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 115 additions & 208 deletions
Large diffs are not rendered by default.

.github/workflows/chart.yml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,81 @@ on:
55
branches:
66
- main
77
paths:
8-
- ".github/workflows/chart.yaml"
8+
- ".github/workflows/chart.yml"
99
- "charts/**"
1010
create:
1111
# Publish semver tags as releases.
1212
tags: [ 'v*.*.*' ]
1313

1414
permissions:
1515
contents: write
16+
packages: write
17+
18+
env:
19+
REGISTRY: ghcr.io
1620

1721
jobs:
18-
deploy:
22+
publish-github-pages:
1923
runs-on: ubuntu-latest
2024
steps:
2125
- uses: actions/checkout@v6.0.2
2226
with:
2327
submodules: true
2428
fetch-depth: 0
25-
- name: Publish Helm chart
29+
- name: Publish Helm chart to GitHub Pages
2630
uses: stefanprodan/helm-gh-pages@v1.7.0
2731
with:
2832
token: ${{ secrets.GITHUB_TOKEN }}
2933
charts_dir: charts
3034
target_dir: charts
31-
linting: off
35+
linting: on
36+
37+
publish-oci:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v6.0.2
42+
43+
- name: Login to GitHub Container Registry
44+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Package and push Helm charts to GHCR
51+
run: |
52+
set -euo pipefail
53+
54+
# Convert repository name to lowercase for OCI registry
55+
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
56+
57+
# Determine version to use
58+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
59+
# Use release tag as version (strip 'v' prefix)
60+
CHART_VERSION=${GITHUB_REF#refs/tags/v}
61+
echo "Using release tag version: ${CHART_VERSION}"
62+
else
63+
# Use version from Chart.yaml for non-tag pushes
64+
CHART_VERSION=$(grep '^version:' charts/hub-agent/Chart.yaml | awk '{print $2}')
65+
echo "Using Chart.yaml version: ${CHART_VERSION}"
66+
fi
67+
68+
# Package and push hub-agent chart
69+
echo "📦 Packaging hub-agent chart..."
70+
helm package charts/hub-agent --version ${CHART_VERSION} --app-version ${CHART_VERSION}
71+
72+
echo "🚀 Pushing hub-agent to OCI registry..."
73+
helm push hub-agent-${CHART_VERSION}.tgz oci://${{ env.REGISTRY }}/${REPO_LOWER}/charts
74+
75+
# Package and push member-agent chart
76+
echo "📦 Packaging member-agent chart..."
77+
helm package charts/member-agent --version ${CHART_VERSION} --app-version ${CHART_VERSION}
78+
79+
echo "🚀 Pushing member-agent to OCI registry..."
80+
helm push member-agent-${CHART_VERSION}.tgz oci://${{ env.REGISTRY }}/${REPO_LOWER}/charts
81+
82+
echo ""
83+
echo "✅ Helm charts published to OCI registry!"
84+
echo "📍 Hub Agent: oci://${{ env.REGISTRY }}/${REPO_LOWER}/charts/hub-agent:${CHART_VERSION}"
85+
echo "📍 Member Agent: oci://${{ env.REGISTRY }}/${REPO_LOWER}/charts/member-agent:${CHART_VERSION}"

.github/workflows/ci.yml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]
1414

1515
env:
16-
GO_VERSION: '1.24.12'
16+
GO_VERSION: '1.24.13'
1717
CERT_MANAGER_VERSION: 'v1.16.2'
1818

1919
jobs:
@@ -30,7 +30,7 @@ jobs:
3030
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
3131
concurrent_skipping: false
3232

33-
unit-tests:
33+
unit-and-integration-tests:
3434
runs-on: ubuntu-latest
3535
needs: detect-noop
3636
if: needs.detect-noop.outputs.noop != 'true'
@@ -46,18 +46,43 @@ jobs:
4646
- name: Set up Ginkgo CLI
4747
run: |
4848
go install github.com/onsi/ginkgo/v2/ginkgo@v2.19.1
49+
50+
- name: Prepare necessary environment variables
51+
run: |
52+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
53+
KUBEBUILDER_ASSETS=$(make --silent kubebuilder-assets-path)
54+
echo "KUBEBUILDER_ASSETS="$KUBEBUILDER_ASSETS"" >> $GITHUB_ENV
4955
50-
- name: Run unit tests & Generate coverage
51-
run: make test
52-
56+
# Certain tests that require special setup (e.g., those that should be run with Ginkgo CLI only) will
57+
# be skipped in this step.
58+
#
59+
# Note that the skipping only applies to the CI environment.
60+
- name: Run unit and integration tests with default setup & generate coverage
61+
run: |
62+
make test
63+
env:
64+
KUBEFLEET_CI_TEST_RUNNER_NAME: 'default'
65+
66+
# The work applier integration tests use in-memory Kubernetes environment setup; due to resource constraints
67+
# and the way the tests are organized, running the suite with as many parallel Ginkgo processes as possible (i.e.,
68+
# the number of all CPU cores) might not lead to the optimal outcome.
69+
#
70+
# Note (chenyu1): switch to test matrices if we need to test with more configuration combos in the future.
71+
- name: Run work applier unit and integration tests with Ginkgo CLI & generate coverage
72+
run: |
73+
ginkgo -v -p --procs=4 --race --cover -coverprofile=work-applier-it-coverage.out ./pkg/controllers/workapplier/
74+
KUBEFLEET_CI_WORK_APPLIER_RUN_WITH_PRIORITY_QUEUE=true ginkgo -v -p --procs=4 --race --cover -coverprofile=work-applier-it-no-pri-q-coverage.out ./pkg/controllers/workapplier/
75+
env:
76+
KUBEFLEET_CI_TEST_RUNNER_NAME: 'ginkgo'
77+
5378
- name: Upload Codecov report
5479
uses: codecov/codecov-action@v5
5580
with:
56-
## Repository upload token - get it from codecov.io. Required only for private repositories
81+
## Repository upload token - get it from codecov.io. Required only for private repositories
5782
token: ${{ secrets.CODECOV_TOKEN }}
58-
## Comma-separated list of files to upload
59-
files: ./ut-coverage.xml
60-
83+
# The codecov action will auto-search all coverage files by default. All uploaded coverage will be
84+
# merged automatically.
85+
6186
e2e-tests:
6287
strategy:
6388
fail-fast: false

.github/workflows/code-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
env:
1616
# Common versions
17-
GO_VERSION: '1.24.12'
17+
GO_VERSION: '1.24.13'
1818

1919
jobs:
2020

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Harden Runner
15-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
15+
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
1616
with:
1717
egress-policy: audit
1818

.github/workflows/trivy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
MEMBER_AGENT_IMAGE_NAME: member-agent
1919
REFRESH_TOKEN_IMAGE_NAME: refresh-token
2020

21-
GO_VERSION: '1.24.12'
21+
GO_VERSION: '1.24.13'
2222

2323
jobs:
2424
export-registry:
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions/checkout@v6.0.2
4848

4949
- name: Login to ${{ env.REGISTRY }}
50-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
50+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
5151
with:
5252
registry: ${{ env.REGISTRY }}
5353
username: ${{ github.actor }}

.github/workflows/upgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]
1818

1919
env:
20-
GO_VERSION: '1.24.12'
20+
GO_VERSION: '1.24.13'
2121

2222
jobs:
2323
detect-noop:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ ut-coverage.xml
3535

3636
.vscode/
3737
.qoder/
38+
39+
# Helm chart packaging
40+
.helm-packages/

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
run:
22
timeout: 15m
3-
go: '1.24.12'
3+
go: '1.24.13'
44

55
linters-settings:
66
stylecheck:

Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86_64))
3636
else ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),aarch64 arm))
3737
TARGET_ARCH := arm64
3838
endif
39-
$(info Auto-detected system architecture: $(TARGET_ARCH))
4039
endif
4140
endif
4241

@@ -63,7 +62,7 @@ CONTROLLER_GEN_VER := v0.16.0
6362
CONTROLLER_GEN_BIN := controller-gen
6463
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
6564

66-
STATICCHECK_VER := master
65+
STATICCHECK_VER := v0.6.1
6766
STATICCHECK_BIN := staticcheck
6867
STATICCHECK := $(abspath $(TOOLS_BIN_DIR)/$(STATICCHECK_BIN)-$(STATICCHECK_VER))
6968

@@ -76,9 +75,9 @@ GOLANGCI_LINT_BIN := golangci-lint
7675
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
7776

7877
# ENVTEST_K8S_VERSION refers to the version of k8s binary assets to be downloaded by envtest binary.
79-
ENVTEST_K8S_VERSION = 1.30.0
78+
ENVTEST_K8S_VERSION = 1.33.0
8079
# ENVTEST_VER is the version of the ENVTEST binary
81-
ENVTEST_VER = v0.0.0-20240317073005-bd9ea79e8d18
80+
ENVTEST_VER = release-0.22
8281
ENVTEST_BIN := setup-envtest
8382
ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(ENVTEST_BIN)-$(ENVTEST_VER))
8483

@@ -182,19 +181,26 @@ test: manifests generate fmt vet local-unit-test integration-test ## Run unit te
182181

183182
##
184183
# Set up the timeout parameters as some of the tests (rollout controller) lengths have exceeded the default 10 minute mark.
185-
# TO-DO (chenyu1): enable parallelization for single package integration tests.
184+
# Note: this recipe runs both unit tests and integration tests under the pkg/ directory.
186185
.PHONY: local-unit-test
187186
local-unit-test: $(ENVTEST) ## Run unit tests
188187
export CGO_ENABLED=1 && \
189188
export KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" && \
190189
go test `go list ./pkg/... ./cmd/...` -race -coverpkg=./... -coverprofile=ut-coverage.xml -covermode=atomic -v -timeout=30m
191190

191+
# Note: this recipe runs the integration tests under the /test/scheduler and /test/apis/ directories with the Ginkgo CLI.
192192
.PHONY: integration-test
193193
integration-test: $(ENVTEST) ## Run integration tests
194194
export CGO_ENABLED=1 && \
195195
export KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" && \
196-
ginkgo -v -p --race --cover --coverpkg=./pkg/scheduler/... ./test/scheduler && \
197-
ginkgo -v -p --race --cover --coverpkg=./... ./test/apis/...
196+
ginkgo -v -p --race --cover --coverpkg=./pkg/scheduler/... -coverprofile=scheduler-it.out ./test/scheduler && \
197+
ginkgo -v -p --race --cover --coverpkg=./apis/ -coverprofile=api-validation-it.out ./test/apis/...
198+
199+
.PHONY: kubebuilder-assets-path
200+
kubebuilder-assets-path: $(ENVTEST) ## Get the path to kubebuilder assets
201+
@export CGO_ENABLED=1 && \
202+
export KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" && \
203+
echo $$KUBEBUILDER_ASSETS
198204

199205
## local tests & e2e tests
200206

@@ -282,6 +288,14 @@ BUILDKIT_VERSION ?= v0.18.1
282288
push: ## Build and push all Docker images
283289
$(MAKE) OUTPUT_TYPE="type=registry" docker-build-hub-agent docker-build-member-agent docker-build-refresh-token docker-build-crd-installer
284290

291+
.PHONY: helm-push
292+
helm-push: ## Package and push Helm charts to OCI registry
293+
helm package charts/hub-agent --version $(TAG) --app-version $(TAG) --destination .helm-packages
294+
helm package charts/member-agent --version $(TAG) --app-version $(TAG) --destination .helm-packages
295+
helm push .helm-packages/hub-agent-$(TAG).tgz oci://$(REGISTRY)
296+
helm push .helm-packages/member-agent-$(TAG).tgz oci://$(REGISTRY)
297+
rm -rf .helm-packages
298+
285299
# By default, docker buildx create will pull image moby/buildkit:buildx-stable-1 and hit the too many requests error
286300
#
287301
# Note (chenyu1): the step below sets up emulation for building/running non-native binaries on the host. The original
@@ -300,6 +314,7 @@ push: ## Build and push all Docker images
300314
# On some systems the emulation setup might not work at all (e.g., macOS on Apple Silicon -> Rosetta 2 will be used
301315
# by Docker Desktop as the default emulation option for AMD64 on ARM64 container compatibility).
302316
docker-buildx-builder:
317+
$(info Auto-detected system architecture: $(TARGET_ARCH))
303318
@if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \
304319
if [ "$(TARGET_ARCH)" = "amd64" ] ; then \
305320
echo "The target is an x86_64 platform; setting up emulation for other known architectures"; \

0 commit comments

Comments
 (0)