Skip to content

Commit 1540ef7

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

File tree

12 files changed

+185
-172
lines changed

12 files changed

+185
-172
lines changed

.github/workflows/build.yml

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

.github/workflows/e2e.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
include:
24+
- target: non-experimental
25+
engine-version: 19.03-dind
26+
steps:
27+
-
28+
name: Checkout
29+
uses: actions/checkout@v2
30+
-
31+
name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v1
33+
-
34+
name: Run ${{ matrix.target }}
35+
uses: docker/bake-action@v1
36+
with:
37+
targets: test-e2e-${{ matrix.target }}
38+
env:
39+
E2E_ENGINE_VERSION: ${{ matrix.engine-version }}

Dockerfile

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

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

2525
FROM build-base-alpine AS build-alpine
@@ -29,7 +29,7 @@ RUN xx-apk add --no-cache musl-dev gcc
2929

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

3535
FROM build-base-buster AS build-buster
@@ -55,8 +55,47 @@ RUN --mount=ro --mount=type=cache,target=/root/.cache \
5555
TARGET=/out ./scripts/build/binary && \
5656
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
5757

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

6197
FROM scratch AS binary
6298
COPY --from=build /out .
99+
100+
FROM scratch AS plugins
101+
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
@@ -44,14 +44,6 @@ dynbinary: ## build dynamically linked binary
4444
plugins: ## build example CLI plugins
4545
./scripts/build/plugins
4646

47-
.PHONY: plugins-windows
48-
plugins-windows: ## build example CLI plugins for Windows
49-
./scripts/build/plugins-windows
50-
51-
.PHONY: plugins-osx
52-
plugins-osx: ## build example CLI plugins for macOS
53-
./scripts/build/plugins-osx
54-
5547
vendor: vendor.conf ## check that vendor matches vendor.conf
5648
rm -rf vendor
5749
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: 24 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
group "default" {
1415
targets = ["binary"]
@@ -32,6 +33,17 @@ target "dynbinary" {
3233
}
3334
}
3435

36+
target "plugins" {
37+
target = "plugins"
38+
platforms = ["local"]
39+
output = ["build"]
40+
args = {
41+
BASE_VARIANT = USE_GLIBC != "" ? "buster" : "alpine"
42+
VERSION = VERSION
43+
GO_STRIP = STRIP_TARGET
44+
}
45+
}
46+
3547
target "platforms" {
3648
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"])
3749
}
@@ -55,3 +67,13 @@ target "shellcheck" {
5567
target = "shellcheck"
5668
output = ["type=cacheonly"]
5769
}
70+
71+
target "e2e-image" {
72+
target = "e2e"
73+
output = ["type=docker"]
74+
tags = ["${IMAGE_NAME}"]
75+
args = {
76+
BASE_VARIANT = "buster"
77+
VERSION = VERSION
78+
}
79+
}

docker.Makefile

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ DOCKER_CLI_CONTAINER_NAME ?=
1010
DOCKER_CLI_GO_BUILD_CACHE ?= y
1111

1212
DEV_DOCKER_IMAGE_NAME = docker-cli-dev$(IMAGE_TAG)
13-
BINARY_NATIVE_IMAGE_NAME = docker-cli-native$(IMAGE_TAG)
14-
CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG)
15-
E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG)
13+
E2E_IMAGE_NAME = docker-cli-e2e
1614
E2E_ENGINE_VERSION ?=
1715
CACHE_VOLUME_NAME := docker-cli-dev-cache
1816
ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
@@ -30,15 +28,6 @@ build_docker_image:
3028
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
3129
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) -
3230

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

@@ -48,8 +37,8 @@ binary:
4837

4938
build: binary ## alias for binary
5039

51-
plugins: build_binary_native_image ## build the CLI plugin examples
52-
$(DOCKER_RUN) $(BINARY_NATIVE_IMAGE_NAME) ./scripts/build/plugins
40+
plugins: ## build the CLI plugin examples
41+
docker buildx bake plugins
5342

5443
.PHONY: clean
5544
clean: build_docker_image ## clean build artifacts
@@ -67,14 +56,6 @@ test: test-unit test-e2e
6756
cross:
6857
docker buildx bake cross
6958

70-
.PHONY: plugins-windows
71-
plugins-windows: build_cross_image ## build the example CLI plugins for Windows
72-
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
73-
74-
.PHONY: plugins-osx
75-
plugins-osx: build_cross_image ## build the example CLI plugins for macOS
76-
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
77-
7859
.PHONY: dynbinary
7960
dynbinary: ## build dynamically linked binary
8061
USE_GLIBC=1 docker buildx bake dynbinary
@@ -115,20 +96,24 @@ manpages: build_docker_image ## generate man pages from go source and markdown
11596
yamldocs: build_docker_image ## generate documentation YAML files consumed by docs repo
11697
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make yamldocs
11798

99+
.PHONY: build-e2e-image
100+
build-e2e-image:
101+
IMAGE_NAME=$(E2E_IMAGE_NAME) VERSION=$(VERSION) docker buildx bake e2e-image
102+
118103
.PHONY: test-e2e
119104
test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ssh ## run all e2e tests
120105

121106
.PHONY: test-e2e-experimental
122-
test-e2e-experimental: build_e2e_image # run experimental e2e tests
123-
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 $(E2E_IMAGE_NAME)
107+
test-e2e-experimental: build-e2e-image # run experimental e2e tests
108+
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)
124109

125110
.PHONY: test-e2e-non-experimental
126-
test-e2e-non-experimental: build_e2e_image # run non-experimental e2e tests
111+
test-e2e-non-experimental: build-e2e-image # run non-experimental e2e tests
127112
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)
128113

129114
.PHONY: test-e2e-connhelper-ssh
130-
test-e2e-connhelper-ssh: build_e2e_image # run experimental SSH-connection helper e2e tests
131-
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)
115+
test-e2e-connhelper-ssh: build-e2e-image # run experimental SSH-connection helper e2e tests
116+
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)
132117

133118
.PHONY: help
134119
help: ## print this help

dockerfiles/Dockerfile.e2e

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

0 commit comments

Comments
 (0)