@@ -116,90 +116,83 @@ jobs:
116
116
name : spdx.json
117
117
path : sbom/spdx.json
118
118
119
-
120
- unittests-k0s-linux-amd64 :
121
- name : " Unit tests :: linux-amd64"
122
- runs-on : ubuntu-22.04
123
-
124
- steps :
125
- - name : Check out code into the Go module directory
126
- uses : actions/checkout@v4
127
- with :
128
- persist-credentials : false
129
-
130
- - name : Cache GOCACHE
131
- uses : actions/cache@v4
132
- with :
133
- key : unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-${{ github.sha }}
134
- restore-keys : |
135
- unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-
136
- build-k0s-linux-amd64-gocache-${{ github.ref_name }}-
137
- path : |
138
- build/cache/go/build
139
-
140
- - name : Cache GOMODCACHE
141
- uses : actions/cache@v4
142
- with :
143
- key : unittests-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
144
- restore-keys : |
145
- build-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
146
- path : |
147
- build/cache/go/mod
148
-
149
- - name : Run unit tests
150
- env :
151
- EMBEDDED_BINS_BUILDMODE : none
152
- run : make check-unit
153
-
154
- unittests-k0s-windows-amd64 :
155
- name : " Unit tests :: windows-amd64"
156
- runs-on : windows-2022
119
+ unittests-k0s :
120
+ strategy :
121
+ fail-fast : false
122
+ matrix :
123
+ include :
124
+ - name : linux-amd64
125
+ runs-on : ubuntu-22.04
126
+ - name : windows-amd64
127
+ runs-on : windows-2022
128
+ target-os : windows
129
+ - name : macos-arm64
130
+ runs-on : macos-15
131
+ target-os : darwin
132
+
133
+ name : " Unit tests :: k0s :: ${{ matrix.name }}"
134
+ runs-on : " ${{ matrix.runs-on }}"
157
135
158
136
defaults :
159
137
run :
160
138
shell : bash
161
139
140
+ env :
141
+ EMBEDDED_BINS_BUILDMODE : none
142
+
162
143
steps :
163
- - name : Check out
144
+ - name : Check out code into the Go module directory
164
145
uses : actions/checkout@v4
165
146
with :
166
147
persist-credentials : false
167
148
149
+ - name : Prepare unit tests
150
+ if : matrix.target-os != ''
151
+ run : |
152
+ cat <<EOF >>"$GITHUB_ENV"
153
+ TARGET_OS=${{ matrix.target-os }}
154
+ GO=go
155
+ GO_ENV=
156
+ GOCACHE=$GITHUB_WORKSPACE/build/cache/go/build
157
+ GOMODCACHE=$GITHUB_WORKSPACE/build/cache/go/mod
158
+ UNITTEST_EXTRA_ARGS=BUILD_GO_LDFLAGS_EXTRA=
159
+ EOF
160
+
161
+ echo ::group::Build Environment
162
+ cat -- "$GITHUB_ENV"
163
+ echo ::endgroup::
164
+
165
+ mkdir -p build/cache
166
+ make --touch .k0sbuild.docker-image.k0s
167
+
168
168
- name : Prepare build environment
169
169
run : .github/workflows/prepare-build-env.sh
170
170
171
171
- name : Set up Go
172
- uses : actions/setup-go@v3
172
+ uses : actions/setup-go@v5
173
+ if : matrix.target-os != ''
173
174
with :
174
175
go-version : ${{ env.GO_VERSION }}
176
+ cache : false
175
177
176
178
- name : Cache GOCACHE
177
179
uses : actions/cache@v4
178
180
with :
179
- key : unittests-k0s-windows-amd64 -gocache-${{ github.ref_name }}-${{ github.sha }}
181
+ key : unittests-k0s-${{ matrix.name }} -gocache-${{ github.ref_name }}-${{ github.sha }}
180
182
restore-keys : |
181
- unittests-k0s-windows-amd64 -gocache-${{ github.ref_name }}-
183
+ unittests-k0s-${{ matrix.name }} -gocache-${{ github.ref_name }}-
182
184
path : |
183
- ~\AppData\Local\go- build
185
+ build/cache/go/ build
184
186
185
187
- name : Cache GOMODCACHE
186
188
uses : actions/cache@v4
187
189
with :
188
- key : unittests-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
189
- restore-keys : |
190
- build-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
190
+ key : unittests-k0s-gomodcache-${{ hashFiles('go.sum') }}
191
191
path : |
192
- ~\go\pkg\ mod
192
+ build/cache/go/ mod
193
193
194
194
- name : Run unit tests
195
- env :
196
- EMBEDDED_BINS_BUILDMODE : none
197
- TARGET_OS : windows
198
- GO : go
199
- GO_ENV : ' '
200
- run : |
201
- make --touch .k0sbuild.docker-image.k0s
202
- make check-unit
195
+ run : make check-unit $UNITTEST_EXTRA_ARGS
203
196
204
197
smoketests :
205
198
strategy :
0 commit comments