Skip to content

Commit d8b099f

Browse files
amuraruCopilot
andauthored
chore(deps): update Go dependencies and build tooling (#70)
* chore(deps): update Go dependencies and build tooling Synchronize build-tool pins during dependency updates, refresh generated CRDs, and enforce the pinned controller-gen version before generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: run build-tool regression tests in shared Go checks Run the updater and controller-gen regression tests for pull requests and releases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(ci): use zizmor version selected by its action Remove the independent zizmor pin and updater lookup so the pinned action selects a supported digest-pinned release. Keep tool updates, tests, and documentation consistent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(e2e): allow kustomize to select its required Go toolchain Scope GOTOOLCHAIN=auto to the standalone kustomize install while retaining Go 1.26 for the operator and tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore(deps): synchronize Go toolchain pins in dependency updater Resolve the official stable Go release, update go.mod and the Dockerfile fallback together, and enable automatic toolchain selection. Reject invalid metadata, missing pins, and downgrades before writing build configuration; cover the behavior with regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: schedule weekly Go and dependency update PRs Run the updater every Monday at 08:17 UTC or on demand, validate changes, and maintain one automation PR. Use the PAT secret only for publishing and keep default workflow permissions read-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3e4e908 commit d8b099f

16 files changed

Lines changed: 633 additions & 53 deletions

‎.github/actions/go-checks/action.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# (GitHub releases), so both gate on exactly the same checks.
33
# The calling job must check out the repository first.
44
name: go-checks
5-
description: Gofmt/license checks, go vet, generated-code drift check and unit tests with coverage.
5+
description: Gofmt/license checks, go vet, generated-code drift check, build-tool regression tests and unit tests with coverage.
66

77
runs:
88
using: composite
@@ -13,6 +13,9 @@ runs:
1313
- name: Gofmt and license checks
1414
shell: bash
1515
run: make check
16+
- name: Build-tool regression tests
17+
shell: bash
18+
run: python3 -B -m unittest discover -s scripts -p 'test_*.py'
1619
- name: go vet
1720
shell: bash
1821
run: go vet ./...

‎.github/workflows/ci.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: golangci-lint
4040
uses: golangci/golangci-lint-action@v9
4141
with:
42-
version: v2.13.2
42+
version: v2.15.0
4343
# The existing code base still carries legacy findings; only report
4444
# issues introduced by the change under review.
4545
only-new-issues: true
@@ -54,7 +54,7 @@ jobs:
5454
persist-credentials: false
5555
- uses: azure/setup-helm@v5
5656
with:
57-
version: v3.22.0
57+
version: v4.3.1
5858
- name: Check values schema json
5959
uses: losisin/helm-values-schema-json-action@v3
6060
with:

‎.github/workflows/e2e.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ jobs:
4040
registry: true
4141
# Pre-install kustomize into ./bin with the Makefile's version instead of
4242
# the install script, which trips GitHub's unauthenticated API rate limit.
43+
# Its compiler requirement can be newer than the operator's Go version.
4344
- name: Install kustomize
4445
run: |
4546
version="$(sed -n 's/^KUSTOMIZE_VERSION ?= //p' Makefile)"
46-
GOBIN="${PWD}/bin" go install "sigs.k8s.io/kustomize/kustomize/v5@${version}"
47+
GOTOOLCHAIN=auto GOBIN="${PWD}/bin" go install "sigs.k8s.io/kustomize/kustomize/v5@${version}"
4748
- name: Build and push operator image
4849
env:
4950
IMAGE: ${{ steps.kind.outputs.LOCAL_REGISTRY }}/zookeeper-operator:e2e

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ jobs:
266266
persist-credentials: false
267267
- uses: azure/setup-helm@v5
268268
with:
269-
version: v3.22.0
269+
version: v4.3.1
270270
- uses: sigstore/cosign-installer@v4.1.2
271271
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
272272
uses: docker/login-action@v4
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: update-dependencies
2+
3+
on:
4+
schedule:
5+
- cron: '17 8 * * 1'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: update-dependencies
13+
cancel-in-progress: false
14+
15+
jobs:
16+
update:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 45
19+
steps:
20+
- name: Check publishing credential
21+
env:
22+
UPDATE_TOKEN: ${{ secrets.PAT }}
23+
run: |
24+
if [ -z "$UPDATE_TOKEN" ]; then
25+
echo "::error::Configure the PAT secret with Contents, Pull requests, and Workflows read/write permissions."
26+
exit 1
27+
fi
28+
- uses: actions/checkout@v7
29+
with:
30+
ref: ${{ github.event.repository.default_branch }}
31+
persist-credentials: false
32+
- uses: actions/setup-go@v7
33+
with:
34+
go-version-file: go.mod
35+
- uses: docker/setup-buildx-action@v4
36+
- name: Update Go and dependencies
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
run: ./update-go-deps.sh
40+
- name: Validate updates
41+
env:
42+
GOTOOLCHAIN: auto
43+
run: |
44+
python3 -B -m unittest discover -s scripts -p 'test_*.py'
45+
make check
46+
go vet ./...
47+
make test
48+
- name: Create or update dependency PR
49+
uses: peter-evans/create-pull-request@v8.1.1
50+
with:
51+
token: ${{ secrets.PAT }}
52+
base: ${{ github.event.repository.default_branch }}
53+
branch: automation/update-dependencies
54+
title: 'chore(deps): refresh Go and dependencies'
55+
commit-message: |
56+
chore(deps): refresh Go and dependencies
57+
58+
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
59+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
60+
add-paths: |
61+
go.mod
62+
go.sum
63+
Dockerfile
64+
Makefile
65+
.github/workflows
66+
api
67+
config
68+
charts
69+
body: |
70+
### Change log description
71+
72+
- Update Go and synchronize the Dockerfile fallback.
73+
- Refresh Go modules, build-tool pins, and CI image tags/digests.
74+
- Regenerate code, manifests, and the Helm chart CRD.
75+
76+
### Purpose of the change
77+
78+
Keep dependencies current through the weekly dependency updater.
79+
80+
### What the code does
81+
82+
Runs `./update-go-deps.sh` against the default branch. Review the
83+
generated diff for the exact version changes before merging.
84+
85+
### How to verify it
86+
87+
The following commands passed in this workflow run:
88+
89+
- `./update-go-deps.sh` (includes `go build ./...` and `make manifests generate`).
90+
- `python3 -B -m unittest discover -s scripts -p 'test_*.py'`.
91+
- `make check`.
92+
- `go vet ./...`.
93+
- `make test`.
94+
95+
Validation uses `GOTOOLCHAIN=auto` for the updated Go version.
96+
Review the PR's remaining CI checks, including image builds and chart validation.

‎.github/workflows/workflow-lint.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
- name: zizmor
4747
uses: zizmorcore/zizmor-action@v0.6.4
4848
with:
49-
version: v1.30.1
5049
# Fail the job and annotate the PR instead of uploading SARIF, which
5150
# also works for pull requests from forks (read-only token).
5251
advanced-security: false

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# from the `go` directive in go.mod) so the builder image always matches the
33
# toolchain version the module actually requires. The default below is only a
44
# fallback for ad-hoc `docker build .` invocations without --build-arg.
5-
ARG GO_VERSION=1.26
5+
ARG GO_VERSION=1.27
66
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:${GO_VERSION}-alpine3.24 AS go-builder
77

88
# Populated automatically by BuildKit with the target platform of each build.

‎Makefile‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,22 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
9393
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
9494
## Tool Versions
9595
# Upgraded to modern stable versions
96-
KUSTOMIZE_VERSION ?= v5.7.1
97-
CONTROLLER_TOOLS_VERSION ?= v0.19.0
96+
KUSTOMIZE_VERSION ?= v5.8.3
97+
CONTROLLER_TOOLS_VERSION ?= v0.23.0
9898
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
9999
.PHONY: kustomize
100100
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
101101
$(KUSTOMIZE): $(LOCALBIN)
102102
test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
103103
.PHONY: controller-gen
104-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
105-
$(CONTROLLER_GEN): $(LOCALBIN)
106-
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
104+
controller-gen: $(LOCALBIN) ## Install controller-gen locally at the configured version.
105+
test -x "$(CONTROLLER_GEN)" && \
106+
test "$$("$(CONTROLLER_GEN)" --version)" = "Version: $(CONTROLLER_TOOLS_VERSION)" || \
107+
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
107108

108109
all: generate check build
109110

110-
generate:
111+
generate: controller-gen
111112
$(CONTROLLER_GEN) object paths="./..."
112113
make manifests
113114
# sync crd generated to helm-chart

‎README.md‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The project is currently beta. While no breaking API changes are currently plann
3030
- [Manual uninstall](#manual-uninstall-1)
3131
- [The AdminServer](#the-adminserver)
3232
- [Development](#development)
33+
- [Update dependencies](#update-dependencies)
3334
- [Build the operator image](#build-the-operator-image)
3435
- [Published Docker Images](#published-docker-images)
3536
- [Direct access to the cluster](#direct-access-to-the-cluster)
@@ -379,6 +380,46 @@ The list of available commands are
379380

380381
## Development
381382

383+
### Update dependencies
384+
385+
Run `./update-go-deps.sh` to update Go to the latest stable release, Go modules,
386+
and build-tool pins in the Makefile and CI workflows: kustomize (within v5),
387+
controller-tools, golangci-lint, Helm, kubeconform and actionlint.
388+
CI image tags and digests are updated together;
389+
Helm versions stay synchronized between CI and releases.
390+
The Go version in `go.mod` and the Dockerfile's major.minor fallback stay
391+
synchronized; CI and Makefile builds derive their Go version from `go.mod`.
392+
Go version downgrades are rejected.
393+
394+
Requires Go, Make, curl, Python 3.9+, authenticated GitHub CLI (`gh auth login`),
395+
and Docker CLI with Buildx. The script enables automatic Go toolchain downloads
396+
with `GOTOOLCHAIN=auto`. All Go/build-tool lookups and pin matches must succeed
397+
before build configuration is written. Go module updates are then checked with
398+
`go build ./...`.
399+
Finally, `make manifests generate` regenerates code, CRDs and the Helm chart CRD;
400+
generation failures stop the updater.
401+
Review the diff and run the relevant CI checks before committing: stable releases
402+
can still introduce breaking changes.
403+
404+
GitHub Actions references, general Docker images and Gradle dependencies remain
405+
managed by Dependabot. Zizmor uses the default binary version selected by its
406+
action. Java and ZooKeeper versions are not changed by this script.
407+
Test the updater without network access or real dependency upgrades with
408+
`python3 -B -m unittest discover -s scripts -p 'test_update_deps.py'`.
409+
410+
The `update-dependencies` workflow runs every Monday at 08:17 UTC and can also
411+
be started manually. It runs the updater and regression, formatting, license,
412+
vet, and unit checks before creating or updating one PR from
413+
`automation/update-dependencies`. No PR is created when nothing changes;
414+
merging remains manual.
415+
416+
The workflow requires the repository secret `PAT`, with Contents, Pull requests,
417+
and Workflows read/write permissions for this repository. Workflow permission
418+
is needed because the updater changes CI version pins. The PAT is used only
419+
to publish the PR, allowing normal PR checks to run; release lookups use the
420+
read-only workflow token. Scheduled runs start after the workflow is merged
421+
into the default branch.
422+
382423
### Build the operator image
383424

384425
Requirements:

‎charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.19.0
7+
controller-gen.kubebuilder.io/version: v0.23.0
88
name: zookeeperclusters.zookeeper.pravega.io
99
spec:
1010
group: zookeeper.pravega.io

0 commit comments

Comments
 (0)