2024-05-30 21:45:45 +03:00
|
|
|
name: Test with Different Databases
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
[master, 'release/*']
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
db-provider: [sqlite, mysql, postgresql]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
services:
|
|
|
|
mysql:
|
|
|
|
image: mysql:latest
|
|
|
|
env:
|
|
|
|
MYSQL_ROOT_PASSWORD: root
|
|
|
|
MYSQL_DATABASE: testdb
|
|
|
|
options: >-
|
|
|
|
--health-cmd "mysqladmin ping --silent"
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
ports:
|
2024-05-31 01:16:13 +03:00
|
|
|
- 5555:3306
|
2024-05-30 21:45:45 +03:00
|
|
|
|
|
|
|
postgres:
|
|
|
|
image: postgres:latest
|
|
|
|
env:
|
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
POSTGRES_DB: testdb
|
|
|
|
options: >-
|
|
|
|
--health-cmd "pg_isready -U postgres"
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
ports:
|
2024-05-31 01:16:13 +03:00
|
|
|
- 6666:5432
|
2024-05-30 21:45:45 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up .NET Core
|
|
|
|
uses: actions/setup-dotnet@v4
|
|
|
|
with:
|
|
|
|
dotnet-version: 8.0.x
|
|
|
|
|
|
|
|
- name: Restore dependencies
|
|
|
|
run: dotnet restore
|
|
|
|
|
|
|
|
- name: Build the solution
|
|
|
|
run: dotnet build --configuration Release
|
|
|
|
|
|
|
|
- name: Install jq
|
|
|
|
run: sudo apt-get install -y jq
|
|
|
|
|
|
|
|
- name: Modify configuration for SQLite
|
|
|
|
if: matrix.db-provider == 'sqlite'
|
|
|
|
run: |
|
|
|
|
jq '.DbSettings.TypeDatabase = 1 | .DbSettings.ConnectionStringSql = "Data Source=test.db3"' Settings.json > temp.json && mv temp.json Settings.json
|
|
|
|
|
|
|
|
- name: Modify configuration for MySQL
|
|
|
|
if: matrix.db-provider == 'mysql'
|
|
|
|
run: |
|
2024-05-31 01:16:13 +03:00
|
|
|
jq '.DbSettings.TypeDatabase = 0 | .DbSettings.ConnectionStringSql = "Server=127.0.0.1;Port=5555;Database=testdb;Uid=root;Pwd=root;"' Settings.json > temp.json && mv temp.json Settings.json
|
2024-05-30 21:45:45 +03:00
|
|
|
|
|
|
|
- name: Modify configuration for PostgreSQL
|
|
|
|
if: matrix.db-provider == 'postgresql'
|
|
|
|
run: |
|
2024-05-31 01:16:13 +03:00
|
|
|
jq '.DbSettings.TypeDatabase = 2 | .DbSettings.ConnectionStringSql = "Host=127.0.0.1;Port=6666;Database=testdb;Username=postgres;Password=postgres"' Settings.json > temp.json && mv temp.json Settings.json
|
2024-05-30 21:45:45 +03:00
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal
|