Skip to content

Commit cd1fd87

Browse files
committed
GitHub Actions e2e tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 9fab13b commit cd1fd87

File tree

15 files changed

+227
-239
lines changed

15 files changed

+227
-239
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ jobs:
5050
name: ${{ matrix.target }}
5151
path: ./build/*
5252
if-no-files-found: error
53+
54+
plugins:
55+
runs-on: ubuntu-latest
56+
steps:
57+
-
58+
name: Checkout
59+
uses: actions/checkout@v2
60+
-
61+
name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v1
63+
-
64+
name: Build plugins
65+
uses: docker/bake-action@v1
66+
with:
67+
targets: plugins-cross

.github/workflows/e2e.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: e2e
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'master'
8+
- '[0-9]+.[0-9]{2}'
9+
tags:
10+
- 'v*'
11+
pull_request:
12+
13+
jobs:
14+
e2e:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
target:
20+
- non-experimental
21+
- experimental
22+
- connhelper-ssh
23+
base:
24+
- alpine
25+
- buster
26+
engine-version:
27+
# - 20.10-dind # FIXME: Fails on 20.10
28+
- stable-dind # TODO: Use 20.10-dind, stable-dind is deprecated
29+
include:
30+
- target: non-experimental
31+
engine-version: 19.03-dind
32+
steps:
33+
-
34+
name: Checkout
35+
uses: actions/checkout@v2
36+
-
37+
name: Update daemon.json
38+
run: |
39+
sudo jq '.experimental = true' < /etc/docker/daemon.json > /tmp/docker.json
40+
sudo mv /tmp/docker.json /etc/docker/daemon.json
41+
sudo cat /etc/docker/daemon.json
42+
sudo service docker restart
43+
docker version
44+
docker info
45+
-
46+
name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v1
48+
-
49+
name: Run ${{ matrix.target }}
50+
run: |
51+
make -f docker.Makefile test-e2e-${{ matrix.target }}
52+
env:
53+
BASE_VARIANT: ${{ matrix.base }}
54+
E2E_ENGINE_VERSION: ${{ matrix.engine-version }}

Dockerfile

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
2020

2121
FROM go-${TARGETOS} AS build-base-alpine
2222
COPY --from=xx / /
23-
RUN apk add --no-cache clang lld llvm file git
23+
RUN apk add --no-cache bash clang lld llvm file git
2424
WORKDIR /go/src/github.com/docker/cli
2525

2626
FROM build-base-alpine AS build-alpine
@@ -30,7 +30,7 @@ RUN xx-apk add --no-cache musl-dev gcc
3030

3131
FROM go-${TARGETOS} AS build-base-buster
3232
COPY --from=xx / /
33-
RUN apt-get update && apt-get install --no-install-recommends -y clang lld file
33+
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld file
3434
WORKDIR /go/src/github.com/docker/cli
3535

3636
FROM build-base-buster AS build-buster
@@ -65,8 +65,49 @@ RUN --mount=type=bind,target=.,ro \
6565
TARGET=/out ./scripts/build/binary && \
6666
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
6767

68-
FROM build-base-${BASE_VARIANT} AS dev
68+
FROM build-${BASE_VARIANT} AS build-plugins
69+
ARG GO_LINKMODE=static
70+
ARG GO_BUILDTAGS
71+
ARG GO_STRIP
72+
ARG CGO_ENABLED
73+
ARG VERSION
74+
RUN --mount=ro --mount=type=cache,target=/root/.cache \
75+
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
76+
xx-go --wrap && \
77+
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*
78+
79+
FROM build-base-alpine AS e2e-base-alpine
80+
RUN apk add --no-cache build-base curl docker-compose openssl openssh-client
81+
82+
FROM build-base-buster AS e2e-base-buster
83+
RUN apt-get update && apt-get install -y build-essential curl openssl openssh-client
84+
ARG COMPOSE_VERSION=1.29.2
85+
RUN curl -fsSL https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && \
86+
chmod +x /usr/local/bin/docker-compose
87+
88+
FROM e2e-base-${BASE_VARIANT} AS e2e
89+
ARG NOTARY_VERSION=v0.6.1
90+
RUN curl -fsSL https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 -o /usr/local/bin/notary && \
91+
chmod +x /usr/local/bin/notary
92+
COPY e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
93+
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
94+
ARG GOTESTSUM_VERSION=1.7.0
95+
RUN curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz && \
96+
tar -xf gotestsum.tar.gz gotestsum && \
97+
mv gotestsum /usr/local/bin/gotestsum && \
98+
rm gotestsum.tar.gz
99+
COPY --from=build /out ./build/
100+
COPY --from=build-plugins /out ./build/
101+
COPY . .
102+
ENV DOCKER_BUILDKIT=1
103+
ENV PATH=/go/src/github.com/docker/cli/build:$PATH
104+
CMD ./scripts/test/e2e/entry
105+
106+
FROM build-base-${BASE_VARIANT} AS dev
69107
COPY . .
70108

71109
FROM scratch AS binary
72110
COPY --from=build /out .
111+
112+
FROM scratch AS plugins
113+
COPY --from=build-plugins /out .

Jenkinsfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ dynbinary: ## build dynamically linked binary
4848
plugins: ## build example CLI plugins
4949
./scripts/build/plugins
5050

51-
.PHONY: plugins-windows
52-
plugins-windows: ## build example CLI plugins for Windows
53-
./scripts/build/plugins-windows
54-
55-
.PHONY: plugins-osx
56-
plugins-osx: ## build example CLI plugins for macOS
57-
./scripts/build/plugins-osx
58-
5951
vendor: vendor.conf ## check that vendor matches vendor.conf
6052
rm -rf vendor
6153
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log'

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/docker/cli)
44
[![Build Status](https://img.shields.io/github/workflow/status/docker/cli/build?logo=github)](https://github.com/docker/cli/actions?query=workflow%3Abuild)
55
[![CircleCI Status](https://img.shields.io/circleci/build/github/docker/cli/master?logo=circleci)](https://circleci.com/gh/docker/cli/tree/master)
6-
[![Jenkins Status](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.docker.com%2Fpublic%2Fjob%2Fcli%2Fjob%2Fmaster&logo=jenkins)](https://ci.docker.com/public/job/cli/job/master)
76
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/cli)](https://goreportcard.com/report/github.com/docker/cli)
87
[![Codecov](https://codecov.io/gh/docker/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/docker/cli)
98

docker-bake.hcl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
variable "VERSION" {
22
default = ""
33
}
4-
54
variable "USE_GLIBC" {
65
default = ""
76
}
8-
97
variable "STRIP_TARGET" {
108
default = ""
119
}
10+
variable "IMAGE_NAME" {
11+
default = "docker-cli"
12+
}
1213

1314
# Sets the name of the company that produced the windows binary.
1415
variable "COMPANY_NAME" {
@@ -38,6 +39,17 @@ target "dynbinary" {
3839
}
3940
}
4041

42+
target "plugins" {
43+
target = "plugins"
44+
platforms = ["local"]
45+
output = ["build"]
46+
args = {
47+
BASE_VARIANT = USE_GLIBC != "" ? "buster" : "alpine"
48+
VERSION = VERSION
49+
GO_STRIP = STRIP_TARGET
50+
}
51+
}
52+
4153
target "platforms" {
4254
platforms = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"])
4355
}
@@ -50,6 +62,10 @@ target "dynbinary-cross" {
5062
inherits = ["dynbinary", "platforms"]
5163
}
5264

65+
target "plugins-cross" {
66+
inherits = ["plugins", "platforms"]
67+
}
68+
5369
target "lint" {
5470
dockerfile = "./dockerfiles/Dockerfile.lint"
5571
target = "lint"
@@ -61,3 +77,13 @@ target "shellcheck" {
6177
target = "shellcheck"
6278
output = ["type=cacheonly"]
6379
}
80+
81+
target "e2e-image" {
82+
target = "e2e"
83+
output = ["type=docker"]
84+
tags = ["${IMAGE_NAME}"]
85+
args = {
86+
BASE_VARIANT = USE_GLIBC != "" ? "buster" : "alpine"
87+
VERSION = VERSION
88+
}
89+
}

docker.Makefile

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ DOCKER_CLI_GO_BUILD_CACHE ?= y
1313
COMPANY_NAME ?=
1414

1515
DEV_DOCKER_IMAGE_NAME = docker-cli-dev$(IMAGE_TAG)
16-
BINARY_NATIVE_IMAGE_NAME = docker-cli-native$(IMAGE_TAG)
17-
CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG)
18-
E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG)
16+
E2E_IMAGE_NAME = docker-cli-e2e
1917
E2E_ENGINE_VERSION ?=
2018
CACHE_VOLUME_NAME := docker-cli-dev-cache
2119
ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
@@ -33,15 +31,6 @@ build_docker_image:
3331
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
3432
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) -
3533

36-
.PHONY: build_binary_native_image
37-
build_binary_native_image:
38-
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
39-
cat ./dockerfiles/Dockerfile.binary-native | docker build --build-arg=GO_VERSION -t $(BINARY_NATIVE_IMAGE_NAME) -
40-
41-
.PHONY: build_e2e_image
42-
build_e2e_image:
43-
docker build -t $(E2E_IMAGE_NAME) --build-arg=GO_VERSION --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e .
44-
4534
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
4635
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
4736

@@ -51,8 +40,11 @@ binary:
5140

5241
build: binary ## alias for binary
5342

54-
plugins: build_binary_native_image ## build the CLI plugin examples
55-
$(DOCKER_RUN) $(BINARY_NATIVE_IMAGE_NAME) ./scripts/build/plugins
43+
plugins: ## build the CLI plugin examples
44+
docker buildx bake plugins
45+
46+
plugins-cross: ## build the CLI plugin examples for all platforms
47+
docker buildx bake plugins-cross
5648

5749
.PHONY: clean
5850
clean: build_docker_image ## clean build artifacts
@@ -70,14 +62,6 @@ test: test-unit test-e2e
7062
cross:
7163
COMPANY_NAME=$(COMPANY_NAME) docker buildx bake cross
7264

73-
.PHONY: plugins-windows
74-
plugins-windows: build_cross_image ## build the example CLI plugins for Windows
75-
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
76-
77-
.PHONY: plugins-osx
78-
plugins-osx: build_cross_image ## build the example CLI plugins for macOS
79-
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
80-
8165
.PHONY: dynbinary
8266
dynbinary: ## build dynamically linked binary
8367
USE_GLIBC=1 COMPANY_NAME=$(COMPANY_NAME) docker buildx bake dynbinary
@@ -118,20 +102,24 @@ manpages: build_docker_image ## generate man pages from go source and markdown
118102
yamldocs: build_docker_image ## generate documentation YAML files consumed by docs repo
119103
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make yamldocs
120104

105+
.PHONY: build-e2e-image
106+
build-e2e-image:
107+
IMAGE_NAME=$(E2E_IMAGE_NAME) VERSION=$(VERSION) docker buildx bake e2e-image
108+
121109
.PHONY: test-e2e
122110
test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ssh ## run all e2e tests
123111

124112
.PHONY: test-e2e-experimental
125-
test-e2e-experimental: build_e2e_image # run experimental e2e tests
126-
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 $(E2E_IMAGE_NAME)
113+
test-e2e-experimental: build-e2e-image # run experimental e2e tests
114+
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION) $(E2E_IMAGE_NAME)
127115

128116
.PHONY: test-e2e-non-experimental
129-
test-e2e-non-experimental: build_e2e_image # run non-experimental e2e tests
117+
test-e2e-non-experimental: build-e2e-image # run non-experimental e2e tests
130118
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION) $(E2E_IMAGE_NAME)
131119

132120
.PHONY: test-e2e-connhelper-ssh
133-
test-e2e-connhelper-ssh: build_e2e_image # run experimental SSH-connection helper e2e tests
134-
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 -e TEST_CONNHELPER=ssh $(E2E_IMAGE_NAME)
121+
test-e2e-connhelper-ssh: build-e2e-image # run experimental SSH-connection helper e2e tests
122+
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION) -e TEST_CONNHELPER=ssh $(E2E_IMAGE_NAME)
135123

136124
.PHONY: help
137125
help: ## print this help

dockerfiles/Dockerfile.binary-native

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)