Skip to content

Commit

Permalink
ci: gha test workflow for integration and unit test
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jun 1, 2022
1 parent de02776 commit 7751ec5
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 33 deletions.
12 changes: 12 additions & 0 deletions .github/actions/setup-runner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Setup Runner'
description: 'Composite action to set up the GitHub Runner for jobs in the test.yml workflow'

runs:
using: composite
steps:
- run: |
sudo modprobe ipv6
sudo modprobe ip6table_filter
echo '{"experimental":true,"ipv6":true,"fixed-cidr-v6":"2001:db8:1::/64"}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
shell: bash
32 changes: 0 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,3 @@ jobs:
TESTFLAGS: "-v --parallel=1 --timeout=30m --run=//worker=dockerd$"
SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}"
working-directory: buildkit

dev:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
mode:
- ""
- systemd
steps:
-
name: Prepare
run: |
if [ "${{ matrix.mode }}" = "systemd" ]; then
echo "SYSTEMD=true" >> $GITHUB_ENV
fi
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
*.cache-from=type=gha,scope=cross-bundle-linux-amd64
*.cache-from=type=gha,scope=dev${{ matrix.mode }}
*.cache-to=type=gha,scope=dev${{ matrix.mode }},mode=max
*.output=type=cacheonly
215 changes: 215 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- 'v*'
pull_request:

env:
DOCKER_EXPERIMENTAL: 1

jobs:
smoke:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -47,3 +50,215 @@ jobs:
*.cache-to=type=gha,scope=binary-smoketest-${{ env.PLATFORM_PAIR }}
env:
DOCKER_LINKMODE: static

devimage:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
mode:
- ""
- systemd
steps:
-
name: Prepare
run: |
if [ "${{ matrix.mode }}" = "systemd" ]; then
echo "SYSTEMD=true" >> $GITHUB_ENV
fi
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
*.cache-from=type=gha,scope=cross-bundle-linux-amd64
*.cache-from=type=gha,scope=dev${{ matrix.mode }}
*.cache-to=type=gha,scope=dev${{ matrix.mode }},mode=max
*.output=type=cacheonly
unit:
runs-on: ubuntu-20.04
needs:
- devimage
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Test
run: |
make test-unit
docker-py:
runs-on: ubuntu-20.04
needs:
- devimage
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Test
run: |
make test-docker-py
-
name: Test daemon logs
if: always()
run: |
cat bundles/test-docker-py/docker.log
integration-flaky:
runs-on: ubuntu-20.04
needs:
- devimage
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Test
run: |
make test-integration-flaky
env:
TEST_SKIP_INTEGRATION_CLI: 1

integration:
runs-on: ubuntu-20.04
needs:
- devimage
strategy:
fail-fast: false
matrix:
mode:
- ""
- rootless
- cgroup2
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Prepare
run: |
CACHE_DEV_SCOPE=dev
if [ "${{ matrix.mode }}" = "rootless" ]; then
echo "DOCKER_ROOTLESS=1" >> $GITHUB_ENV
fi
if [ "${{ matrix.mode }}" = "cgroup2" ]; then
echo "SYSTEMD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}systemd"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=${{ env.CACHE_DEV_SCOPE }}
-
name: Test
run: |
make test-integration
env:
TEST_SKIP_INTEGRATION_CLI: 1
-
name: Test daemon logs
if: always()
run: |
cat bundles/test-integration/docker.log
integration-cli:
runs-on: ubuntu-20.04
needs:
- devimage
strategy:
fail-fast: false
matrix:
testsuite:
- DockerSuite
- DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite
- DockerSwarmSuite
- DockerDaemonSuite
- DockerExternalVolumeSuite
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dev image
uses: docker/bake-action@v1
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Test
run: |
make test-integration
env:
TEST_SKIP_INTEGRATION: 1
TESTFLAGS: "-test.run Test(${{ matrix.testsuite }})/"
-
name: Test daemon logs
if: always()
run: |
cat bundles/test-integration/docker.log
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DOCKER_IMAGE := docker-dev
DOCKER_PORT_FORWARD := $(if $(DOCKER_PORT),-p "$(DOCKER_PORT)",)
DELVE_PORT_FORWARD := $(if $(DELVE_PORT),-p "$(DELVE_PORT)",)

DOCKER_FLAGS := $(DOCKER) run --rm -i --privileged $(DOCKER_CONTAINER_NAME) $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD) $(DELVE_PORT_FORWARD)
DOCKER_FLAGS := $(DOCKER) run --rm --privileged $(DOCKER_CONTAINER_NAME) $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD) $(DELVE_PORT_FORWARD)
BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR))
export BUILD_APT_MIRROR

Expand All @@ -131,6 +131,14 @@ ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif

# on GitHub Runners input device is not a TTY but we allocate a pseudo-one,
# otherwise keep STDIN open even if not attached if not a GitHub Runner.
ifeq ($(GITHUB_ACTIONS),true)
DOCKER_FLAGS += -t
else
DOCKER_FLAGS += -i
endif

DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"

DOCKER_BUILD_ARGS += --build-arg=GO_VERSION
Expand Down

0 comments on commit 7751ec5

Please sign in to comment.