Commit 694578b5 authored by Steve Azzopardi's avatar Steve Azzopardi

Merge branch '3757-make-ci-pipeline-working-on-windows' into 'master'

Make Runner tests working on Windows with our CI Pipeline

Closes #3757

See merge request !1219
parents 9368cf24 2b1641ac
Pipeline #50171984 passed with stages
in 52 minutes and 54 seconds
......@@ -237,26 +237,41 @@ unit test with race:
# # Check the internal links
# - bundle exec nanoc check internal_links
integration windows:
<<: *except_docs
.windows test:
extends: .except_docs
stage: test
parallel: 3
variables:
GOROOT: "C:\\Go"
PKG_NAMESPACE: gitlab.com\gitlab-org
PKG_NAME: gitlab-runner
GOPATH: "$CI_PROJECT_DIR\\.gopath"
PKG_BASE_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE"
PKG_BUILD_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE\\$PKG_NAME"
before_script:
- $GODIR = "$env:GOPATH\src\gitlab.com\gitlab-org"
- $target_path = "$GODIR\gitlab-runner"
- $current_path = pwd
- md $GODIR -Force
- if (Test-Path $target_path) { cmd /c rmdir $target_path }
- cmd /c mklink /D $target_path $current_path
- cd $GODIR\gitlab-runner
- if (Test-Path $GOPATH) { Remove-Item -Force -Recurse $GOPATH }
- New-Item $PKG_BASE_DIR -ItemType directory -Force
- New-Item -ItemType SymbolicLink -Path $PKG_BUILD_DIR -Value $CI_PROJECT_DIR
- cd $PKG_BUILD_DIR
script:
- $script = Join-Path -Path "ci" -ChildPath "test_windows.ps1"
- Invoke-Expression $script
- .\ci\test_windows.ps1
after_script:
- if (Test-Path $PKG_BUILD_DIR) { $(Get-Item $PKG_BUILD_DIR).Delete() }
allow_failure: true
only:
- /.*/@gitlab-org/gitlab-runner
windows 1803 tests:
extends: .windows test
tags:
- windows-1803
- shell
windows 1809 tests:
extends: .windows test
tags:
- integration
- windows
- windows-1809
- shell
git 1.7.1:
<<: *except_docs
......
param([string]$testOpts = "")
param(
[string]$testsDefinitionsFile = ".\testsdefinitions.txt"
)
$InformationPreference = "Continue"
function Get-Line([string]$file) {
(Get-Content $file | Measure-Object -Line).Lines
}
$numberOfDefinitions = Get-Line -file $testsDefinitionsFile
$executionSize = [int]($numberOfDefinitions / $env:CI_NODE_TOTAL)
$nodeIndex = $env:CI_NODE_INDEX - 1
$executionOffset = ($nodeIndex * $executionSize)
Write-Information "Number of definitions: $numberOfDefinitions"
Write-Information "Suite size: $env:CI_NODE_TOTAL"
Write-Information "Suite index: $env:CI_NODE_INDEX"
Write-Information "Execution size: $executionSize"
Write-Information "Execution offset: $executionOffset"
$failed = @()
go list ./... | Select-String -Pattern "gitlab.com/gitlab-org/gitlab-runner/vendor/" -NotMatch | ForEach-Object {
$pkg = %{$_ -replace "\r\n", "" }
$testCmd = "go test $testOpts $pkg"
Invoke-Expression $testCmd
if ( $LASTEXITCODE -ne 0 ) { $failed += $pkg }
Get-Content $testsDefinitionsFile | Select-Object -skip $executionOffset -first $executionSize | ForEach-Object {
$pkg, $index, $tests = $_.Split(" ", 3)
Write-Information "`r`n`r`n--- Starting part $index of go tests of '$pkg' package:`r`n`r`n"
go test -v $pkg -run "$tests"
if ($LASTEXITCODE -ne 0) {
$failed += "$pkg-$index"
}
}
if ($failed.count -ne 0) {
Write-Host "Failed packages"
$failed | Out-String | Write-Host
Write-Output ""
Write-Warning "Failed packages:"
$failed | Out-String | Write-Warning
exit 1
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment