-
Notifications
You must be signed in to change notification settings - Fork 47
175 lines (150 loc) · 4.71 KB
/
unit-test.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Unit-Test
on:
workflow_dispatch:
inputs:
tags:
description: "Comment"
push:
branches: [main]
env:
GOU_TEST_AES_KEY: "^*aNBue!loLTTiP*4i&BSK7s#QRbe0^g"
GOU_TEST_REDIS_HOST: "127.0.0.1"
GOU_TEST_REDIS_PORT: "6379"
GOU_TEST_GITHUB_TOKEN: ${{ secrets.GOU_TEST_GITHUB_TOKEN }}
GOU_TEST_GITHUB_REPO: github.com/YaoApp/workshop-tests-private
GOU_TEST_DSL_TABLE_NAME: test_env
GOU_TEST_APPLICATION: ${{ github.WORKSPACE }}/gou-dev-app
GOU_TEST_PLUGIN: ${{ github.WORKSPACE }}/gou-dev-app/plugins/linux
SEND_MAIL_WORKER_NUMS: 2
SEND_MAIL_TEST_MAIL: [email protected]
REPO_KUN: ${{ github.repository_owner }}/kun
REPO_XUN: ${{ github.repository_owner }}/xun
REPO_APP: YaoApp/gou-dev-app
MYSQL_TEST_HOST: "127.0.0.1"
MYSQL_TEST_PORT: "3308"
MYSQL_TEST_USER: test
MYSQL_TEST_PASS: "123456"
SQLITE_DB: "./app/db/yao.db"
REDIS_TEST_HOST: "127.0.0.1"
REDIS_TEST_PORT: "6379"
REDIS_TEST_DB: "2"
MONGO_TEST_HOST: "127.0.0.1"
MONGO_TEST_PORT: "27017"
MONGO_TEST_USER: "root"
MONGO_TEST_PASS: "123456"
OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }}
jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.20.0]
db: [MySQL8.0, SQLite3]
redis: [4, 5, 6]
mongo: ["6.0"]
steps:
- name: Checkout Kun
uses: actions/checkout@v4
with:
repository: ${{ env.REPO_KUN }}
path: kun
- name: Checkout Xun
uses: actions/checkout@v4
with:
repository: ${{ env.REPO_XUN }}
path: xun
- name: Checkout Application
uses: actions/checkout@v4
with:
repository: ${{ env.REPO_APP }}
path: gou-dev-app
- name: Checkout V8Go
uses: actions/checkout@v4
with:
repository: yaoapp/v8go
lfs: true
path: v8go
- name: Checkout Demo WMS
uses: actions/checkout@v4
with:
repository: yaoapp/demo-wms
path: demo-wms
- name: Move Kun, Xun, V8go, Application
run: |
mv kun ../
mv xun ../
mv v8go ../
mv demo-wms ../
mv gou-dev-app ../
ls -l .
ls -l ../
- name: Checkout code
uses: actions/checkout@v4
- name: Move Application
run: |
mv ../gou-dev-app .
ls -l .
ls -l ../
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis }}
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongo }}
mongodb-username: root
mongodb-password: 123456
mongodb-db: test
- name: Setup MySQL8.0 (connector)
uses: ./.github/actions/setup-db
with:
kind: "MySQL8.0"
db: "test"
user: "test"
password: "123456"
port: "3308"
- name: Setup ${{ matrix.db }}
uses: ./.github/actions/setup-db
with:
kind: "${{ matrix.db }}"
db: "gou"
user: "gou"
password: "123456"
- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Setup Go Tools
run: |
make tools
- name: Setup ENV
run: |
echo "GOU_TEST_DSN=$DSN" >> $GITHUB_ENV
echo "GOU_TEST_DB_DRIVER=$DB_DRIVER" >> $GITHUB_ENV
echo "GOU_TEST_API_ROOT=$GITHUB_WORKSPACE/app/apis" >> $GITHUB_ENV
echo "GOU_TEST_FLW_ROOT=$GITHUB_WORKSPACE/app/flows" >> $GITHUB_ENV
echo "GOU_TEST_MOD_ROOT=$GITHUB_WORKSPACE/app/models" >> $GITHUB_ENV
echo "GOU_TEST_PLG_ROOT=$HOME/data/gou-unit/plugins" >> $GITHUB_ENV
echo "GOU_TEST_SCRIPT_ROOT=$GITHUB_WORKSPACE/app/scripts" >> $GITHUB_ENV
echo "GOU_TEST_QUERY_ROOT=$GITHUB_WORKSPACE/query/assets" >> $GITHUB_ENV
echo "GOU_TEST_PLG_LOG=$HOME/data/gou-unit/logs" >> $GITHUB_ENV
echo "GOU_TEST_APP_ROOT=$GITHUB_WORKSPACE/tests/app" >> $GITHUB_ENV
echo "YAO_PATH=$GITHUB_WORKSPACE/tests/yao" >> $GITHUB_ENV
mkdir -p $HOME/.yao
echo ${{ secrets.GOU_TEST_GITHUB_TOKEN }} > $HOME/.yao/github_token
chmod 600 $HOME/.yao/github_token
ls -l $HOME/.yao/github_token
- name: Run Benchmark
run: |
make bench
- name: Run Test
run: |
make vet
make fmt-check
make misspell-check
make test
- name: Codecov Report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos