Skip to content

Commit ad76050

Browse files
authored
[chore] enable windows container builds on CI (open-telemetry#1154)
add core arm64 update package tests to new package naming scheme update snapshot version config remove arch from k8s since its not needed Revert "refactoring" This reverts commit 590644c. change variable back add prev version to correct step add needs copy over prev tag job refactoring dont run docker tests on windows arm minor changes replace shorthand with longer version try again with windows 2022 runner build local windows image for 2025 try mounting folder on windows try double forward slashes Revert "try again" This reverts commit ccb23f0 remove double backslashes try with redirection after log file name try again fix log file name try backticks try with PS try again on bash for windows try more things revert prep changes again try output redirection again revert cmd option newline revert some variable prep changes fix logging try with newline try shorthand and again try again with PS try running separate docker run cmd for windows more default shells Revert "more default shells" This reverts commit 55ba0ae. set bash as default shell see if explicitely splitting args works one step closer fix more quotes add missing quote remove dash set tag env var correctly use runner_temp dir to be OS independent fix docker cmd set windows dockerfile try building on windows without actions and buildx enable buildx also on windows build container images for testing try to go back to single version without specific OS add back os conditional run variable output on bash more debugging try without quotes debugging try again without backslashes combine linux and windows var prep try to set variables separately for windows also run echo step set variables also on windows try running docker tests on windows runner try to fix version numbers for msi installers fix job name try fixing otelcol core wxs version templating try again to just build MSIs just run docker tests on linux runners simplify variable prep step try running more steps on windows enable windows builds on other distros disable qemu on windows docker-tests job disable msi builds on snapshot builds remove wixl on windows remove unneeded conditional revert removal of wixl Revert "revert changes to windows runner" This reverts commit 6ce5fa6. Revert "disable windows container building skips" This reverts commit cf2f10d. Revert "remove windows skips from goreleaser cfg" This reverts commit b6f4918. Revert "only build windows containers" This reverts commit 69c606c. only build windows containers remove windows skips from goreleaser cfg disable windows container building skips revert changes to windows runner more skipping remove wixl step
1 parent fec0c8f commit ad76050

File tree

6 files changed

+129
-41
lines changed

6 files changed

+129
-41
lines changed

.github/workflows/base-ci-goreleaser.yaml

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,19 @@ jobs:
9595
fetch-depth: 0
9696

9797
- name: Setup QEMU
98+
if: runner.os != 'Windows'
9899
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
99100
with:
100101
platforms: arm64,ppc64le,linux/arm/v7,s390x,riscv64
101102

102103
- name: Setup wixl # Required to build MSI packages for Windows
103-
if: ${{ matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') }}
104+
if: runner.os != 'Windows'
104105
run: |
105106
sudo apt-get update
106107
sudo apt-get install -y wixl
107108
108109
- name: Setup Docker Buildx
110+
if: runner.os != 'Windows'
109111
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
110112

111113
- name: Setup Go
@@ -186,7 +188,7 @@ jobs:
186188
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/
187189

188190
- name: Show built or downloaded content
189-
if: inputs.distribution == 'otelcol-contrib'
191+
if: inputs.distribution == 'otelcol-contrib' && runner.os != 'Windows'
190192
run: ls -laR distributions/otelcol-contrib/artifacts
191193

192194
- name: Run GoReleaser for ${{ inputs.distribution }}
@@ -212,7 +214,7 @@ jobs:
212214
run: cat ./distributions/${{ inputs.distribution }}/dist/**/metadata.json
213215

214216
- name: Print dist folder contents
215-
if: always()
217+
if: always() && runner.os != 'Windows'
216218
run: ls -laR ./distributions/${{ inputs.distribution }}/dist
217219

218220
- name: Upload linux service packages
@@ -232,53 +234,66 @@ jobs:
232234
if-no-files-found: error
233235

234236
- name: Prepare variables
235-
if: matrix.GOOS == 'linux'
237+
if: matrix.GOOS == 'linux' || matrix.GOOS == 'windows'
236238
id: prep
239+
shell: bash
237240
run: |
238241
# Find version number and types of built artifacts
239-
echo "version=$(cat ./distributions/${{ inputs.distribution }}/dist/**/metadata.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
240-
echo "types=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq '[.[].type]' | tr -d '\n' )" >> "$GITHUB_OUTPUT"
241-
242-
# Find GOOS and GOARCH
243-
os=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq -r '.[] | select(.name | contains(".tar.gz")) | .goos')
244-
arch=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq -r '.[] | select(.name | contains(".tar.gz")) | .goarch')
245-
echo "arch=$os-$arch" >> "$GITHUB_OUTPUT"
246-
242+
version=$(cat ./distributions/${{ inputs.distribution }}/dist/**/metadata.json | jq -r '.version')
243+
arch="${{ matrix.GOOS }}-${{ matrix.GOARCH }}"
244+
245+
echo "version=$version" >> $GITHUB_OUTPUT
246+
echo "arch=$arch" >> $GITHUB_OUTPUT
247+
echo "types=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq '[.[].type]' | tr -d '\n' )" >> $GITHUB_OUTPUT
248+
247249
# Find binary path
248-
echo "binary-path=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq -r 'map(select(any(.type; contains("Binary")))) | .[].path' )" >> "$GITHUB_OUTPUT"
250+
echo "binarypath=$(cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json | jq -r 'map(select(any(.type; contains("Binary")))) | .[].path' )" >> "$GITHUB_OUTPUT"
251+
252+
echo "TAG=${{ inputs.distribution }}:$version-$arch" >> $GITHUB_ENV
253+
249254
250255
- name: Print version and target
251-
if: matrix.GOOS == 'linux'
256+
if: matrix.GOOS == 'linux' || matrix.GOOS == 'windows'
252257
run: |
253258
echo 'Version: ${{ steps.prep.outputs.version }}'
254259
echo 'Types: ${{ steps.prep.outputs.types }}'
255260
echo 'Arch: ${{ steps.prep.outputs.arch }}'
261+
echo 'Binary path: ${{ steps.prep.outputs.binarypath }}'
256262
echo 'Images?: ${{ steps.prep.outputs.container-images }}'
263+
echo 'Image tag: ${{ env.TAG }}'
257264
258265
- name: Copy binary to distro root folder
259-
if: matrix.GOOS == 'linux'
260-
run: cp ./distributions/${{ inputs.distribution }}/${{ steps.prep.outputs.binary-path }} ./distributions/${{ inputs.distribution }}
266+
if: matrix.GOOS == 'linux' || matrix.GOOS == 'windows'
267+
run: cp ./distributions/${{ inputs.distribution }}/${{ steps.prep.outputs.binarypath }} ./distributions/${{ inputs.distribution }}
261268

262-
- name: Build container images locally
269+
- name: Build container images locally (Linux)
263270
if: matrix.GOOS == 'linux' && contains(steps.prep.outputs.types, 'Docker Image')
264271
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
265272
with:
266273
context: ./distributions/${{ inputs.distribution }}
267274
push: false
268275
load: true
269-
tags: ${{ inputs.distribution }}:${{ steps.prep.outputs.version }}-${{ steps.prep.outputs.arch }}
276+
tags: ${{ env.TAG }}
277+
278+
- name: Build container images locally (Windows)
279+
if: matrix.GOOS == 'windows' && contains(steps.prep.outputs.types, 'Docker Image')
280+
run: |
281+
docker build -f ./distributions/${{ inputs.distribution }}/Windows.dockerfile `
282+
-t ${{ env.TAG }} `
283+
--build-arg WIN_VERSION=2022 `
284+
./distributions/${{ inputs.distribution }}/
270285
271286
- name: Export container image to tarball
272-
if: matrix.GOOS == 'linux' && contains(steps.prep.outputs.types, 'Docker Image')
287+
if: (matrix.GOOS == 'linux' || matrix.GOOS == 'windows') && contains(steps.prep.outputs.types, 'Docker Image')
273288
run: |
274-
docker save ${{ inputs.distribution }}:${{ steps.prep.outputs.version }}-${{ steps.prep.outputs.arch }} > /tmp/${{ inputs.distribution }}.tar
289+
docker save ${{ env.TAG }} > ${{ runner.temp }}/${{ inputs.distribution }}.tar
275290
276291
- name: Upload container image artifact
277-
if: matrix.GOOS == 'linux' && contains(steps.prep.outputs.types, 'Docker Image')
292+
if: (matrix.GOOS == 'linux' || matrix.GOOS == 'windows') && contains(steps.prep.outputs.types, 'Docker Image')
278293
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
279294
with:
280295
name: ${{ inputs.distribution }}-image-${{ steps.prep.outputs.version }}-${{ steps.prep.outputs.arch }}
281-
path: /tmp/${{ inputs.distribution }}.tar
296+
path: ${{ runner.temp }}/${{ inputs.distribution }}.tar
282297
retention-days: 7
283298

284299
docker-tests:
@@ -291,43 +306,50 @@ jobs:
291306
exclude:
292307
- GOOS: darwin
293308
- GOOS: windows
309+
GOARCH: "386"
310+
- GOOS: windows
311+
GOARCH: arm64
294312
runs-on: ${{ inputs.runner_os }}
313+
env:
314+
TAG: ${{ needs.check-goreleaser.outputs.version }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
295315
steps:
296316
- name: Checkout
297317
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
298318

299319
- name: Setup QEMU
320+
if: runner.os != 'Windows'
300321
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
301322
with:
302323
platforms: arm64,ppc64le,linux/arm/v7,s390x,riscv64
303324

304325
- name: Download container image artifact
305326
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
306327
with:
307-
name: ${{ inputs.distribution }}-image-${{ needs.check-goreleaser.outputs.version }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
328+
name: ${{ inputs.distribution }}-image-${{ env.TAG }}
308329

309330
- name: Load image into docker
310331
run: |
311332
docker image load --input ./${{ inputs.distribution }}.tar
312333
docker image ls
313-
docker image inspect ${{ inputs.distribution }}:${{ needs.check-goreleaser.outputs.version }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
334+
docker image inspect ${{ inputs.distribution }}:${{ env.TAG }}
314335
315-
- name: Run container image
336+
- name: Run container image (Linux)
337+
if: matrix.GOOS == 'linux'
316338
run: |
317339
echo "Running container..."
318340
docker run --name ${{ inputs.distribution }} \
319341
-d \
320342
${{ inputs.docker_run_options }} \
321343
-v ${PWD}/tests/docker-tests/${{ inputs.config_file }}:/config.yaml \
322-
${{ inputs.distribution }}:${{ needs.check-goreleaser.outputs.version }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }} \
344+
${{ inputs.distribution }}:${{ env.TAG }} \
323345
${{ inputs.otelcol_run_options }} --config /config.yaml
324346
echo "docker ps:"
325347
echo ""
326348
docker ps
327349
echo "Sleeping for a bit..."
328350
sleep 10
329351
echo "Checking logs for correct startup..."
330-
docker logs ${{ inputs.distribution }} >& docker-logs-${{ inputs.distribution }}.log
352+
docker logs ${{ inputs.distribution }} &>docker-logs-${{ inputs.distribution }}.log
331353
if cat docker-logs-${{ inputs.distribution }}.log | grep "Everything is ready."; then
332354
echo "${{ inputs.distribution }} started up correctly"
333355
else
@@ -338,12 +360,40 @@ jobs:
338360
exit 1
339361
fi
340362
363+
- name: Run container image (Windows)
364+
if: matrix.GOOS == 'windows'
365+
run: |
366+
echo "Running container..."
367+
docker run --name ${{ inputs.distribution }} `
368+
-d `
369+
${{ inputs.docker_run_options }} `
370+
-v ${PWD}\tests\docker-tests:C:\config `
371+
${{ inputs.distribution }}:${{ env.TAG }} `
372+
--config C:\config\${{ inputs.config_file }} `
373+
${{ inputs.otelcol_run_options }}
374+
echo "docker ps:"
375+
echo ""
376+
docker ps
377+
echo "Sleeping for a bit..."
378+
sleep 10
379+
echo "Checking logs for correct startup..."
380+
docker logs ${{ inputs.distribution }} *> "docker-logs-${{ inputs.distribution }}.log"
381+
if (Get-Content docker-logs-${{ inputs.distribution }}.log | Select-String -Pattern "Everything is ready.") {
382+
echo "${{ inputs.distribution }} started up correctly"
383+
} else {
384+
echo "${{ inputs.distribution }} failed to start"
385+
echo "Printing container logs below..."
386+
echo ""
387+
Get-Content docker-logs-${{ inputs.distribution }}.log
388+
exit 1
389+
}
390+
341391
- name: Run golden tests
342392
if: matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' && inputs.distribution == 'otelcol-contrib'
343393
run: |
344394
echo "Running golden tests..."
345395
cd tests/golden
346-
MY_UID="$(id -u)" MY_GID="$(id -g)" IMG=${{ inputs.distribution }}:${{ needs.check-goreleaser.outputs.version }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }} docker compose up -d --wait
396+
MY_UID="$(id -u)" MY_GID="$(id -g)" IMG=${{ inputs.distribution }}:${{ env.TAG }} docker compose up -d --wait
347397
exit_code=$(docker wait golden)
348398
docker logs golden
349399
if [ "$exit_code" -ne 0 ]; then

.github/workflows/ci-goreleaser-contrib.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,32 @@ jobs:
3636
uses: ./.github/workflows/base-ci-goreleaser.yaml
3737
with:
3838
distribution: otelcol-contrib
39-
goos: '[ "linux", "windows", "darwin" ]'
39+
goos: '[ "linux", "darwin" ]'
4040
goarch: '[ "386", "amd64", "arm", "arm64", "ppc64le", "riscv64", "s390x" ]'
4141
secrets: inherit
4242

43+
check-goreleaser-windows:
44+
name: CI - Contrib - GoReleaser
45+
uses: ./.github/workflows/base-ci-goreleaser.yaml
46+
with:
47+
distribution: otelcol-contrib
48+
goos: '[ "windows" ]'
49+
goarch: '[ "386", "amd64", "arm64" ]'
50+
runner_os: 'windows-2022'
51+
secrets: inherit
52+
4353
package-tests:
44-
name: Package tests
45-
needs: check-goreleaser
46-
uses: ./.github/workflows/base-package-tests.yaml
47-
with:
48-
distribution: otelcol-contrib
49-
type: '[ "deb", "rpm" ]'
54+
name: Package tests
55+
needs: check-goreleaser
56+
uses: ./.github/workflows/base-package-tests.yaml
57+
with:
58+
distribution: otelcol-contrib
59+
type: '[ "deb", "rpm" ]'
5060

5161
msi-tests:
5262
name: MSI tests
53-
needs: check-goreleaser
63+
needs: check-goreleaser-windows
5464
uses: ./.github/workflows/msi-tests.yaml
5565
with:
5666
distribution: otelcol-contrib
5767
type: '[ "msi" ]'
58-

.github/workflows/ci-goreleaser-core.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,20 @@ jobs:
3636
uses: ./.github/workflows/base-ci-goreleaser.yaml
3737
with:
3838
distribution: otelcol
39-
goos: '[ "linux", "windows", "darwin" ]'
39+
goos: '[ "linux", "darwin" ]'
4040
goarch: '[ "386", "amd64", "arm", "arm64", "ppc64le", "riscv64", "s390x" ]'
4141
secrets: inherit
4242

43+
check-goreleaser-windows:
44+
name: CI - Core - GoReleaser
45+
uses: ./.github/workflows/base-ci-goreleaser.yaml
46+
with:
47+
distribution: otelcol
48+
goos: '[ "windows" ]'
49+
goarch: '[ "386", "amd64", "arm64" ]'
50+
runner_os: 'windows-2022'
51+
secrets: inherit
52+
4353
package-tests:
4454
name: Package tests
4555
needs: check-goreleaser
@@ -50,7 +60,7 @@ jobs:
5060

5161
msi-tests:
5262
name: MSI tests
53-
needs: check-goreleaser
63+
needs: check-goreleaser-windows
5464
uses: ./.github/workflows/msi-tests.yaml
5565
with:
5666
distribution: otelcol

.github/workflows/ci-goreleaser-k8s.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ jobs:
3939
goos: '[ "linux" ]'
4040
goarch: '[ "amd64", "arm64", "ppc64le", "riscv64", "s390x" ]'
4141
secrets: inherit
42+
check-goreleaser-windows:
43+
name: CI - k8s - GoReleaser
44+
uses: ./.github/workflows/base-ci-goreleaser.yaml
45+
with:
46+
distribution: otelcol-k8s
47+
goos: '[ "windows" ]'
48+
goarch: '[ "amd64" ]'
49+
runner_os: 'windows-2022'
50+
secrets: inherit

.github/workflows/ci-goreleaser-otlp.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ jobs:
3636
uses: ./.github/workflows/base-ci-goreleaser.yaml
3737
with:
3838
distribution: otelcol-otlp
39-
goos: '[ "linux", "windows", "darwin" ]'
39+
goos: '[ "linux", "darwin" ]'
4040
goarch: '[ "386", "amd64", "arm", "arm64", "ppc64le", "riscv64", "s390x" ]'
4141
secrets: inherit
42+
43+
check-goreleaser-windows:
44+
name: CI - OTLP - GoReleaser
45+
uses: ./.github/workflows/base-ci-goreleaser.yaml
46+
with:
47+
distribution: otelcol-otlp
48+
goos: '[ "windows" ]'
49+
goarch: '[ "386", "amd64", "arm64" ]'
50+
runner_os: 'windows-2022'
51+
secrets: inherit

cmd/msi-generator/windows-installer.wxs.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Name="OpenTelemetry Collector ({{ .Version }}) - {{ .Binary }} distribution"
55
Id="*"
66
UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3"
7-
Version="{{ .Version }}"
7+
Version="{{ if .IsSnapshot }}{{ .RawVersion }}{{ else }}{{ .Version }}{{ end }}"
88
Manufacturer="OpenTelemetry"
99
Language="1033">
1010

0 commit comments

Comments
 (0)