Repository navigation
138 lines (130 loc) · 4.11 KB
/
Copy pathci.yml
File metadata and controls
138 lines (130 loc) · 4.11 KB
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
name: 构建、测试与贡献建议
on:
pull_request:
types: [opened, synchronize, reopened, edited]
push:
branches: [main]
tags: ['**']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# 与便携包编译参数保持一致,复用测试和构建缓存。
CGO_ENABLED: '0'
GOFLAGS: -trimpath
jobs:
commit-language:
name: 中文描述建议
if: github.event_name == 'pull_request' || (github.event_name == 'push' && !github.event.deleted)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-node@v4
with:
node-version: 22
- name: 验证建议规则
run: node --test .github/scripts/chinese-advice.test.mjs
- name: 提供中文描述建议
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: node .github/scripts/chinese-advice.mjs
go:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: dev/go.mod
cache-dependency-path: dev/go.sum
- name: Test
working-directory: dev
run: go test -vet=off ./...
- name: Vet
working-directory: dev
run: go vet ./...
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: dev/web/package-lock.json
- name: 构建便携包
run: node build.mjs
- name: 上传便携包
uses: actions/upload-artifact@v4
with:
name: easybotce-${{ runner.os }}-${{ runner.arch }}
path: |
release/*.zip
release/*.tar.gz
if-no-files-found: error
compression-level: 0
mysql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["8.4.11", "9.6.0"]
services:
mysql:
image: mysql:${{ matrix.version }}
env:
MYSQL_ROOT_PASSWORD: root-test-password
MYSQL_DATABASE: easybot_test
MYSQL_USER: easybot
MYSQL_PASSWORD: easybot-test-password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot-test-password"
--health-interval=3s
--health-timeout=5s
--health-retries=40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: dev/go.mod
cache-dependency-path: dev/go.sum
- name: Test against MySQL
working-directory: dev
env:
EASYBOT_TEST_DATABASE_DSN: mysql://easybot:easybot-test-password@127.0.0.1:3306/easybot_test
# 其他包由跨平台任务覆盖;外部数据库测试每次连接新测试库执行。
run: go test -count=1 -vet=off ./internal/store
postgres:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18.6
env:
POSTGRES_DB: easybot_test
POSTGRES_USER: easybot
POSTGRES_PASSWORD: easybot-test-password
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -h 127.0.0.1 -U easybot -d easybot_test"
--health-interval=3s
--health-timeout=5s
--health-retries=40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: dev/go.mod
cache-dependency-path: dev/go.sum
- name: Test against PostgreSQL
working-directory: dev
env:
EASYBOT_TEST_DATABASE_DSN: postgres://easybot:easybot-test-password@127.0.0.1:5432/easybot_test?sslmode=disable
run: go test -count=1 -vet=off ./internal/store