-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (103 loc) · 3.13 KB
/
tests_with_database.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
name: Tests with database
on:
push:
branches:
- main
pull_request: {}
jobs:
mysql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- icinga/icingadb-mysql:5.5
- icinga/icingadb-mysql:5.6
- mysql:5.7
- mysql:8
- mysql:latest
- icinga/mariadb:10.1
- mariadb:10.2
- mariadb:10.3
- mariadb:10.4
- mariadb:10.5
- mariadb:10.6
- mariadb:10.7
- mariadb:latest
env:
NOTIFICATIONS_TESTS_DB_TYPE: mysql
NOTIFICATIONS_TESTS_DB: notifications
NOTIFICATIONS_TESTS_DB_USER: root
NOTIFICATIONS_TESTS_DB_PASSWORD: notifications
NOTIFICATIONS_TESTS_DB_HOST: 127.0.0.1
NOTIFICATIONS_TESTS_DB_PORT: 3306
services:
mysql:
image: ${{ matrix.image }}
env:
MYSQL_ROOT_PASSWORD: ${{ env.NOTIFICATIONS_TESTS_DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.NOTIFICATIONS_TESTS_DB }}
ports:
- 3306:3306
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Checkout code
uses: actions/checkout@v4
- name: Download dependencies
run: go get -v -t -d ./...
- name: Importing Schema
run: |
sleep 5
mysql -h127.0.0.1 -u${{ env.NOTIFICATIONS_TESTS_DB_USER }} -p${{ env.NOTIFICATIONS_TESTS_DB_PASSWORD
}} ${{ env.NOTIFICATIONS_TESTS_DB }} < ${{ github.workspace }}/schema/mysql/schema.sql
- name: Run tests
timeout-minutes: 10
run: go test -v -timeout 5m ./...
postgresql:
name: PostgreSQL ${{ matrix.version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["9.6", "10", "11", "12", "13", "14", "15", "latest"]
env:
NOTIFICATIONS_TESTS_DB_TYPE: pgsql
NOTIFICATIONS_TESTS_DB: notifications
NOTIFICATIONS_TESTS_DB_USER: postgres
NOTIFICATIONS_TESTS_DB_PASSWORD: notifications
NOTIFICATIONS_TESTS_DB_HOST: 127.0.0.1
NOTIFICATIONS_TESTS_DB_PORT: 5432
services:
postgres:
image: postgres:${{ matrix.version }}
env:
POSTGRES_PASSWORD: ${{ env.NOTIFICATIONS_TESTS_DB_PASSWORD }}
POSTGRES_DB: ${{ env.NOTIFICATIONS_TESTS_DB }}
# Wait until postgres becomes ready
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Checkout code
uses: actions/checkout@v4
- name: Importing Schema
env:
PGPASSWORD: ${{ env.NOTIFICATIONS_TESTS_DB_PASSWORD }}
run: |
psql -U postgres -w -h 127.0.0.1 -d ${{ env.NOTIFICATIONS_TESTS_DB }} < ${{ github.workspace }}/schema/pgsql/schema.sql
- name: Download dependencies
run: go get -v -t -d ./...
- name: Run tests
timeout-minutes: 10
run: go test -v -timeout 5m ./...