Skip to content

clear DB before running integration tests #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysqladmin -h 127.0.0.1 -u username -ppassword -f drop db || true
mysqladmin -h 127.0.0.1 -u username -ppassword create db || true
1 change: 1 addition & 0 deletions .github/postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PGPASSWORD=password psql -h 127.0.0.1 -U username postgres -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true
44 changes: 27 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Building & Testing
on:
push:
branches: [main]
paths-ignore:
- "*.md"
pull_request:
branches: [main]

defaults:
run:
Expand Down Expand Up @@ -49,50 +51,50 @@ jobs:
run-tests-db:
name: Build and test DORM with external DB
runs-on: ubuntu-latest
needs: run-tests
# needs: run-tests
strategy:
fail-fast: false
matrix:
include:
- image: mariadb:10.9
health_cmd: "mysqladmin ping"
config: mysql.toml
config: mysql
compiler: dmd-latest
- image: mariadb:10.6
health_cmd: "mysqladmin ping"
config: mysql.toml
config: mysql
compiler: dmd-latest
- image: postgres:15
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: dmd-latest
- image: postgres:13
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: dmd-latest
- image: postgres:11
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: dmd-latest
- image: mariadb:10.9
health_cmd: "mysqladmin ping"
config: mysql.toml
config: mysql
compiler: ldc-latest
- image: mariadb:10.6
health_cmd: "mysqladmin ping"
config: mysql.toml
config: mysql
compiler: ldc-latest
- image: postgres:15
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: ldc-latest
- image: postgres:13
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: ldc-latest
- image: postgres:11
health_cmd: pg_isready
config: postgres.toml
config: postgres
compiler: ldc-latest

services:
Expand Down Expand Up @@ -124,15 +126,23 @@ jobs:
with:
compiler: ${{ matrix.compiler }}

- name: Build & test dorm
run: dub build && dub test
- name: Install MySQL client to clear DB in tests
if: ${{ matrix.config == 'mysql' }}
run: sudo apt update && sudo apt install mariadb-client

- name: Build test app
run: dub build
working-directory: testapp
- name: Install PostgreSQL client to clear DB in tests
if: ${{ matrix.config == 'postgres' }}
run: sudo apt update && sudo apt install postgresql-client

- name: Test dorm
run: dub test

- name: Prepare the integration tests
run: for i in $(find -maxdepth 1 -type d); do cp -v ../.github/${{ matrix.config }} $i/database.toml; done
run: |
for i in $(find -maxdepth 1 -type d); do
cp -v ../.github/${{ matrix.config }}.toml $i/database.toml
cp -v ../.github/${{ matrix.config }}.sh $i/.pre-run-hook.sh
done
working-directory: integration-tests

- name: Run integration tests
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/all-fields/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -euo pipefail

dub build
$RORM_CLI make-migrations
$RORM_CLI migrate
$RORM_CLI migrate --log-sql
./all-fields
2 changes: 1 addition & 1 deletion integration-tests/crud-vibe/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -euo pipefail

dub build
$RORM_CLI make-migrations
$RORM_CLI migrate
$RORM_CLI migrate --log-sql
./crud-vibe
2 changes: 1 addition & 1 deletion integration-tests/crud/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -euo pipefail

dub build
$RORM_CLI make-migrations
$RORM_CLI migrate
$RORM_CLI migrate --log-sql
./crud
2 changes: 1 addition & 1 deletion integration-tests/nested-join/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -euo pipefail

dub build
$RORM_CLI make-migrations
$RORM_CLI migrate
$RORM_CLI migrate --log-sql
./nested-join
2 changes: 1 addition & 1 deletion integration-tests/one-to-many/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -euo pipefail

dub build
$RORM_CLI make-migrations
$RORM_CLI migrate
$RORM_CLI migrate --log-sql
./one-to-many
3 changes: 3 additions & 0 deletions integration-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ do
rm -rf migrations
rm -f .models.json
rm -f *.sqlite3
if [ -f .pre-run-hook.sh ]; then
source .pre-run-hook.sh
fi
if [ ! -f database.toml ]; then
echo "$DATABASE_CONFIG" > database.toml
fi
Expand Down