-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (81 loc) · 2.72 KB
/
Test When Commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Test When Commit.yml
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
services:
docker:
image: docker:latest
options: --privileged
ports:
- 80:80
- 8000:8000
- 3000:3000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
steps:
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
docker-compose --version
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# # 构建单架构后端服务镜像用于本地测试
# - name: Build backend service image for testing
# run: docker build -t backend:test -f ./Django/Dockerfile ./Django
#
# # 构建单架构前端服务镜像用于本地测试
# - name: Build web service image for testing
# run: docker build -t web:test -f ./astro/Dockerfile ./astro
# # 构建单架构 Nginx 服务镜像用于本地测试
# - name: Build nginx service image for testing
# run: docker build -t nginx:test -f ./nginx/nginx.Dockerfile .
# 启动 Docker Compose 服务用于测试
- name: Start Docker Compose services for testing
run: docker compose -f "./GitHub Action Build Docker.yml" up --build -d
- name: Wait for services to be up
run: |
echo "Waiting for services to be up..."
sleep 5
- name: Check logs
run: |
docker compose logs backend
docker compose logs web
docker compose logs db
- name: Load database fixtures
run: |
docker compose exec backend python manage.py loaddata db.json
- name: Wait for services to be up
run: |
echo "Waiting for services to be up..."
sleep 10
- name: Check logs
run: |
docker compose logs backend
docker compose logs web
docker compose logs db
- name: Run tests
run: |
curl -f http://localhost:3000
curl -f http://localhost:3000/posts/1
curl -f http://localhost:3000/archive
curl -f http://localhost:3000/about
curl -f http://localhost:8000/admin
curl -f http://localhost:8000/api/posts/
curl -f http://localhost:8000/api/web_config