Skip to content

Commit

Permalink
ci: run test on Windows (elastic#15570)
Browse files Browse the repository at this point in the history
* feat: run test on Windows

* chore: parameter to enable/disable windows test

* deleteDir before of the checkout

* Update Jenkinsfile

* Update Jenkinsfile

* Update Jenkinsfile

* Update Jenkinsfile

* Update Jenkinsfile

* Apply suggestions from code review

* feat: apply dependency hierarchies

* fit: use isChanged for all matches, and add the libbeat match where it is needed

* feat: add x-pack/winlogbeat windows unit tests

* fix: duplicate when condition

* Update Jenkinsfile

Co-Authored-By: Andrew Kroh <andrew.kroh@elastic.co>

Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
  • Loading branch information
2 people authored and v1v committed Oct 16, 2020
1 parent 4f83202 commit 4568ce9
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .ci/scripts/install-tools.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set GOPATH=%WORKSPACE%
set MAGEFILE_CACHE=%WORKSPACE%\.magefile
set PATH=%WORKSPACE%\bin;C:\ProgramData\chocolatey\bin;%PATH%

where /q curl
IF ERRORLEVEL 1 (
choco install curl -y --no-progress --skipdownloadcache
)
mkdir %WORKSPACE%\bin
where /q gvm
IF ERRORLEVEL 1 (
curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.1/gvm-windows-amd64.exe
)
FOR /f "tokens=*" %%i IN ('"gvm.exe" use %GO_VERSION% --format=batch') DO %%i

go install github.com/elastic/beats/vendor/github.com/magefile/mage
77 changes: 75 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pipeline {
}
parameters {
booleanParam(name: 'runAllStages', defaultValue: false, description: 'Allow to run all stages.')
booleanParam(name: 'windowsTest', defaultValue: true, description: 'Allow Windows stages.')
}
stages {
stage('Checkout') {
Expand All @@ -57,6 +58,7 @@ pipeline {
retryWithSleep(retries: 2, seconds: 5){ sh(label: "Install Go ${env.GO_VERSION}", script: '.ci/scripts/install-go.sh') }
}
}
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
}
}
stage('Lint'){
Expand Down Expand Up @@ -175,6 +177,9 @@ def k8sTest(Map args = [:]) {
} finally {
sh(label: 'Delete cluster', script: 'kind delete cluster')
}
steps {
mageTargetWin("Functionbeat Windows Unit test", "-d x-pack/functionbeat goUnitTest")
}
}
}
}
Expand Down Expand Up @@ -633,8 +638,76 @@ class GetProjectDependencies extends co.elastic.beats.BeatsFunction {
}

def isChanged(patterns){
return (params.runAllStages
return (
params.runAllStages
|| isGitRegionMatch(patterns: patterns, comparator: 'regexp')
|| isGitRegionMatch(patterns: ["^libbeat/.*"], comparator: 'regexp')
)
}

def loadConfigEnvVars(){
env.BUILD_AUDITBEAT = isChanged(["^auditbeat/.*"])
env.BUILD_AUDITBEAT_XPACK = isChanged([
"^auditbeat/.*",
"^x-pack/auditbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_DOCKERLOGBEAT_XPACK = isChanged([
"^x-pack/dockerlogbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_DOCS = isChanged(
patterns: ["^docs/.*"],
comparator: 'regexp'
)
env.BUILD_FILEBEAT = isChanged(["^filebeat/.*"])
env.BUILD_FILEBEAT_XPACK = isChanged([
"^filebeat/.*",
"^x-pack/filebeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_FUNCTIONBEAT_XPACK = isChanged([
"^x-pack/functionbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_GENERATOR = isChanged(["^generator/.*"])
env.BUILD_HEARTBEAT = isChanged(["^heartbeat/.*"])
env.BUILD_HEARTBEAT_XPACK = isChanged([
"^heartbeat/.*",
"^x-pack/heartbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_JOURNALBEAT = isChanged(["^journalbeat/.*"])
env.BUILD_JOURNALBEAT_XPACK = isChanged([
"^journalbeat/.*",
"^x-pack/journalbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_KUBERNETES = isChanged(["^deploy/kubernetes/*"])
env.BUILD_LIBBEAT = isChanged(
patterns: ["^libbeat/.*"],
comparator: 'regexp'
)
env.BUILD_LIBBEAT_XPACK = isChanged([
"^libbeat/.*",
"^x-pack/libbeat/.*",
])
env.BUILD_METRICBEAT = isChanged(["^metricbeat/.*"])
env.BUILD_METRICBEAT_XPACK = isChanged([
"^metricbeat/.*",
"^x-pack/libbeat/.*",
"^x-pack/metricbeat/.*",
])
env.BUILD_PACKETBEAT = isChanged(["^packetbeat/.*"])
env.BUILD_PACKETBEAT_XPACK = isChanged([
"^packetbeat/.*",
"^x-pack/libbeat/.*",
"^x-pack/packetbeat/.*",
])
env.BUILD_WINLOGBEAT = isChanged(["^winlogbeat/.*"])
env.BUILD_WINLOGBEAT_XPACK = isChanged([
"^winlogbeat/.*",
"^x-pack/libbeat/.*",
"^x-pack/winlogbeat/.*",
])
env.GO_VERSION = readFile(".go-version").trim()
}

0 comments on commit 4568ce9

Please sign in to comment.