-
Notifications
You must be signed in to change notification settings - Fork 4
122 lines (111 loc) · 3.48 KB
/
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
on:
push:
branches:
- master
pull_request:
branches:
- master
name: build
jobs:
testing:
strategy:
matrix:
go-version: [ 1.16.x,1.17.x,1.18.x,1.19.x,1.20.x,1.21.x,1.22.x ]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
services:
mysql:
image: mysql:5.5
env:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --name redis
steps:
- name: Verify MYSQL connection
env:
PORT: ${{ job.services.mysql.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Checkout code
uses: actions/checkout@v3
- name: Setting Up DB
run: |
mysql -h 127.0.0.1 -P 3306 --protocol=tcp -u root -padmin < .ci/tests.db.sql
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Run tests
run: |
export GO111MODULE=on
export WORKPATH=$(pwd)
export GOPATH=$(go env GOPATH)
export SNAIL007PATH=$GOPATH/src/github.com/snail007/
mkdir -p $GOPATH/src/github.com/snail007
cd ../ && cp -R gmc $SNAIL007PATH/ && cd $SNAIL007PATH/gmc
go get -v -t -d ./...
go test ./...
codecov:
environment: gmc
name: codecov
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.5
env:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --name redis
steps:
- name: Verify MYSQL connection
env:
PORT: ${{ job.services.mysql.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: 1.20.x
id: go
- name: Checkout code
uses: actions/checkout@v3
- name: Init & Run
run: |
export WORKPATH=$(pwd)
export GOPATH=$(go env GOPATH)
export SNAIL007PATH=$GOPATH/src/github.com/snail007/
export F=gmct-linux-amd64.tar.gz
export LAST_VERSION=$(curl --silent "https://api.github.com/repos/snail007/gmct/releases/latest" | grep -Po '"tag_name": ?"\K.*?(?=")')
mkdir -p $GOPATH/src/github.com/snail007
mysql -h 127.0.0.1 -P 3306 --protocol=tcp -u root -padmin < .ci/tests.db.sql
wget -q -t 1 "https://github.com/snail007/gmct/releases/download/${LAST_VERSION}/$F"
tar zxf $F && chmod +x gmct && rm -rf $F
cd ../ && cp -R gmc $SNAIL007PATH/
cd $SNAIL007PATH/gmc/ && go get -v -t -d ./... && ./gmct cover -s -k
mv coverage.txt $WORKPATH/
- name: Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella