From ca8b659a06bcf484260248a32f6a87bef6aabc93 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 6 Jun 2022 15:36:12 +0200 Subject: [PATCH] ci(integration-cli): move integration-cli run to make script Signed-off-by: CrazyMax --- .github/workflows/windows.yml | 13 ++---------- hack/make.ps1 | 39 ++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8fc1a324c7..7d8f4b4f3d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -390,21 +390,12 @@ jobs: name: Test integration-cli if: matrix.test != './...' run: | - & gotestsum ` - --format=standard-verbose ` - --jsonfile="./bundles/go-test-report-int-cli-tests.json" ` - --junitfile="./bundles/junit-report-int-cli-tests.xml" ` - --packages="./integration-cli/..." ` - -- ` - "-coverprofile" "./bundles/coverage-report-int-cli-tests.txt" ` - "-covermode" "atomic" ` - "-tags" "autogen" ` - "-test.run" "(${{ matrix.test }})/" ` - "-test.timeout" "200m" + .\hack\make.ps1 -TestIntegrationCli env: DOCKER_HOST: npipe:////./pipe/docker_engine GO111MODULE: "off" TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker + INTEGRATION_TESTRUN: ${{ matrix.test }} - name: Send to Codecov if: matrix.os == 'windows-2022' diff --git a/hack/make.ps1 b/hack/make.ps1 index 8d1f7177a7..9359d8f52d 100644 --- a/hack/make.ps1 +++ b/hack/make.ps1 @@ -63,6 +63,9 @@ .PARAMETER TestIntegration Runs integration tests. +.PARAMETER TestIntegrationCli + Runs integration-cli tests. + .PARAMETER All Runs everything this script knows about that can run in a container. @@ -88,6 +91,7 @@ param( [Parameter(Mandatory=$False)][switch]$GoFormat, [Parameter(Mandatory=$False)][switch]$TestUnit, [Parameter(Mandatory=$False)][switch]$TestIntegration, + [Parameter(Mandatory=$False)][switch]$TestIntegrationCli, [Parameter(Mandatory=$False)][switch]$All ) @@ -383,6 +387,36 @@ Function Run-IntegrationTests() { } } +# Run the integration-cli tests +Function Run-IntegrationCliTests() { + Write-Host "INFO: Running integration-cli tests..." + + $goTestRun = "" + $reportSuffix = "" + if ($env:INTEGRATION_TESTRUN.Length -ne 0) + { + $goTestRun = "-test.run=($env:INTEGRATION_TESTRUN)/" + $reportSuffixStream = [IO.MemoryStream]::new([byte[]][char[]]$env:INTEGRATION_TESTRUN) + $reportSuffix = "-" + (Get-FileHash -InputStream $reportSuffixStream -Algorithm SHA256).Hash + } + + $jsonFilePath = $bundlesDir + "\go-test-report-int-cli-tests$reportSuffix.json" + $xmlFilePath = $bundlesDir + "\junit-report-int-cli-tests$reportSuffix.xml" + $coverageFilePath = $bundlesDir + "\coverage-report-int-cli-tests$reportSuffix.txt" + $goTestArg = "--format=standard-verbose --packages=./integration-cli/... --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -coverprofile=$coverageFilePath -covermode=atomic -tags=autogen -test.timeout=200m $goTestRun $env:INTEGRATION_TESTFLAGS" + Write-Host "INFO: Invoking integration-cli tests run with gotestsum.exe $goTestArg" + $pinfo = New-Object System.Diagnostics.ProcessStartInfo + $pinfo.FileName = "gotestsum.exe" + $pinfo.WorkingDirectory = "$($PWD.Path)" + $pinfo.UseShellExecute = $false + $pinfo.Arguments = $goTestArg + $p = New-Object System.Diagnostics.Process + $p.StartInfo = $pinfo + $p.Start() | Out-Null + $p.WaitForExit() + if ($p.ExitCode -ne 0) { Throw "integration-cli tests failed" } +} + # Start of main code. Try { Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)" @@ -405,7 +439,7 @@ Try { if ($Binary) { $Client = $True; $Daemon = $True } # Default to building the daemon if not asked for anything explicitly. - if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration)) { $Daemon=$True } + if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration) -and -not($TestIntegrationCli)) { $Daemon=$True } # Verify git is installed if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" } @@ -501,6 +535,9 @@ Try { # Run integration tests if ($TestIntegration) { Run-IntegrationTests } + # Run integration-cli tests + if ($TestIntegrationCli) { Run-IntegrationCliTests } + # Gratuitous ASCII art. if ($Daemon -or $Client) { Write-Host