-
Notifications
You must be signed in to change notification settings - Fork 2
93 lines (84 loc) · 3.76 KB
/
unit-test-backend.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
name: Backend unit tests
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
unit-test-backend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
services:
postgres:
image: postgres:15.1-alpine
env:
POSTGRES_DB: plutonotest
POSTGRES_PASSWORD: plutonotest
POSTGRES_USER: plutonotest
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mysql:
image: mysql:5.7.40
env:
MYSQL_DATABASE: plutono_tests
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_USER: plutono
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.23.2
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Linter
run: make lint-go
- name: Test
run: go test -v -covermode=atomic -tags=integration ./pkg/...
- name: Test PostgreSQL integration
run: |
psql -p 5432 -h localhost -U plutonotest -d plutonotest -f devenv/docker/blocks/postgres_tests/setup.sql
go clean -testcache
for d in $(go list ./pkg/...); do go test -tags=integration "$d"; done
env:
PLUTONO_TEST_DB: postgres
PGPASSWORD: plutonotest
POSTGRES_HOST: localhost
- name: Test MySQL integration
run: |
cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h 127.0.0.1 -P 3306 -u root -prootpass
go clean -testcache
# run only integration tests
go test -tags=integration ./pkg/infra/serverlock -test.run="TestServerLok"
go test -tags=integration ./pkg/services/alerting -test.run="TestEngineTimeouts"
go test -tags=integration ./pkg/services/ngalert -test.run="TestCreatingAlertDefinition|TestCreatingConflictionAlertDefinition|TestUpdatingAlertDefinition|TestUpdatingConflictingAlertDefinition|TestDeletingAlertDefinition|TestAlertInstanceOperations"
go test -tags=integration ./pkg/services/sqlstore -test.run="TestAlertNotificationSQLAccess|TestAlertingDataAccess|TestPausingAlerts|TestAnnotations|TestApiKeyDataAccess|TestApiKeyErrors|TestDashboardAclDataAccess|TestDashboardFolderDataAccess|TestDashboardProvisioningTest|TestIntegratedDashboardService|TestDashboardSnapshotDBAccess|TestDeleteExpiredSnapshots|TestDashboardDataAccess|TestDashboard_SortingOptions|TestGetDashboardVersion|TestGetDashboardVersions|TestDeleteExpiredVersions|TestDataAccess|TestGetDefaultDataSource|TestGetDBHealthQuery|TestLoginAttempts|TestAccountDataAccess|TestPlaylistDataAccess|TestPreferencesDataAccess|TestQuotaCommandsAndQueries|TestSQLBuilder|TestSQLConnectionString|TestUserStarsDataAccess|TestIntegration_GetAdminStats|TestStatsDataAccess|TestSavingTags|TestTeamCommandsAndQueries|TestTempUserCommandsAndQueries|TestTransaction"
go test -tags=integration ./pkg/services/sqlstore/searchstore -test.run="TestBuilder_EqualResults_Basic|TestBuilder_Pagination|TestBuilder_Permissions"
go test -tags=integration ./pkg/tsdb/mysql -test.run="TestMySQL"
go test -tags=integration ./pkg/tsdb/postgres -test.run="TestGenerateConnectionString|TestPostgres"
env:
PLUTONO_TEST_DB: mysql
MYSQL_HOST: "127.0.0.1"