mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-16 17:56:37 +00:00
Merge pull request #945 from breed808/ci_master_pushes
Run CI on pushes to master branch
This commit is contained in:
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -1,8 +1,11 @@
|
|||||||
name: windows_exporter CI/CD
|
name: windows_exporter CI/CD
|
||||||
|
|
||||||
# Trigger on pull requests and releases
|
# Trigger on pull requests, releases and pushes to master branch.
|
||||||
# Deployments will only occur for releases (see `if` clauses in the build job).
|
# Deployments will only occur for releases (see `if` clauses in the build job).
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@@ -170,7 +173,7 @@ jobs:
|
|||||||
promu checksum output\
|
promu checksum output\
|
||||||
|
|
||||||
- name: Login to GitHub container registry
|
- name: Login to GitHub container registry
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
|||||||
@@ -24,19 +24,27 @@ $skip_re = "^(go_|windows_exporter_build_info|windows_exporter_collector_duratio
|
|||||||
# Use default collectors, port and address: http://localhost:9182/metrics
|
# Use default collectors, port and address: http://localhost:9182/metrics
|
||||||
$exporter_proc = Start-Process `
|
$exporter_proc = Start-Process `
|
||||||
-PassThru `
|
-PassThru `
|
||||||
-FilePath .\windows_exporter.exe `
|
-FilePath ..\windows_exporter.exe `
|
||||||
-ArgumentList "--log.level=debug --collector.textfile.directory=$($textfile_dir)" `
|
-ArgumentList "--log.level=debug --collector.textfile.directory=$($textfile_dir)" `
|
||||||
-WindowStyle Hidden `
|
-WindowStyle Hidden `
|
||||||
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
|
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
|
||||||
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
|
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
|
||||||
|
|
||||||
# Give exporter some time to start
|
# Exporter can take some time to start
|
||||||
Start-Sleep 3
|
for ($i=1; $i -le 5; $i++) {
|
||||||
|
Start-Sleep 10
|
||||||
|
|
||||||
|
$netstat_output = netstat -anp tcp | Select-String 'listening'
|
||||||
|
if ($netstat_output -like '*:9182*') {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Write-Host "Waiting for exporter to start"
|
||||||
|
}
|
||||||
|
|
||||||
$response = Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9182/metrics
|
$response = Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9182/metrics
|
||||||
# Response output must be split and saved as UTF-8.
|
# Response output must be split and saved as UTF-8.
|
||||||
$response.content -split "[`r`n]"| Select-String -NotMatch $skip_re | Set-Content -Encoding utf8 "$($temp_dir)/e2e-output.txt"
|
$response.content -split "[`r`n]"| Select-String -NotMatch $skip_re | Set-Content -Encoding utf8 "$($temp_dir)/e2e-output.txt"
|
||||||
Stop-Process $exporter_proc
|
Stop-Process -Id $exporter_proc.Id
|
||||||
$output_diff = Compare-Object (Get-Content 'e2e-output.txt') (Get-Content "$($temp_dir)/e2e-output.txt")
|
$output_diff = Compare-Object (Get-Content 'e2e-output.txt') (Get-Content "$($temp_dir)/e2e-output.txt")
|
||||||
|
|
||||||
# Fail if differences in output are detected
|
# Fail if differences in output are detected
|
||||||
|
|||||||
@@ -88,23 +88,32 @@ Push-Location $working_dir
|
|||||||
$temp_dir = Join-Path $env:TEMP $(New-Guid) | ForEach-Object { mkdir $_ }
|
$temp_dir = Join-Path $env:TEMP $(New-Guid) | ForEach-Object { mkdir $_ }
|
||||||
|
|
||||||
# Start process in background, awaiting HTTP requests.
|
# Start process in background, awaiting HTTP requests.
|
||||||
# Use default collectors, port and address: http://localhost:9182/metrics
|
# Listen on 9183/TCP, preventing conflicts with 9182/TCP used by end-to-end-test.ps1
|
||||||
|
# Not an issue when run individually, but will cause failures when run concurrently in CI.
|
||||||
$exporter_proc = Start-Process `
|
$exporter_proc = Start-Process `
|
||||||
-PassThru `
|
-PassThru `
|
||||||
-FilePath .\windows_exporter.exe `
|
-FilePath ..\windows_exporter.exe `
|
||||||
-ArgumentList "--log.level=debug" `
|
-ArgumentList '--telemetry.addr="127.0.0.1:9183" --log.level=debug' `
|
||||||
-WindowStyle Hidden `
|
-WindowStyle Hidden `
|
||||||
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
|
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
|
||||||
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
|
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
|
||||||
|
|
||||||
# Give exporter some time to start
|
# Exporter can take some time to start
|
||||||
Start-Sleep 3
|
for ($i=1; $i -le 5; $i++) {
|
||||||
|
Start-Sleep 10
|
||||||
|
|
||||||
|
$netstat_output = netstat -anp tcp | Select-String 'listening'
|
||||||
|
if ($netstat_output -like '*:9183*') {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Write-Host "Waiting for exporter to start"
|
||||||
|
}
|
||||||
|
|
||||||
# Omit metrics from client_golang library; we're not responsible for these
|
# Omit metrics from client_golang library; we're not responsible for these
|
||||||
$skip_re = "^[#]?\s*(HELP|TYPE)?\s*go_"
|
$skip_re = "^[#]?\s*(HELP|TYPE)?\s*go_"
|
||||||
|
|
||||||
# Need to remove carriage returns, as promtool expects LF line endings
|
# Need to remove carriage returns, as promtool expects LF line endings
|
||||||
$output = ((Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9182/metrics).Content) -Split "`r?`n" | Select-String -NotMatch $skip_re | Join-String -Separator "`n"
|
$output = ((Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9183/metrics).Content) -Split "`r?`n" | Select-String -NotMatch $skip_re | Join-String -Separator "`n"
|
||||||
# Join the split lines back to a single String (with LF line endings!)
|
# Join the split lines back to a single String (with LF line endings!)
|
||||||
$output = $output -Join "`n"
|
$output = $output -Join "`n"
|
||||||
Stop-Process -Id $exporter_proc.Id
|
Stop-Process -Id $exporter_proc.Id
|
||||||
|
|||||||
Reference in New Issue
Block a user