1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

ci(integration-cli): dynamically split tests in matrix

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-06-16 22:47:36 +02:00
parent 0e6a1b9596
commit 1887d85e21
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 45 additions and 7 deletions

View file

@ -16,6 +16,7 @@ on:
env: env:
GO_VERSION: 1.18.3 GO_VERSION: 1.18.3
GOTESTLIST_VERSION: v0.2.0
WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore
WINDOWS_BASE_TAG_2019: ltsc2019 WINDOWS_BASE_TAG_2019: ltsc2019
WINDOWS_BASE_TAG_2022: ltsc2022 WINDOWS_BASE_TAG_2022: ltsc2022
@ -188,10 +189,43 @@ jobs:
name: ${{ matrix.os }}-unit-reports name: ${{ matrix.os }}-unit-reports
path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\* path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\*
integration-test-prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.tests.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
-
name: Install gotestlist
run:
go install github.com/crazy-max/gotestlist/cmd/gotestlist@${{ env.GOTESTLIST_VERSION }}
-
name: Create matrix
id: tests
working-directory: ./integration-cli
run: |
# Distribute integration-cli tests for the matrix in integration-test job.
# Also prepend ./... to the matrix. This is a special case to run "Test integration" step exclusively.
matrix="$(gotestlist -d 4 ./...)"
matrix="$(echo "$matrix" | jq -c '. |= ["./..."] + .')"
echo "::set-output name=matrix::$matrix"
-
name: Show matrix
run: |
echo ${{ steps.tests.outputs.matrix }}
integration-test: integration-test:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: needs:
- build - build
- integration-test-prepare
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -201,6 +235,7 @@ jobs:
runtime: runtime:
- builtin - builtin
- containerd - containerd
test: ${{ fromJson(needs.integration-test-prepare.outputs.matrix) }}
env: env:
GOPATH: ${{ github.workspace }}\go GOPATH: ${{ github.workspace }}\go
GOBIN: ${{ github.workspace }}\go\bin GOBIN: ${{ github.workspace }}\go\bin
@ -343,7 +378,8 @@ jobs:
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- -
name: Test API name: Test integration
if: matrix.test == './...'
run: | run: |
.\hack\make.ps1 -TestIntegration .\hack\make.ps1 -TestIntegration
env: env:
@ -351,7 +387,8 @@ jobs:
GO111MODULE: "off" GO111MODULE: "off"
TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker
- -
name: Test CLI name: Test integration-cli
if: matrix.test != './...'
run: | run: |
& gotestsum ` & gotestsum `
--format=standard-verbose ` --format=standard-verbose `
@ -362,6 +399,7 @@ jobs:
"-coverprofile" "./bundles/coverage-report-int-cli-tests.txt" ` "-coverprofile" "./bundles/coverage-report-int-cli-tests.txt" `
"-covermode" "atomic" ` "-covermode" "atomic" `
"-tags" "autogen" ` "-tags" "autogen" `
"-test.run" "(${{ matrix.test }})/" `
"-test.timeout" "200m" "-test.timeout" "200m"
env: env:
DOCKER_HOST: npipe:////./pipe/docker_engine DOCKER_HOST: npipe:////./pipe/docker_engine

View file

@ -31,7 +31,7 @@ COPY hack/dockerfile/install/install.sh ./install.sh
COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
# Build DockerSuite.TestBuild* dependency # TestDockerCLIBuildSuite dependency
FROM base AS contrib FROM base AS contrib
COPY contrib/syscall-test /build/syscall-test COPY contrib/syscall-test /build/syscall-test
COPY contrib/httpserver/Dockerfile /build/httpserver/Dockerfile COPY contrib/httpserver/Dockerfile /build/httpserver/Dockerfile

View file

@ -171,16 +171,16 @@ $ TESTDIRS='github.com/docker/docker/opts' TESTFLAGS='-test.run ^TestValidateIPA
We use [gocheck](https://labix.org/gocheck) for our integration-cli tests. We use [gocheck](https://labix.org/gocheck) for our integration-cli tests.
You can use the `TESTFLAGS` environment variable to run a single test. The You can use the `TESTFLAGS` environment variable to run a single test. The
flag's value is passed as arguments to the `go test` command. For example, from flag's value is passed as arguments to the `go test` command. For example, from
your local host you can run the `TestBuild` test with this command: your local host you can run the `TestDockerCLIBuildSuite` test with this command:
```bash ```bash
$ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration $ TESTFLAGS='-test.run TestDockerCLIBuildSuite' make test-integration
``` ```
To run the same test inside your Docker development container, you do this: To run the same test inside your Docker development container, you do this:
```bash ```bash
# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration # TESTFLAGS='-test.run TestDockerCLIBuildSuite' hack/make.sh binary test-integration
``` ```
## Test the Windows binary against a Linux daemon ## Test the Windows binary against a Linux daemon

View file

@ -3,7 +3,7 @@
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
# to run certain tests on your local host, you should run with command: # to run certain tests on your local host, you should run with command:
# #
# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration # TESTFLAGS='-test.run TestDockerCLIBuildSuite' ./hack/make.sh binary test-integration
# #
if [ -z "${MAKEDIR}" ]; then if [ -z "${MAKEDIR}" ]; then