-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (132 loc) · 4.25 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 定义工作流的名称
name: CI
on:
workflow_dispatch: # 允许手动触发工作流
push: # 当有代码推送事件发生时
branches:
- '*' # 只有推送到 main 分支时才触发
tags:
- '*'
pull_request:
# 定义工作流的任务
jobs:
build:
name: Set up Build
runs-on: ubuntu-latest
# 定义任务中的步骤
steps:
# 检出代码。只检出最新的1次提交
- uses: actions/checkout@v3
with:
fetch-depth: 1
# 设置 QEMU 模拟器,这通常用于多平台的 Docker 构建
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# 设置 Docker Buildx,用于构建多平台的 Docker 镜像
- name: Set up Build
uses: docker/setup-buildx-action@v2
- run: |
ls -l
linting:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_MARKDOWN: true
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
MARKDOWN_CONFIG_FILE: .markdownlint.yml
go-test:
name: Go Test
runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: test_db
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_ROOT_PASSWORD: mysql
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
minio:
# fixme: let's not depend on external unofficial image
image: minio/minio
ports:
- 9000:9000
env:
MINIO_ROOT_USER: admin
MINIO_ROOT_PASSWORD: admin123456
options: >-
--name=minio
--health-cmd "curl http://localhost:9000/minio/health/live"
--command "server /data --console-address ':9090' --address ':9000'"
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Go Test
run: |
docker ps -a
go test -v ./...
env:
# The hostname used to communicate with the PostgreSQL service container
PG_DB_HOST: "localhost"
PG_DB_PORT: "5432"
PG_DB_SSLMODE: "false"
PG_DB_USERNAME: "postgres"
PG_DB_PASSWORD: "postgres"
# The hostname used to communicate with the Redis service container
REDIS_ADDR: "localhost:6379"
# The hostname used to communicate with the Mysql service container
MYSQL_DB_HOST: "localhost"
MYSQL_DB_PORT: "33306"
MYSQL_DB_SSLMODE: "false"
MYSQL_DB_USERNAME: "mysql"
MYSQL_DB_PASSWORD: "mysql"
# The hostname used to communicate with the Minio service container
MINIO_ENDPOINT: "localhost:9000"
MINIO_ACCESS_KEY: "admin"
MINIO_SECRET_KEY: "admin123456"
MINIO_SSL: "false"