-
Notifications
You must be signed in to change notification settings - Fork 3
195 lines (189 loc) · 7.61 KB
/
build-and-test-windows.yml
File metadata and controls
195 lines (189 loc) · 7.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: build-and-test-windows
on:
push:
branches:
- "main"
- "releases/**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
merge_group:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
# Make sure to exit early if cache segment download times out after 2 minutes.
# We limit cache download as a whole to 5 minutes.
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
# Do not cancel this workflow on main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: read-all
jobs:
setup-environment:
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
strategy:
fail-fast: true
matrix:
os: [ windows-latest, windows-11-arm ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
id: go-setup
with:
go-version: oldstable
cache-dependency-path: "**/*.sum"
- name: Install dependencies
if: steps.go-setup.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
if: steps.go-setup.outputs.cache-hit != 'true'
run: make install-tools
windows-smoke-build:
needs: [setup-environment]
strategy:
fail-fast: true
matrix:
os: [ windows-latest, windows-11-arm ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- run: ./.github/workflows/scripts/free-disk-space.sh
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
id: go-setup
with:
go-version: oldstable
cache-dependency-path: "**/*.sum"
- name: Install dependencies
if: steps.go-setup.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
if: steps.go-setup.outputs.cache-hit != 'true'
run: make install-tools
- name: Generate nrdotcol files
run: make gennrdotcol
- name: Build Collector
run: make nrdotcol
windows-unittest-matrix:
needs: [setup-environment]
strategy:
fail-fast: false
matrix:
group:
- receiver
- processor
- exporter
- extension
- connector
- internal
- pkg
- cmd
- other
os: [windows-2025, windows-11-arm]
runs-on: ${{ matrix.os }}
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
env:
# Limit memory usage via GC environment variables to avoid OOM on GH runners, especially for `cmd/nrdotcol`,
# see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/28682#issuecomment-1802296776
GOGC: 50
GOMEMLIMIT: 2GiB
# The gcc installed on the Windows arm64 runner doesn't ship native ARM libraries so we need to disable CGO.
CGO_ENABLED: ${{ matrix.os == 'windows-11-arm' && '0' || '' }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
id: go-setup
with:
go-version: oldstable
cache-dependency-path: "**/*.sum"
- name: Ensure required ports in the dynamic range are available
run: |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Build shared test tools
# If component tests share Makefile targets they need to be added here to avoid
# concurrent component tests clashing when building such targets. This applies
# specifically to Windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34691
run: make "$(${PWD} -replace '\\', '/')/.tools/gotestsum"
# Unit tests without JUnit output are much faster, so it's fine to run on every PR.
# The only time we don't run them is when we already ran them with JUnit output.
- name: Run Unit Tests
id: tests
if: github.ref != 'refs/heads/main'
run: make -j2 gotest GROUP=${{ matrix.group }}
# JUnit tests are super long, so we only run them on pushes to the main branch.
# This is used for automation that automatically creates issues for flaky tests that are
# merged to main, so we don't run them on every PR.
- name: Run Unit Tests With JUnit and Coverage
id: tests-with-junit
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
continue-on-error: true # Allow uploading artifacts even if the test fails
run: make gotest-with-junit-and-cover GROUP=${{ matrix.group }}
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
with:
name: test-results-windows-${{ matrix.os }}-${{ matrix.group }}
path: internal/tools/testresults/
retention-days: 4
- name: Fail workflow if tests fails
if: always()
shell: bash
run: |
if [[ "${{ steps.tests-with-junit.outcome }}" == "failure" || "${{ steps.tests.outcome }}" == "failure" ]]; then
echo "Tests failed. Failing workflow."
exit 1
else
echo "Tests passed or were skipped. Continuing."
fi
windows-unittest:
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
runs-on: windows-latest
needs: [windows-unittest-matrix]
steps:
- name: Print result
run: echo ${{ needs.windows-unittest-matrix.result }}
- name: Interpret result
shell: bash
run: |
if [[ success == ${{ needs.windows-unittest-matrix.result }} ]]
then
echo "All matrix jobs passed!"
else
echo "One or more matrix jobs failed."
false
fi
flakytests-generate-issues:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
strategy:
matrix:
os: [windows-2025, windows-11-arm]
runs-on: ubuntu-24.04
needs: [windows-unittest-matrix]
permissions:
issues: write
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
id: go-setup
with:
go-version: oldstable
cache-dependency-path: "**/*.sum"
- name: Install dependencies
if: steps.go-setup.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
if: steps.go-setup.outputs.cache-hit != 'true'
run: make install-tools
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
merge-multiple: true
pattern: test-results-windows-${{ matrix.os }}-*
path: ./internal/tools/testresults/
- name: Generate Issues
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make install-tools
./.tools/issuegenerator -path ./internal/tools/testresults/ -labels "flaky tests,needs triage"