From 17101d6c4b9e4e86f7058e9cd5efa7a9fb290ab0 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 29 Aug 2023 08:47:55 +0200 Subject: [PATCH] ci: test workflow --- .github/workflows/test.yml | 95 +++++++++++++++++++++++++++ test/compose.yml | 12 ++++ test/{ => qemu}/Dockerfile | 0 test/{ => qemu}/go.mod | 0 test/{ => qemu}/main.go | 0 test/{xx.Dockerfile => xx/Dockerfile} | 0 test/xx/go.mod | 3 + test/xx/main.go | 7 ++ 8 files changed, 117 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 test/compose.yml rename test/{ => qemu}/Dockerfile (100%) rename test/{ => qemu}/go.mod (100%) rename test/{ => qemu}/main.go (100%) rename test/{xx.Dockerfile => xx/Dockerfile} (100%) create mode 100644 test/xx/go.mod create mode 100644 test/xx/main.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ed8f82e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,95 @@ +name: test + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - 'master' + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +env: + BUILD_TAG: docker:test + CONTAINER_NAME: docker + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + docker_file: + - Dockerfile-26.1 + - Dockerfile-26.0 + - Dockerfile-25.0 + context: + - qemu + - xx + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Docker Build + uses: docker/bake-action@v4 + with: + targets: image-local + env: + DEFAULT_TAG: ${{ env.BUILD_TAG }} + DOCKERFILE: ${{ matrix.docker_file }} + - + name: Start + run: | + docker compose config + docker compose up -d + sleep 20 + docker ps -a + netstat -atpn + docker compose logs + working-directory: test + env: + DOCKER_IMAGE: ${{ env.BUILD_TAG }} + DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }} + CONTEXT_DIR: ${{ matrix.context }} +# - +# name: Check container logs +# uses: crazy-max/.github/.github/actions/container-logs-check@main +# with: +# container_name: ${{ env.CONTAINER_NAME }} +# log_check: "API listen on [::]:2375" + - + name: Create context + run: | + docker context create docker-test --docker "host=tcp://127.0.0.1:12375,skip-tls-verify=true" + docker context use docker-test + - + name: Build + uses: docker/build-push-action@v5 + with: + context: ./test/${{ matrix.context }} + - + name: Build within container + run: | + docker compose exec ${{ env.CONTAINER_NAME }} \ + docker build --platform linux/amd64,linux/arm64 --output type=cacheonly . + working-directory: test + env: + DOCKER_IMAGE: ${{ env.BUILD_TAG }} + DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }} + CONTEXT_DIR: ${{ matrix.context }} + - + name: Logs + if: always() + run: | + docker compose logs + working-directory: test + env: + DOCKER_IMAGE: ${{ env.BUILD_TAG }} + DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }} + CONTEXT_DIR: ${{ matrix.context }} diff --git a/test/compose.yml b/test/compose.yml new file mode 100644 index 0000000..5003ac5 --- /dev/null +++ b/test/compose.yml @@ -0,0 +1,12 @@ +services: + docker: + image: ${DOCKER_IMAGE:-crazymax/docker} + container_name: ${DOCKER_CONTAINER:-docker} + privileged: true + command: --host=tcp://0.0.0.0:2375 --tlsverify=false --debug + ports: + - "12375:2375" + volumes: + - "./${CONTEXT_DIR:-qemu}:/src" + working_dir: /src + restart: always diff --git a/test/Dockerfile b/test/qemu/Dockerfile similarity index 100% rename from test/Dockerfile rename to test/qemu/Dockerfile diff --git a/test/go.mod b/test/qemu/go.mod similarity index 100% rename from test/go.mod rename to test/qemu/go.mod diff --git a/test/main.go b/test/qemu/main.go similarity index 100% rename from test/main.go rename to test/qemu/main.go diff --git a/test/xx.Dockerfile b/test/xx/Dockerfile similarity index 100% rename from test/xx.Dockerfile rename to test/xx/Dockerfile diff --git a/test/xx/go.mod b/test/xx/go.mod new file mode 100644 index 0000000..010c11d --- /dev/null +++ b/test/xx/go.mod @@ -0,0 +1,3 @@ +module github.com/crazy-max/docker-docker/test + +go 1.17 diff --git a/test/xx/main.go b/test/xx/main.go new file mode 100644 index 0000000..0452af2 --- /dev/null +++ b/test/xx/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, Go!") +}