Skip to content

Commit d77bc4c

Browse files
committed
bump
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
1 parent dfcde37 commit d77bc4c

File tree

5 files changed

+114
-42
lines changed

5 files changed

+114
-42
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ name: Build
33
on:
44
pull_request:
55
types: [opened, synchronize]
6-
76
jobs:
87
build_binary:
98
name: Build addon-operator binary
109
runs-on: ubuntu-latest
1110
steps:
12-
- name: Set up Go 1.25
11+
- name: Set up Go
1312
uses: actions/setup-go@v5
1413
with:
1514
go-version: '1.25.5'
1615
id: go
17-
1816
- name: Check out addon-operator code
1917
uses: actions/checkout@v4
20-
2118
- name: Restore Go modules
2219
id: go-modules-cache
2320
uses: actions/cache@v4
@@ -27,15 +24,13 @@ jobs:
2724
key: ${{ runner.os }}-gomod-${{ hashFiles('go.mod', 'go.sum') }}
2825
restore-keys: |
2926
${{ runner.os }}-gomod-
30-
3127
- name: Download Go modules
3228
if: steps.go-modules-cache.outputs.cache-hit != 'true'
3329
run: |
3430
go mod download
3531
echo -n "Go modules unpacked size is: " && du -sh $HOME/go/pkg/mod
36-
3732
- name: Build binary
38-
run: |
33+
run: |-
3934
export GOOS=linux
4035
41-
go build ./cmd/addon-operator
36+
go build ./cmd/addon-operator

.github/workflows/lint.yaml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,48 @@
11
# every push to a branch:
2-
# - Run Go linters.
3-
# - Check grammar with codespell.
2+
# - run linter
43
name: Lint
54
on:
65
pull_request:
76
types: [opened, synchronize]
8-
97
jobs:
10-
go_linters:
11-
name: Run Go linters
8+
run_linter:
9+
name: Run linter
1210
runs-on: ubuntu-latest
1311
steps:
14-
- name: Set up Go 1.25
12+
- name: Set up Go
1513
uses: actions/setup-go@v5
1614
with:
17-
go-version: '1.25.5'
18-
id: go
19-
20-
- name: Check out addon-operator code
15+
go-version: "1.25.5"
16+
- name: Check out shell-operator code
2117
uses: actions/checkout@v4
22-
2318
- name: Restore Go modules
2419
id: go-modules-cache
25-
uses: actions/cache@v4
20+
uses: actions/cache@v4.2.3
2621
with:
2722
path: |
2823
~/go/pkg/mod
2924
key: ${{ runner.os }}-gomod-${{ hashFiles('go.mod', 'go.sum') }}
3025
restore-keys: |
3126
${{ runner.os }}-gomod-
32-
3327
- name: Download Go modules
3428
if: steps.go-modules-cache.outputs.cache-hit != 'true'
3529
run: |
3630
go mod download
3731
echo -n "Go modules unpacked size is: " && du -sh $HOME/go/pkg/mod
38-
3932
- name: Run golangci-lint
4033
run: |
41-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . v2.7.2
42-
./golangci-lint run
43-
34+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . v2.8.0
35+
./golangci-lint run ./...
4436
codespell:
4537
name: Run codespell
4638
runs-on: ubuntu-latest
4739
steps:
4840
- uses: actions/setup-python@v5
4941
with:
5042
python-version: 3.8
51-
5243
- name: Check out addon-operator code
5344
uses: actions/checkout@v4
54-
5545
- name: Run codespell
5646
run: |
5747
pip install codespell==v1.17.1
58-
codespell --skip=".git,go.mod,go.sum,*.log,*.gif,*.png" -L witht,eventtypes,uint,uptodate,afterall
48+
codespell --skip=".git,go.mod,go.sum,*.log,*.gif,*.png,*.md" -L witht,eventtypes,uint,uptodate,afterall,keypair

.github/workflows/tests.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ name: Unit tests
44
on:
55
pull_request:
66
types: [opened, synchronize]
7-
87
jobs:
98
run_unit_tests:
109
name: Run unit tests
1110
runs-on: ubuntu-latest
1211
steps:
13-
- name: Set up Go 1.25
12+
- name: Set up Go
1413
uses: actions/setup-go@v5
1514
with:
1615
go-version: '1.25.5'
1716
id: go
18-
1917
- name: Check out addon-operator code
2018
uses: actions/checkout@v4
21-
2219
- name: Restore Go modules
2320
id: go-modules-cache
2421
uses: actions/cache@v4
@@ -28,17 +25,15 @@ jobs:
2825
key: ${{ runner.os }}-gomod-${{ hashFiles('go.mod', 'go.sum') }}
2926
restore-keys: |
3027
${{ runner.os }}-gomod-
31-
3228
- name: Download Go modules
3329
if: steps.go-modules-cache.outputs.cache-hit != 'true'
3430
run: |
3531
go mod download
3632
echo -n "Go modules unpacked size is: " && du -sh $HOME/go/pkg/mod
37-
3833
- name: Run unit tests
39-
run: |
34+
run: |-
4035
export GOOS=linux
4136
4237
go test \
4338
--race \
44-
./cmd/... ./pkg/...
39+
./cmd/... ./pkg/...

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*.so
66
*.dylib
77

8+
bin/
9+
810
# Graph images
911
*.gv
1012
*gv.svg

Makefile

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,73 @@
1+
2+
.PHONY: go-module-version
3+
go-module-version: go-check git-check
4+
@echo "go get $(shell $(GO) list ./cmd/addon-operator)@$(shell $(GIT) rev-parse HEAD)"
5+
6+
.PHONY: lint
7+
lint: golangci-lint ## Run linter.
8+
@$(GOLANGCI_LINT) run --fix
9+
10+
.PHONY: test
11+
test: go-check
12+
@$(GO) test --race --cover ./...
13+
14+
## Run all generate-* jobs in bulk.
15+
.PHONY: generate
16+
generate: update-k8s-version update-workflows-go-version update-workflows-golangci-lint-version update-workflows-ginkgo-version
17+
18+
19+
##@ Dependencies
20+
21+
WHOAMI ?= $(shell whoami)
22+
23+
## Location to install dependencies to
24+
LOCALBIN ?= $(shell pwd)/bin
25+
$(LOCALBIN):
26+
mkdir -p $(LOCALBIN)
27+
28+
## Tool Binaries
129
GO=$(shell which go)
230
GIT=$(shell which git)
31+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
32+
YQ = $(LOCALBIN)/yq
33+
34+
## TODO: remap in yaml file (version.yaml or smthng)
35+
## Tool Versions
36+
# GO_BUILDER_VERSION must be without 'v' prefix
37+
GO_BUILDER_VERSION = 1.25.5
38+
GOLANGCI_LINT_VERSION = v2.8.0
39+
YQ_VERSION ?= v4.50.1
40+
41+
42+
.PHONY: update-k8s-version
43+
update-k8s-version: go-check
44+
@kubernetesVer=$(shell $(GO) list -m k8s.io/api | cut -d' ' -f 2); \
45+
kubectlVer=$$(echo $$kubernetesVer | sed 's/v0/v1/'); \
46+
echo "Updating kubectl version in Dockerfile to match k8s.io/api version: $$kubectlVer"; \
47+
sed -i "s/ARG kubectlVersion=.*/ARG kubectlVersion=$$kubectlVer/" Dockerfile; \
48+
echo "kubectl version in Dockerfile updated to: $$kubectlVer"
49+
50+
.PHONY: update-workflows-go-version
51+
update-workflows-go-version: yq
52+
for file in $$(find .github/workflows -name "*.yaml"); do \
53+
if grep -q "actions/setup-go" $$file; then \
54+
$(YQ) -i '(.jobs[]?.steps[]? | select(.uses | test("actions/setup-go")) | .with."go-version") = "$(GO_BUILDER_VERSION)"' $$file; \
55+
fi; \
56+
done
57+
echo "Updated go-version in workflow files to $(GO_BUILDER_VERSION)"
58+
59+
.PHONY: update-workflows-golangci-lint-version
60+
update-workflows-golangci-lint-version: yq
61+
$(YQ) -i '(.jobs.run_linter.steps[] | select(.name == "Run golangci-lint") | .run) |= sub("v\\d+\\.\\d+\\.\\d+", "$(GOLANGCI_LINT_VERSION)")' .github/workflows/lint.yaml
62+
echo "Updated golangci-lint version in lint.yaml to $(GOLANGCI_LINT_VERSION)"
63+
64+
.PHONY: update-workflows-ginkgo-version
65+
update-workflows-ginkgo-version: yq
66+
@ginkgoVer=$(shell $(GO) list -m github.com/onsi/ginkgo/v2 | cut -d' ' -f 2); \
67+
$(YQ) -i '(.jobs.integration_tests.steps[] | select(.name == "Install ginkgo") | .run) |= sub("@latest", "@$$ginkgoVer")' .github/workflows/tests-labeled.yaml; \
68+
echo "Updated ginkgo version in tests-labeled.yaml to $$ginkgoVer"
69+
70+
## Installed tools check
371

472
.PHONY: go-check
573
go-check:
@@ -9,13 +77,35 @@ go-check:
977
git-check:
1078
$(call error-if-empty,$(GIT),git)
1179

12-
.PHONY: go-module-version
13-
go-module-version: go-check git-check
14-
@echo "go get $(shell $(GO) list ./cmd/addon-operator)@$(shell $(GIT) rev-parse HEAD)"
80+
## Tool installations
81+
82+
.PHONY: golangci-lint
83+
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
84+
$(GOLANGCI_LINT): $(LOCALBIN)
85+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
86+
87+
.PHONY: yq
88+
yq: $(YQ) ## Download yq locally if necessary.
89+
$(YQ): $(LOCALBIN)
90+
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,$(YQ_VERSION))
91+
92+
93+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
94+
# $1 - target path with name of binary
95+
# $2 - package url which can be installed
96+
# $3 - specific version of package
97+
define go-install-tool
98+
@[ -f "$(1)-$(3)" ] || { \
99+
set -e; \
100+
package=$(2)@$(3) ;\
101+
echo "Downloading $${package}" ;\
102+
rm -f $(1) || true ;\
103+
GOBIN=$(LOCALBIN) GOTOOLCHAIN=$(GO_TOOLCHAIN_AUTOINSTALL_VERSION) go install $${package} ;\
104+
mv $(1) $(1)-$(3) ;\
105+
} ;\
106+
ln -sf $(1)-$(3) $(1)
107+
endef
15108

16-
.PHONY: test
17-
test: go-check
18-
@$(GO) test --race --cover ./...
19109

20110
define error-if-empty
21111
@if [[ -z $(1) ]]; then echo "$(2) not installed"; false; fi

0 commit comments

Comments
 (0)