瀏覽代碼

ci(integration-cli): move integration-cli run to make script

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
CrazyMax 3 年之前
父節點
當前提交
ca8b659a06
共有 2 個文件被更改,包括 40 次插入12 次删除
  1. 2 11
      .github/workflows/windows.yml
  2. 38 1
      hack/make.ps1

+ 2 - 11
.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'

+ 38 - 1
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