mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-14 17:06:36 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9f4264fc4 | ||
|
|
27ceeecff3 | ||
|
|
1ba5835af6 | ||
|
|
0db956aa4d | ||
|
|
b6f88cbbdd | ||
|
|
4b9b9e97cb | ||
|
|
3ebe0e937e |
129
.github/workflows/ci.yml
vendored
Normal file
129
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
name: windows_exporter CI/CD
|
||||||
|
|
||||||
|
# Trigger on pull requests and releases
|
||||||
|
# Deployments will only occur for releases (see `if` clauses in the build job).
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
- edited
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: windows-2019
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '^1.17.5'
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Install e2e deps
|
||||||
|
run: |
|
||||||
|
go get -u github.com/prometheus/promu@v0.11.1
|
||||||
|
go get -u github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.2.0
|
||||||
|
# GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
|
||||||
|
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: e2e Test
|
||||||
|
run: make e2e-test
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: windows-2019
|
||||||
|
steps:
|
||||||
|
# `gofmt` linter run by golangci-lint fails on CRLF line endings (the default for Windows)
|
||||||
|
- name: Set git to use LF
|
||||||
|
run: |
|
||||||
|
git config --global core.autocrlf false
|
||||||
|
git config --global core.eol lf
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '^1.17.5'
|
||||||
|
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v2
|
||||||
|
with:
|
||||||
|
version: v1.43
|
||||||
|
args: "--timeout=5m"
|
||||||
|
|
||||||
|
# golangci-lint action doesn't always provide helpful output, so re-run without the action for
|
||||||
|
# better output of the problem.
|
||||||
|
# The cache from the golangci-lint step is re-used here, so this step should finish quickly.
|
||||||
|
- name: errors
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: golangci-lint run --timeout=5m -c .golangci.yaml
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: windows-2019
|
||||||
|
needs:
|
||||||
|
- test
|
||||||
|
- lint
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# fetch-depth required for gitversion in `Build` step
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '^1.17.5'
|
||||||
|
|
||||||
|
- name: Install Build deps
|
||||||
|
run: |
|
||||||
|
go get -u github.com/prometheus/promu@v0.11.1
|
||||||
|
go get -u github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.2.0
|
||||||
|
# GOPATH\bin dir must be added to PATH else the `promu` and `goversioninfo` commands won't be found
|
||||||
|
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
|
||||||
|
$Version = Get-Content VERSION
|
||||||
|
# Windows versioninfo resources need the file version by parts (but product version is free text)
|
||||||
|
$VersionParts = ($Version -replace '^v?([0-9\.]+).*$','$1').Split(".")
|
||||||
|
goversioninfo.exe -ver-major $VersionParts[0] -ver-minor $VersionParts[1] -ver-patch $VersionParts[2] -product-version $Version -platform-specific
|
||||||
|
|
||||||
|
make crossbuild
|
||||||
|
# GH requires all files to have different names, so add version/arch to differentiate
|
||||||
|
foreach($Arch in "amd64","386") {
|
||||||
|
Move-Item output\$Arch\windows_exporter.exe output\windows_exporter-$Version-$Arch.exe
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Upload Artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: windows_exporter_binaries
|
||||||
|
path: output\windows_exporter-*.exe
|
||||||
|
|
||||||
|
- name: Build Release Artifacts
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$BuildVersion = Get-Content VERSION
|
||||||
|
$TagName = $env:GITHUB_REF -replace 'refs/tags/', ''
|
||||||
|
# The MSI version is not semver compliant, so just take the numerical parts
|
||||||
|
$MSIVersion = $TagName -replace '^v?([0-9\.]+).*$','$1'
|
||||||
|
foreach($Arch in "amd64","386") {
|
||||||
|
Write-Verbose "Building windows_exporter $MSIVersion msi for $Arch"
|
||||||
|
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $MSIVersion -Arch "$Arch"
|
||||||
|
Move-Item installer\Output\windows_exporter-$MSIVersion-$Arch.msi output\
|
||||||
|
}
|
||||||
|
|
||||||
|
promu checksum output\
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
$TagName = $env:GITHUB_REF -replace 'refs/tags/', ''
|
||||||
|
Get-ChildItem -Path output\* -Include @('windows_exporter*.msi', 'windows_exporter*.exe', 'sha256sums.txt') | Foreach-Object {gh release upload $TagName $_}
|
||||||
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@ lint:
|
|||||||
|
|
||||||
.PHONY: e2e-test
|
.PHONY: e2e-test
|
||||||
e2e-test: windows_exporter.exe
|
e2e-test: windows_exporter.exe
|
||||||
powershell -NonInteractive -ExecutionPolicy Bypass -File .\tools\end-to-end-test.ps1
|
pwsh -NonInteractive -ExecutionPolicy Bypass -File .\tools\end-to-end-test.ps1
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
gofmt -l -w -s .
|
gofmt -l -w -s .
|
||||||
|
|||||||
81
appveyor.yml
81
appveyor.yml
@@ -1,81 +0,0 @@
|
|||||||
version: "{build}"
|
|
||||||
|
|
||||||
os: Visual Studio 2019
|
|
||||||
build: off
|
|
||||||
|
|
||||||
environment:
|
|
||||||
GOPATH: c:\gopath
|
|
||||||
GO111MODULE: on
|
|
||||||
|
|
||||||
clone_folder: c:\gopath\src\github.com\prometheus-community\windows_exporter
|
|
||||||
|
|
||||||
install:
|
|
||||||
- mkdir %GOPATH%\bin
|
|
||||||
- set PATH=%GOPATH%\bin;%PATH%
|
|
||||||
- set PATH=%PATH%;C:\msys64\mingw64\bin
|
|
||||||
- choco install gitversion.portable make -y
|
|
||||||
- ps: |
|
|
||||||
appveyor DownloadFile https://github.com/golangci/golangci-lint/releases/download/v1.43.0/golangci-lint-1.43.0-windows-amd64.zip
|
|
||||||
Expand-Archive golangci-lint-1.43.0-windows-amd64.zip
|
|
||||||
Move-Item golangci-lint-1.43.0-windows-amd64\golangci-lint-1.43.0-windows-amd64\golangci-lint.exe $env:GOPATH\bin\golangci-lint.exe
|
|
||||||
- go install github.com/prometheus/promu@v0.11.1
|
|
||||||
- go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.2.0
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- make test
|
|
||||||
|
|
||||||
after_test:
|
|
||||||
- make lint
|
|
||||||
- make e2e-test
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- ps: |
|
|
||||||
# go mod download (or, if we don't call it, go build) will write every dependent package name to
|
|
||||||
# stderr, which will be interpreted as an error and abort the build if ErrorActionPreference is Stop,
|
|
||||||
# so we need to run it before setting the preference.
|
|
||||||
go mod download
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
|
|
||||||
$Version = Get-Content VERSION
|
|
||||||
# Windows versioninfo resources need the file version by parts (but product version is free text)
|
|
||||||
$VersionParts = ($Version -replace '^v?([0-9\.]+).*$','$1').Split(".")
|
|
||||||
goversioninfo.exe -ver-major $VersionParts[0] -ver-minor $VersionParts[1] -ver-patch $VersionParts[2] -product-version $Version -platform-specific
|
|
||||||
|
|
||||||
make crossbuild
|
|
||||||
# GH requires all files to have different names, so add version/arch to differentiate
|
|
||||||
foreach($Arch in "amd64","386") {
|
|
||||||
Move-Item output\$Arch\windows_exporter.exe output\windows_exporter-$Version-$Arch.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
after_build:
|
|
||||||
- ps: |
|
|
||||||
# Build installer packages only on tagged releases
|
|
||||||
if($env:APPVEYOR_REPO_TAG -ne "True") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
$BuildVersion = Get-Content VERSION
|
|
||||||
# The MSI version is not semver compliant, so just take the numerical parts
|
|
||||||
$MSIVersion = $env:APPVEYOR_REPO_TAG_NAME -replace '^v?([0-9\.]+).*$','$1'
|
|
||||||
foreach($Arch in "amd64","386") {
|
|
||||||
Write-Verbose "Building windows_exporter $MSIVersion msi for $Arch"
|
|
||||||
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $MSIVersion -Arch "$Arch"
|
|
||||||
Move-Item installer\Output\windows_exporter-$MSIVersion-$Arch.msi output\
|
|
||||||
}
|
|
||||||
- promu checksum output\
|
|
||||||
|
|
||||||
artifacts:
|
|
||||||
- name: Artifacts
|
|
||||||
path: output\*
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
- provider: GitHub
|
|
||||||
description: windows_exporter version $(appveyor_build_version)
|
|
||||||
artifact: Artifacts
|
|
||||||
auth_token:
|
|
||||||
secure: 'hFR7Ymxt/Rb25p4BweFvMNhX03lHD9kXJXrRlC/KbThazHuLD5NTx2ibMI6LYRsr'
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
on:
|
|
||||||
appveyor_repo_tag: true
|
|
||||||
@@ -313,10 +313,11 @@ fileLoop:
|
|||||||
} else {
|
} else {
|
||||||
for _, mf := range metricFamilies {
|
for _, mf := range metricFamilies {
|
||||||
convertMetricFamily(mf, ch)
|
convertMetricFamily(mf, ch)
|
||||||
c.exportMTimes(mtimes, ch)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.exportMTimes(mtimes, ch)
|
||||||
|
|
||||||
// Export if there were errors.
|
// Export if there were errors.
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
prometheus.NewDesc(
|
prometheus.NewDesc(
|
||||||
|
|||||||
Reference in New Issue
Block a user