-
Notifications
You must be signed in to change notification settings - Fork 2.3k
114 lines (105 loc) · 3.1 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
name: test
on:
pull_request:
push:
workflow_dispatch:
env:
MYSQL_TEST_USER: gotest
MYSQL_TEST_PASS: secret
MYSQL_TEST_ADDR: 127.0.0.1:3306
MYSQL_TEST_CONCURRENT: 1
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dominikh/staticcheck-action@v1.3.1
list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: list
id: set-matrix
run: |
import json
import os
go = [
# Keep the most recent production release at the top
'1.23',
# Older production releases
'1.22',
'1.21',
]
mysql = [
'9.0',
'8.4', # LTS
'8.0',
'5.7',
'mariadb-11.4', # LTS
'mariadb-11.2',
'mariadb-11.1',
'mariadb-10.11', # LTS
'mariadb-10.6', # LTS
'mariadb-10.5', # LTS
]
includes = []
# Go versions compatibility check
for v in go[1:]:
includes.append({'os': 'ubuntu-latest', 'go': v, 'mysql': mysql[0]})
matrix = {
# OS vs MySQL versions
'os': [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ],
'go': [ go[0] ],
'mysql': mysql,
'include': includes
}
output = json.dumps(matrix, separators=(',', ':'))
with open(os.environ["GITHUB_OUTPUT"], 'a', encoding="utf-8") as f:
print(f"matrix={output}", file=f)
shell: python
test:
needs: list
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.list.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: ${{ matrix.mysql }}
user: ${{ env.MYSQL_TEST_USER }}
password: ${{ env.MYSQL_TEST_PASS }}
my-cnf: |
innodb_log_file_size=256MB
innodb_buffer_pool_size=512MB
max_allowed_packet=16MB
; TestConcurrent fails if max_connections is too large
max_connections=50
local_infile=1
performance_schema=on
- name: setup database
run: |
mysql --user 'root' --host '127.0.0.1' -e 'create database gotest;'
- name: test
run: |
go test -v '-race' '-covermode=atomic' '-coverprofile=coverage.out' -parallel 10
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
flag-name: ${{ runner.os }}-Go-${{ matrix.go }}-DB-${{ matrix.mysql }}
parallel: true
# notifies that all test jobs are finished.
finish:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true