-
Notifications
You must be signed in to change notification settings - Fork 47
98 lines (87 loc) · 3.02 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
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ 'oldstable', 'stable' ]
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: pass
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
- name: PostgreSQL Setup
run: >
echo "*:*:*:*:pass" > $HOME/.pgpass
&& chmod 600 $HOME/.pgpass
&& psql --host localhost --username user -c 'CREATE DATABASE dialect_droppable;'
&& psql --host localhost --username user -c 'CREATE DATABASE driver_droppable;'
- name: MySQL Setup
run: >
echo -e "[client]\nuser = root\npassword = pass\nhost = localhost\nprotocol = tcp" > $HOME/.my.cnf
&& chmod 600 $HOME/.my.cnf
&& mysql --execute 'CREATE DATABASE dialect_droppable;'
&& mysql --execute 'CREATE DATABASE driver_droppable;'
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
cache: true
- name: Install Dependencies
run: go mod download
- name: Run tests
env:
PSQL_DIALECT_TEST_DSN: postgresql://user:pass@localhost:5432/dialect_droppable?sslmode=disable
PSQL_DRIVER_TEST_DSN: postgresql://user:pass@localhost:5432/driver_droppable?sslmode=disable
MYSQL_DIALECT_TEST_DSN: root:pass@(localhost:3306)/dialect_droppable?tls=skip-verify&multiStatements=true
MYSQL_DRIVER_TEST_DSN: root:pass@(localhost:3306)/driver_droppable?tls=skip-verify&multiStatements=true
run: go test -race -covermode atomic -coverprofile=covprofile.out -coverpkg=github.com/stephenafamo/bob/... ./...
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: covprofile.out
test-windows-sqlite:
# Run generation test on windows to catch filepath issues
# Testing Postgres and MySQL are not possible since the windows runner
# does not support containers
runs-on: windows-latest
strategy:
matrix:
go: ['stable' ]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
cache: true
- name: Install Dependencies
run: go mod download
- name: Run tests
run: go test -race ./gen/bobgen-sqlite/driver