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

Commit 17101d6

Browse files
committed
ci: test workflow
1 parent 0781a6b commit 17101d6

File tree

8 files changed

+117
-0
lines changed

8 files changed

+117
-0
lines changed

.github/workflows/test.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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-26.1
29+
- Dockerfile-26.0
30+
- Dockerfile-25.0
31+
context:
32+
- qemu
33+
- xx
34+
steps:
35+
-
36+
name: Checkout
37+
uses: actions/checkout@v4
38+
-
39+
name: Docker Build
40+
uses: docker/bake-action@v4
41+
with:
42+
targets: image-local
43+
env:
44+
DEFAULT_TAG: ${{ env.BUILD_TAG }}
45+
DOCKERFILE: ${{ matrix.docker_file }}
46+
-
47+
name: Start
48+
run: |
49+
docker compose config
50+
docker compose up -d
51+
sleep 20
52+
docker ps -a
53+
netstat -atpn
54+
docker compose logs
55+
working-directory: test
56+
env:
57+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
58+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
59+
CONTEXT_DIR: ${{ matrix.context }}
60+
# -
61+
# name: Check container logs
62+
# uses: crazy-max/.github/.github/actions/container-logs-check@main
63+
# with:
64+
# container_name: ${{ env.CONTAINER_NAME }}
65+
# log_check: "API listen on [::]:2375"
66+
-
67+
name: Create context
68+
run: |
69+
docker context create docker-test --docker "host=tcp://127.0.0.1:12375,skip-tls-verify=true"
70+
docker context use docker-test
71+
-
72+
name: Build
73+
uses: docker/build-push-action@v5
74+
with:
75+
context: ./test/${{ matrix.context }}
76+
-
77+
name: Build within container
78+
run: |
79+
docker compose exec ${{ env.CONTAINER_NAME }} \
80+
docker build --platform linux/amd64,linux/arm64 --output type=cacheonly .
81+
working-directory: test
82+
env:
83+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
84+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
85+
CONTEXT_DIR: ${{ matrix.context }}
86+
-
87+
name: Logs
88+
if: always()
89+
run: |
90+
docker compose logs
91+
working-directory: test
92+
env:
93+
DOCKER_IMAGE: ${{ env.BUILD_TAG }}
94+
DOCKER_CONTAINER: ${{ env.CONTAINER_NAME }}
95+
CONTEXT_DIR: ${{ matrix.context }}

test/compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
docker:
3+
image: ${DOCKER_IMAGE:-crazymax/docker}
4+
container_name: ${DOCKER_CONTAINER:-docker}
5+
privileged: true
6+
command: --host=tcp://0.0.0.0:2375 --tlsverify=false --debug
7+
ports:
8+
- "12375:2375"
9+
volumes:
10+
- "./${CONTEXT_DIR:-qemu}:/src"
11+
working_dir: /src
12+
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)