-
Notifications
You must be signed in to change notification settings - Fork 5
101 lines (85 loc) · 2.02 KB
/
ci.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: xzdp CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
fmt:
name: Run go fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Run go fmt
run: |
fmt_output=$(go fmt ./...)
if [ -n "$fmt_output" ]; then
echo "The following files need to be formatted:"
echo "$fmt_output"
exit 1
fi
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Install dependencies
run: go mod tidy
- name: Build
run: ./script/build.sh
test:
name: Run tests
runs-on: ubuntu-latest
needs: build
services:
redis:
image: redis:latest
ports:
- 6379:6379
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: xzdp
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Install dependencies
run: go mod tidy
- name: Wait for MySQL to be ready
run: |
until mysqladmin ping -h 127.0.0.1 --silent; do
echo "Waiting for MySQL..."
sleep 2
done
- name: Import SQL file into MySQL
run: |
mysql -h 127.0.0.1 -P 3306 -u root -ppassword xzdp < resources/xzdp.sql
- name: Run tests
env:
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: xzdp
run: ./script/test.sh