| 1 |
name: build-and-test-windows |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [main] |
| 5 |
tags: |
| 6 |
- "v[0-9]+.[0-9]+.[0-9]+*" |
| 7 |
merge_group: |
| 8 |
types: [checks_requested] |
| 9 |
pull_request: |
| 10 |
|
| 11 |
concurrency: |
| 12 |
group: ${{ github.workflow }}-${{ github.ref_name }} |
| 13 |
cancel-in-progress: true |
| 14 |
|
| 15 |
permissions: read-all |
| 16 |
|
| 17 |
jobs: |
| 18 |
windows-unittest: |
| 19 |
strategy: |
| 20 |
fail-fast: false |
| 21 |
matrix: |
| 22 |
os: [windows-2022, windows-2025, windows-11-arm] |
| 23 |
runs-on: ${{ matrix.os }} |
| 24 |
steps: |
| 25 |
- name: Checkout Repo |
| 26 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 27 |
- name: Setup Go |
| 28 |
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 29 |
with: |
| 30 |
go-version: oldstable |
| 31 |
cache: false |
| 32 |
- name: Cache Go |
| 33 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 34 |
env: |
| 35 |
cache-name: cache-go-modules |
| 36 |
with: |
| 37 |
path: | |
| 38 |
~\go\pkg\mod |
| 39 |
~\AppData\Local\go-build |
| 40 |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 41 |
- name: Ensure required ports in the dynamic range are available |
| 42 |
run: | |
| 43 |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 |
| 44 |
- name: Run Unit Tests |
| 45 |
run: make gotest |
| 46 |
|
| 47 |
windows-service-test: |
| 48 |
strategy: |
| 49 |
fail-fast: false |
| 50 |
matrix: |
| 51 |
os: [windows-2022, windows-2025, windows-11-arm] |
| 52 |
runs-on: ${{ matrix.os }} |
| 53 |
steps: |
| 54 |
- name: Checkout Repo |
| 55 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 56 |
- name: Setup Go |
| 57 |
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 58 |
with: |
| 59 |
go-version: oldstable |
| 60 |
cache: false |
| 61 |
- name: Cache Go |
| 62 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 63 |
env: |
| 64 |
cache-name: cache-go-modules |
| 65 |
with: |
| 66 |
path: | |
| 67 |
~\go\pkg\mod |
| 68 |
~\AppData\Local\go-build |
| 69 |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 70 |
- name: Ensure required ports in the dynamic range are available |
| 71 |
run: | |
| 72 |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 |
| 73 |
|
| 74 |
- name: Make otelcorecol |
| 75 |
run: make otelcorecol |
| 76 |
|
| 77 |
- name: Install otelcorecol as a service |
| 78 |
run: | |
| 79 |
New-Service -Name "otelcorecol" -StartupType "Manual" -BinaryPathName "${PWD}\bin\otelcorecol_windows_$(go env GOARCH) --config ${PWD}\examples\local\otel-config.yaml" |
| 80 |
eventcreate.exe /t information /id 1 /l application /d "Creating event provider for 'otelcorecol'" /so otelcorecol |
| 81 |
|
| 82 |
- name: Test otelcorecol service |
| 83 |
working-directory: ${{ github.workspace }}/otelcol |
| 84 |
run: | |
| 85 |
go test -timeout 90s -run ^TestCollectorAsService$ -v -tags=win32service |
| 86 |
|
| 87 |
- name: Remove otelcorecol service |
| 88 |
if: always() |
| 89 |
run: | |
| 90 |
Remove-Service otelcorecol |
| 91 |
Remove-Item HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\otelcorecol |