Use the configuration depending on the selected database provider #13

Merged
Wesser merged 33 commits from feat/database-persistence into feat/add-setup 2024-06-01 05:45:18 +03:00
Showing only changes of commit f17ee43805 - Show all commits

View File

@ -12,35 +12,7 @@ jobs:
matrix: matrix:
db-provider: [sqlite, mysql, postgresql] db-provider: [sqlite, mysql, postgresql]
runs-on: ubuntu-latest 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:
- 5555:3306
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:
- 6666:5432
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -68,10 +40,28 @@ jobs:
run: | run: |
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 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
- name: Install MySQL
if: matrix.db-provider == 'mysql'
run: |
sudo apt-get update
sudo apt-get install -y mysql-server
sudo service mysql start
sudo mysql -e "CREATE DATABASE testdb; CREATE USER 'root'@'localhost' IDENTIFIED BY 'root'; GRANT ALL PRIVILEGES ON testdb.* TO 'root'@'localhost'; FLUSH PRIVILEGES;"
- name: Modify configuration for PostgreSQL - name: Modify configuration for PostgreSQL
if: matrix.db-provider == 'postgresql' if: matrix.db-provider == 'postgresql'
run: | run: |
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 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
- name: Install PostgreSQL
if: matrix.db-provider == 'postgresql'
run: |
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
sudo service postgresql start
sudo -u postgres psql -c "CREATE DATABASE testdb;"
sudo -u postgres psql -c "CREATE USER postgres WITH PASSWORD 'postgres';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE testdb TO postgres;"
- name: Run tests - name: Run tests
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal run: dotnet test --configuration Release --no-build --no-restore --verbosity normal