Skip to content
This repository was archived by the owner on Dec 24, 2024. It is now read-only.

Commit d43a3b9

Browse files
committed
ci: test workflow
1 parent a030bd5 commit d43a3b9

File tree

8 files changed

+113
-0
lines changed

8 files changed

+113
-0
lines changed

.github/workflows/test.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: test
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- 'master'
11+
paths-ignore:
12+
- '**.md'
13+
pull_request:
14+
paths-ignore:
15+
- '**.md'
16+
17+
env:
18+
BUILD_TAG: docker:test
19+
CONTAINER_NAME: docker
20+
21+
jobs:
22+
test:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
docker_file:
28+
- Dockerfile-20.10
29+
- Dockerfile-23.0
30+
context:
31+
- qemu
32+
- xx
33+
steps:
34+
-
35+
name: Checkout
36+
uses: actions/checkout@v3
37+
-
38+
name: Docker Build
39+
uses: docker/bake-action@v3
40+
with:
41+
targets: image-local
42+
env:
43+
DEFAULT_TAG: ${{ env.BUILD_TAG }}
44+
DOCKERFILE: ${{ matrix.docker_file }}
45+
-
46+
name: Start
47+
run: |
48+
docker compose up -d
49+
sleep 15
50+
working-directory: test
51+
env:
52+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
53+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
54+
CONTEXT_DIR: ${{ matrix.context }}
55+
-
56+
name: Check container logs
57+
uses: crazy-max/.github/.github/actions/container-logs-check@main
58+
with:
59+
container_name: ${{ env.CONTAINER_NAME }}
60+
log_check: "API listen on [::]:2375"
61+
-
62+
name: Create context
63+
run: |
64+
docker context create docker-test --docker "host=tcp://127.0.0.1:12375,skip-tls-verify=true"
65+
docker context use docker-test
66+
-
67+
name: Build
68+
uses: docker/build-push-action@v4
69+
with:
70+
context: ./test/${{ matrix.context }}
71+
-
72+
name: Build within container
73+
run: |
74+
docker compose exec ${{ env.CONTAINER_NAME }} \
75+
docker build --platform linux/amd64,linux/arm64 --output type=cacheonly .
76+
working-directory: test
77+
env:
78+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
79+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
80+
CONTEXT_DIR: ${{ matrix.context }}
81+
-
82+
name: Logs
83+
if: always()
84+
run: |
85+
docker compose logs
86+
working-directory: test
87+
env:
88+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
89+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
90+
CONTEXT_DIR: ${{ matrix.context }}

test/compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
docker:
3+
image: ${DOCKER_IMAGE:-crazymax/docker}
4+
container_name: ${DOCKER_CONTAINER:-docker}
5+
privileged: true
6+
network_mode: host
7+
command: --host=tcp://0.0.0.0:2375 --tlsverify=false --debug
8+
ports:
9+
- "12375:2375"
10+
volumes:
11+
- "./${CONTEXT_DIR:-qemu}:/src"
12+
working_dir: /src
13+
restart: always
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/xx/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/crazy-max/docker-docker/test
2+
3+
go 1.17

test/xx/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("Hello, Go!")
7+
}

0 commit comments

Comments
 (0)