Ver Fonte

ci(windows): upload coverage to codecov

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
CrazyMax há 3 anos atrás
pai
commit
15ed58ffb5
3 ficheiros alterados com 55 adições e 10 exclusões
  1. 42 5
      .github/workflows/windows.yml
  2. 7 3
      codecov.yml
  3. 6 2
      hack/make.ps1

+ 42 - 5
.github/workflows/windows.yml

@@ -131,6 +131,7 @@ jobs:
         run: |
           New-Item -ItemType "directory" -Path "${{ github.workspace }}\go-build"
           New-Item -ItemType "directory" -Path "${{ github.workspace }}\go\pkg\mod"
+          New-Item -ItemType "directory" -Path "bundles"
           If ("${{ matrix.os }}" -eq "windows-2019") {
             echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2019 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
           } ElseIf ("${{ matrix.os }}" -eq "windows-2022") {
@@ -162,9 +163,26 @@ jobs:
         name: Test
         run: |
           & docker run --name ${{ env.TEST_CTN_NAME }} -e "DOCKER_GITCOMMIT=${{ github.sha }}" `
-              -v "${{ github.workspace }}\go-build:C:\Users\ContainerAdministrator\AppData\Local\go-build" `
-              -v "${{ github.workspace }}\go\pkg\mod:C:\gopath\pkg\mod" `
-              ${{ env.TEST_IMAGE_NAME }} hack\make.ps1 -TestUnit
+            -v "${{ github.workspace }}\go-build:C:\Users\ContainerAdministrator\AppData\Local\go-build" `
+            -v "${{ github.workspace }}\go\pkg\mod:C:\gopath\pkg\mod" `
+            -v "${{ env.GOPATH }}\src\github.com\docker\docker\bundles:C:\gopath\src\github.com\docker\docker\bundles" `
+            ${{ env.TEST_IMAGE_NAME }} hack\make.ps1 -TestUnit
+      -
+        name: Send to Codecov
+        if: matrix.os == 'windows-2022'
+        uses: codecov/codecov-action@v3
+        with:
+          working-directory: ${{ env.GOPATH }}\src\github.com\docker\docker
+          directory: bundles
+          env_vars: RUNNER_OS
+          flags: unit
+      -
+        name: Upload reports
+        if: matrix.os == 'windows-2022'
+        uses: actions/upload-artifact@v3
+        with:
+          name: unit-reports
+          path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\*
 
   integration-test:
     runs-on: ${{ matrix.os }}
@@ -330,12 +348,31 @@ jobs:
       -
         name: Test CLI
         run: |
-          gotestsum --format=standard-verbose -- "-tags" "autogen" "-test.timeout" "200m"
-        working-directory: ${{ env.GOPATH }}/src/github.com/docker/docker/integration-cli
+          & gotestsum --format=standard-verbose --packages="./integration-cli/..." -- `
+            "-coverprofile" "./bundles/coverage-report-int-cli-tests.txt" `
+            "-covermode" "atomic" `
+            "-tags" "autogen" `
+            "-test.timeout" "200m"
         env:
           DOCKER_HOST: npipe:////./pipe/docker_engine
           GO111MODULE: "off"
           TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker
+      -
+        name: Send to Codecov
+        if: matrix.os == 'windows-2022'
+        uses: codecov/codecov-action@v3
+        with:
+          working-directory: ${{ env.GOPATH }}\src\github.com\docker\docker
+          directory: bundles
+          env_vars: RUNNER_OS
+          flags: integration,${{ matrix.runtime }}
+      -
+        name: Upload reports
+        if: matrix.os == 'windows-2022'
+        uses: actions/upload-artifact@v3
+        with:
+          name: integration-reports-${{ matrix.runtime }}
+          path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\*
       -
         name: Docker info
         run: |

+ 7 - 3
codecov.yml

@@ -1,5 +1,8 @@
-comment:
-  layout: header, changes, diff, sunburst
+comment: false
+
+github_checks:
+  annotations: false
+
 coverage:
   status:
     patch:
@@ -13,5 +16,6 @@ coverage:
         target: auto
         threshold: "15%"
     changes: false
+
 ignore:
-  - "vendor/*"
+  - "vendor/**/*"

+ 6 - 2
hack/make.ps1

@@ -328,7 +328,10 @@ Function Run-UnitTests() {
     $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration"
     $pkgList = $pkgList -replace "`r`n", " "
 
-    $goTestArg = "--format=standard-verbose --jsonfile=bundles\go-test-report-unit-tests.json --junitfile=bundles\junit-report-unit-tests.xml -- " + $raceParm + " -cover -ldflags -w -a """ + "-test.timeout=10m" + """ $pkgList"
+    $jsonFilePath = $bundlesDir + "\go-test-report-unit-tests.json"
+    $xmlFilePath = $bundlesDir + "\junit-report-unit-tests.xml"
+    $coverageFilePath = $bundlesDir + "\coverage-report-unit-tests.txt"
+    $goTestArg = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- " + $raceParm + " -coverprofile=$coverageFilePath -covermode=atomic -ldflags -w -a """ + "-test.timeout=10m" + """ $pkgList"
     Write-Host "INFO: Invoking unit tests run with $GOTESTSUM_LOCATION\gotestsum.exe $goTestArg"
     $pinfo = New-Object System.Diagnostics.ProcessStartInfo
     $pinfo.FileName = "$GOTESTSUM_LOCATION\gotestsum.exe"
@@ -364,13 +367,14 @@ Function Run-IntegrationTests() {
         }
         $jsonFilePath = $bundlesDir + "\go-test-report-int-tests-$normDir" + ".json"
         $xmlFilePath = $bundlesDir + "\junit-report-int-tests-$normDir" + ".xml"
+        $coverageFilePath = $bundlesDir + "\coverage-report-int-tests-$normDir" + ".txt"
         Set-Location $dir
         Write-Host "Running $($PWD.Path)"
         $pinfo = New-Object System.Diagnostics.ProcessStartInfo
         $pinfo.FileName = "gotestsum.exe"
         $pinfo.WorkingDirectory = "$($PWD.Path)"
         $pinfo.UseShellExecute = $false
-        $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -test.timeout=60m $env:INTEGRATION_TESTFLAGS"
+        $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -coverprofile=$coverageFilePath -covermode=atomic -test.timeout=60m $env:INTEGRATION_TESTFLAGS"
         $p = New-Object System.Diagnostics.Process
         $p.StartInfo = $pinfo
         $p.Start() | Out-Null