Skip to content

Commit 75453ad

Browse files
fix: issue #66 (#71)
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
1 parent 2c93276 commit 75453ad

File tree

8 files changed

+300
-86
lines changed

8 files changed

+300
-86
lines changed

.github/workflows/ci.yml

+115-38
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ on:
1111
env:
1212
# Common versions
1313
GO_VERSION: '1.21'
14-
GOLANGCI_VERSION: 'v1.54.0'
14+
GOLANGCI_VERSION: 'v1.61.0'
1515
DOCKER_BUILDX_VERSION: 'v0.8.2'
16-
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
16+
17+
# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
18+
# step 'if env.XXX != ""', so we copy these to succinctly test whether
19+
# credentials have been provided before trying to run steps that need them.
20+
UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
1721

1822
jobs:
1923
detect-noop:
20-
runs-on: ubuntu-22.04
24+
runs-on: ubuntu-24.04
2125
outputs:
2226
noop: ${{ steps.noop.outputs.should_skip }}
2327
steps:
@@ -29,8 +33,35 @@ jobs:
2933
paths_ignore: '["**.md", "**.png", "**.jpg"]'
3034
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
3135

36+
report-breaking-changes:
37+
runs-on: ubuntu-24.04
38+
needs: detect-noop
39+
if: needs.detect-noop.outputs.noop != 'true'
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
43+
with:
44+
submodules: true
45+
46+
- name: Get modified CRDs
47+
id: modified-crds
48+
uses: tj-actions/changed-files@v45
49+
with:
50+
files: |
51+
package/crds/**
52+
- name: Report breaking CRD OpenAPI v3 schema changes
53+
if: steps.modified-crds.outputs.any_changed == 'true'
54+
env:
55+
MODIFIED_CRD_LIST: ${{ steps.modified-crds.outputs.all_changed_files }}
56+
run: |
57+
make crddiff
58+
- name: Report native schema version changes
59+
if: ${{ inputs.upjet-based-provider }}
60+
run: |
61+
make schema-version-diff
62+
3263
lint:
33-
runs-on: ubuntu-22.04
64+
runs-on: ubuntu-24.04
3465
needs: detect-noop
3566
if: needs.detect-noop.outputs.noop != 'true'
3667

@@ -47,17 +78,17 @@ jobs:
4778

4879
- name: Find the Go Build Cache
4980
id: go
50-
run: echo "::set-output name=cache::$(make go.cachedir)"
81+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
5182

5283
- name: Cache the Go Build Cache
53-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
84+
uses: actions/cache@v4
5485
with:
5586
path: ${{ steps.go.outputs.cache }}
5687
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }}
5788
restore-keys: ${{ runner.os }}-build-lint-
5889

5990
- name: Cache Go Dependencies
60-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
91+
uses: actions/cache@v4
6192
with:
6293
path: .work/pkg
6394
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
@@ -69,12 +100,12 @@ jobs:
69100
# We could run 'make lint' but we prefer this action because it leaves
70101
# 'annotations' (i.e. it comments on PRs to point out linter violations).
71102
- name: Lint
72-
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6
103+
uses: golangci/golangci-lint-action@v6
73104
with:
74105
version: ${{ env.GOLANGCI_VERSION }}
75106

76107
check-diff:
77-
runs-on: ubuntu-22.04
108+
runs-on: ubuntu-24.04
78109
needs: detect-noop
79110
if: needs.detect-noop.outputs.noop != 'true'
80111

@@ -94,17 +125,17 @@ jobs:
94125

95126
- name: Find the Go Build Cache
96127
id: go
97-
run: echo "::set-output name=cache::$(make go.cachedir)"
128+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
98129

99130
- name: Cache the Go Build Cache
100-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
131+
uses: actions/cache@v4
101132
with:
102133
path: ${{ steps.go.outputs.cache }}
103134
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}
104135
restore-keys: ${{ runner.os }}-build-check-diff-
105136

106137
- name: Cache Go Dependencies
107-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
138+
uses: actions/cache@v4
108139
with:
109140
path: .work/pkg
110141
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
@@ -117,7 +148,7 @@ jobs:
117148
run: make check-diff
118149

119150
unit-tests:
120-
runs-on: ubuntu-22.04
151+
runs-on: ubuntu-24.04
121152
needs: detect-noop
122153
if: needs.detect-noop.outputs.noop != 'true'
123154

@@ -137,17 +168,17 @@ jobs:
137168

138169
- name: Find the Go Build Cache
139170
id: go
140-
run: echo "::set-output name=cache::$(make go.cachedir)"
171+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
141172

142173
- name: Cache the Go Build Cache
143-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
174+
uses: actions/cache@v4
144175
with:
145176
path: ${{ steps.go.outputs.cache }}
146177
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
147178
restore-keys: ${{ runner.os }}-build-unit-tests-
148179

149180
- name: Cache Go Dependencies
150-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
181+
uses: actions/cache@v4
151182
with:
152183
path: .work/pkg
153184
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
@@ -160,28 +191,85 @@ jobs:
160191
run: make -j2 test
161192

162193
- name: Publish Unit Test Coverage
163-
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
194+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
164195
with:
165196
flags: unittests
166197
file: _output/tests/linux_amd64/coverage.txt
167198

168-
publish-artifacts:
169-
runs-on: ubuntu-22.04
199+
local-deploy:
200+
runs-on: ubuntu-24.04
170201
needs: detect-noop
171202
if: needs.detect-noop.outputs.noop != 'true'
172203

204+
steps:
205+
- name: Checkout
206+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
207+
with:
208+
submodules: true
209+
210+
- name: Fetch History
211+
run: git fetch --prune --unshallow
212+
213+
- name: Setup Go
214+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
215+
with:
216+
go-version: ${{ env.GO_VERSION }}
217+
218+
- name: Find the Go Build Cache
219+
id: go
220+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
221+
222+
- name: Cache the Go Build Cache
223+
uses: actions/cache@v4
224+
with:
225+
path: ${{ steps.go.outputs.cache }}
226+
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
227+
restore-keys: ${{ runner.os }}-build-unit-tests-
228+
229+
- name: Cache Go Dependencies
230+
uses: actions/cache@v4
231+
with:
232+
path: .work/pkg
233+
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
234+
restore-keys: ${{ runner.os }}-pkg-
235+
236+
- name: Vendor Dependencies
237+
run: make vendor vendor.check
238+
239+
- name: Deploying locally built provider package
240+
run: make local-deploy
241+
242+
publish-artifacts:
243+
runs-on: ubuntu-24.04
244+
needs:
245+
- detect-noop
246+
- report-breaking-changes
247+
- lint
248+
- check-diff
249+
- unit-tests
250+
- local-deploy
251+
if: needs.detect-noop.outputs.noop != 'true'
252+
173253
steps:
174254
- name: Setup QEMU
175255
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
176256
with:
177257
platforms: all
178258

179259
- name: Setup Docker Buildx
180-
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
260+
uses: docker/setup-buildx-action@v3
181261
with:
182262
version: ${{ env.DOCKER_BUILDX_VERSION }}
183263
install: true
184264

265+
- name: Login to Upbound
266+
uses: docker/login-action@v3
267+
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
268+
with:
269+
registry: xpkg.upbound.io
270+
username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
271+
password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }}
272+
185273
- name: Checkout
186274
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
187275
with:
@@ -197,17 +285,17 @@ jobs:
197285

198286
- name: Find the Go Build Cache
199287
id: go
200-
run: echo "::set-output name=cache::$(make go.cachedir)"
288+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
201289

202290
- name: Cache the Go Build Cache
203-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
291+
uses: actions/cache@v4
204292
with:
205293
path: ${{ steps.go.outputs.cache }}
206294
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}
207295
restore-keys: ${{ runner.os }}-build-publish-artifacts-
208296

209297
- name: Cache Go Dependencies
210-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
298+
uses: actions/cache@v4
211299
with:
212300
path: .work/pkg
213301
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
@@ -222,24 +310,13 @@ jobs:
222310
# We're using docker buildx, which doesn't actually load the images it
223311
# builds by default. Specifying --load does so.
224312
BUILD_ARGS: "--load"
225-
226-
- name: Publish Artifacts to GitHub
227-
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
313+
314+
- name: Upload Artifacts to GitHub
315+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
228316
with:
229317
name: output
230318
path: _output/**
231319

232-
- name: Login to Upbound
233-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
234-
if: env.XPKG_ACCESS_ID != ''
235-
with:
236-
registry: xpkg.upbound.io
237-
username: ${{ secrets.XPKG_ACCESS_ID }}
238-
password: ${{ secrets.XPKG_TOKEN }}
239-
240320
- name: Publish Artifacts
321+
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
241322
run: make publish BRANCH_NAME=${GITHUB_REF##*/}
242-
if: env.XPKG_ACCESS_ID != ''
243-
env:
244-
UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.XPKG_ACCESS_ID }}
245-
UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW: ${{ secrets.XPKG_TOKEN }}

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "build"]
22
path = build
3-
url = https://github.com/upbound/build
3+
url = https://github.com/crossplane/build

.golangci.yml

+18-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
run:
2-
deadline: 10m
3-
4-
skip-files:
5-
- "zz_\\..+\\.go$"
2+
timeout: 10m
63

74
output:
8-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
9-
format: colored-line-number
5+
formats:
6+
- format: colored-line-number
107

118
linters-settings:
129
errcheck:
@@ -21,15 +18,14 @@ linters-settings:
2118
# [deprecated] comma-separated list of pairs of the form pkg:regex
2219
# the regex is used to ignore names within pkg. (default "fmt:.*").
2320
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
24-
ignore: fmt:.*,io/ioutil:^Read.*
21+
exclude-functions:
22+
- fmt:.*
23+
- io/ioutil:^Read.*
2524

2625
govet:
2726
# report about shadowed variables
28-
check-shadowing: false
29-
30-
golint:
31-
# minimal confidence for issues, default is 0.8
32-
min-confidence: 0.8
27+
disable:
28+
- shadow
3329

3430
gofmt:
3531
# simplify code: gofmt with `-s` option, true by default
@@ -38,16 +34,12 @@ linters-settings:
3834
goimports:
3935
# put imports beginning with prefix after 3rd-party packages;
4036
# it's a comma-separated list of prefixes
41-
local-prefixes: github.com/crossplane-contrib/provider-jet-template
37+
local-prefixes: github.com/upbound/upjet-provider-template
4238

4339
gocyclo:
4440
# minimal code complexity to report, 30 by default (but we recommend 10-20)
4541
min-complexity: 10
4642

47-
maligned:
48-
# print struct with more effective memory layout or not, false by default
49-
suggest-new: true
50-
5143
dupl:
5244
# tokens count to trigger issue, 150 by default
5345
threshold: 100
@@ -67,8 +59,8 @@ linters-settings:
6759
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
6860
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
6961
# with golangci-lint call it on a directory with the changed file.
70-
check-exported: false
71-
62+
exported-fields-are-used: false
63+
7264
unparam:
7365
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
7466
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
@@ -104,16 +96,16 @@ linters-settings:
10496

10597
linters:
10698
enable:
107-
- megacheck
99+
- gosimple
100+
- staticcheck
101+
- unused
108102
- govet
109103
- gocyclo
110104
- gocritic
111-
- interfacer
112105
- goconst
113106
- goimports
114107
- gofmt # We enable this as well as goimports for its simplify mode.
115108
- prealloc
116-
- golint
117109
- unconvert
118110
- misspell
119111
- nakedret
@@ -125,6 +117,9 @@ linters:
125117

126118

127119
issues:
120+
exclude-files:
121+
- "zz_\\..+\\.go$"
122+
128123
# Excluding configuration per-path and per-linter
129124
exclude-rules:
130125
# Exclude some linters from running on tests files.
@@ -189,7 +184,7 @@ issues:
189184
new: false
190185

191186
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
192-
max-per-linter: 0
187+
max-issues-per-linter: 0
193188

194189
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
195190
max-same-issues: 0

0 commit comments

Comments
 (0)