name: build-and-test-windows on: push: branches: [main] tags: - "v[0-9]+.[0-9]+.[0-9]+*" merge_group: types: [checks_requested] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref_name }} cancel-in-progress: true permissions: read-all jobs: windows-unittest: strategy: fail-fast: false matrix: os: [windows-2022, windows-2025, windows-11-arm] runs-on: ${{ matrix.os }} steps: - name: Checkout Repo uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - name: Setup Go uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 with: go-version: oldstable cache: false - name: Cache Go uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 env: cache-name: cache-go-modules with: path: | ~\go\pkg\mod ~\AppData\Local\go-build key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - name: Ensure required ports in the dynamic range are available run: | & ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 - name: Run Unit Tests run: make gotest windows-service-test: strategy: fail-fast: false matrix: os: [windows-2022, windows-2025, windows-11-arm] runs-on: ${{ matrix.os }} steps: - name: Checkout Repo uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - name: Setup Go uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 with: go-version: oldstable cache: false - name: Cache Go uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 env: cache-name: cache-go-modules with: path: | ~\go\pkg\mod ~\AppData\Local\go-build key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - name: Ensure required ports in the dynamic range are available run: | & ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 - name: Make otelcorecol run: make otelcorecol - name: Install otelcorecol as a service run: | New-Service -Name "otelcorecol" -StartupType "Manual" -BinaryPathName "${PWD}\bin\otelcorecol_windows_$(go env GOARCH) --config ${PWD}\examples\local\otel-config.yaml" eventcreate.exe /t information /id 1 /l application /d "Creating event provider for 'otelcorecol'" /so otelcorecol - name: Test otelcorecol service working-directory: ${{ github.workspace }}/otelcol run: | go test -timeout 90s -run ^TestCollectorAsService$ -v -tags=win32service - name: Remove otelcorecol service if: always() run: | Remove-Service otelcorecol Remove-Item HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\otelcorecol