-
Notifications
You must be signed in to change notification settings - Fork 786
212 lines (184 loc) · 5.96 KB
/
build_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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: test
on:
push:
branches:
- master
- 'release-**'
pull_request:
branches:
- master
- 'release-**'
jobs:
unit_test:
name: unit tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:10.0
ports:
- 5432
env:
POSTGRES_USER: gorse
POSTGRES_PASSWORD: gorse_pass
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongo:
image: mongo:4.0
ports:
- 27017
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 5
clickhouse:
image: clickhouse/clickhouse-server:22
ports:
- 8123
options: >-
--health-cmd="clickhouse-client --query 'SELECT 1'"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis/redis-stack:6.2.6-v9
ports:
- 6379
steps:
- name: Set up dataset
run: |
mkdir -p ~/.gorse/dataset
mkdir -p ~/.gorse/download
wget https://cdn.gorse.io/datasets/ml-100k.zip -P ~/.gorse/download
wget https://cdn.gorse.io/datasets/ml-1m.zip -P ~/.gorse/download
wget https://cdn.gorse.io/datasets/pinterest-20.zip -P ~/.gorse/download
wget https://cdn.gorse.io/datasets/frappe.zip -P ~/.gorse/download
wget https://cdn.gorse.io/datasets/ml-tag.zip -P ~/.gorse/download
wget https://cdn.gorse.io/datasets/criteo.zip -P ~/.gorse/download
unzip ~/.gorse/download/ml-100k.zip -d ~/.gorse/dataset
unzip ~/.gorse/download/ml-1m.zip -d ~/.gorse/dataset
unzip ~/.gorse/download/pinterest-20.zip -d ~/.gorse/dataset
unzip ~/.gorse/download/frappe.zip -d ~/.gorse/dataset
unzip ~/.gorse/download/ml-tag.zip -d ~/.gorse/dataset
unzip ~/.gorse/download/criteo.zip -d ~/.gorse/dataset
- name: Set up Go 1.23.x
uses: actions/setup-go@v4
with:
go-version: 1.23.x
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./...
- name: Test
run: go test -timeout 20m -v ./... -coverprofile=coverage.txt -covermode=atomic
env:
# MySQL
MYSQL_URI: mysql://root:password@tcp(localhost:${{ job.services.mysql.ports[3306] }})/
# Postgres
POSTGRES_URI: postgres://gorse:gorse_pass@localhost:${{ job.services.postgres.ports[5432] }}/
# MongoDB
MONGO_URI: mongodb://root:password@localhost:${{ job.services.mongo.ports[27017] }}/
# ClickHouse
CLICKHOUSE_URI: clickhouse://localhost:${{ job.services.clickhouse.ports[8123] }}/
# Redis
REDIS_URI: redis://localhost:${{ job.services.redis.ports[6379] }}/
- name: Upload
run: bash <(curl -s https://codecov.io/bash)
integrate_test:
name: integrate tests
runs-on: ubuntu-latest
strategy:
matrix:
database: [mysql, postgres, mongo, clickhouse]
steps:
- uses: actions/checkout@v1
- uses: cuchi/jinja2-action@v1.2.0
with:
template: client/docker-compose.yml.j2
output_file: client/docker-compose.yml
strict: true
variables: |
database=${{ matrix.database }}
- name: Build the stack
run: docker compose -f client/docker-compose.yml --project-directory . up -d
env:
DOCKER_BUILDKIT: 1
- name: Check the deployed service URL
uses: jtalk/url-health-check-action@v2
with:
# Check the following URLs one by one sequentially
url: http://127.0.0.1:8088/metrics|http://127.0.0.1:8087/metrics|http://127.0.0.1:8089/metrics
# Fail this action after this many failed attempts
max-attempts: 5
# Delay between retries
retry-delay: 5s
# Retry all errors, including 404. This option might trigger curl upgrade.
retry-all: true
- name: Set up Go 1.23.x
uses: actions/setup-go@v4
with:
go-version: 1.23.x
id: go
- name: Test
run: go test -tags='integrate_test' ./client/
- name: Download dataset
if: ${{ matrix.database == 'mysql' }}
run: wget https://cdn.gorse.io/example/github.sql
- name: Import dataset
if: ${{ matrix.database == 'mysql' }}
run: mysql -h 127.0.0.1 -u gorse -pgorse_pass gorse < github.sql
compat_test:
name: compatibility tests
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.2
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: password
steps:
- name: Set up Go 1.23.x
uses: actions/setup-go@v4
with:
go-version: 1.23.x
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Test MariaDB
run: go test ./storage/data -run ^TestMySQL_
env:
MYSQL_URI: mysql://root:password@tcp(localhost:${{ job.services.mariadb.ports[3306] }})/
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.23.x
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
args: --timeout 20m