diff --git a/.github/mysql.sh b/.github/mysql.sh new file mode 100755 index 0000000..b0f4c1a --- /dev/null +++ b/.github/mysql.sh @@ -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 diff --git a/.github/postgres.sh b/.github/postgres.sh new file mode 100755 index 0000000..02725e0 --- /dev/null +++ b/.github/postgres.sh @@ -0,0 +1 @@ +PGPASSWORD=password psql -h 127.0.0.1 -U username postgres -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab72c92..bfd88f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,11 @@ name: Building & Testing on: push: + branches: [main] paths-ignore: - "*.md" pull_request: + branches: [main] defaults: run: @@ -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: @@ -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 diff --git a/integration-tests/all-fields/run.sh b/integration-tests/all-fields/run.sh index b324f36..23178b6 100755 --- a/integration-tests/all-fields/run.sh +++ b/integration-tests/all-fields/run.sh @@ -3,5 +3,5 @@ set -euo pipefail dub build $RORM_CLI make-migrations -$RORM_CLI migrate +$RORM_CLI migrate --log-sql ./all-fields diff --git a/integration-tests/crud-vibe/run.sh b/integration-tests/crud-vibe/run.sh index 57b66a5..774315f 100755 --- a/integration-tests/crud-vibe/run.sh +++ b/integration-tests/crud-vibe/run.sh @@ -3,5 +3,5 @@ set -euo pipefail dub build $RORM_CLI make-migrations -$RORM_CLI migrate +$RORM_CLI migrate --log-sql ./crud-vibe diff --git a/integration-tests/crud/run.sh b/integration-tests/crud/run.sh index fee2a02..4444c6e 100755 --- a/integration-tests/crud/run.sh +++ b/integration-tests/crud/run.sh @@ -3,5 +3,5 @@ set -euo pipefail dub build $RORM_CLI make-migrations -$RORM_CLI migrate +$RORM_CLI migrate --log-sql ./crud diff --git a/integration-tests/nested-join/run.sh b/integration-tests/nested-join/run.sh index 8fae3fd..2caa568 100755 --- a/integration-tests/nested-join/run.sh +++ b/integration-tests/nested-join/run.sh @@ -3,5 +3,5 @@ set -euo pipefail dub build $RORM_CLI make-migrations -$RORM_CLI migrate +$RORM_CLI migrate --log-sql ./nested-join diff --git a/integration-tests/one-to-many/run.sh b/integration-tests/one-to-many/run.sh index a7520f4..047891c 100755 --- a/integration-tests/one-to-many/run.sh +++ b/integration-tests/one-to-many/run.sh @@ -3,5 +3,5 @@ set -euo pipefail dub build $RORM_CLI make-migrations -$RORM_CLI migrate +$RORM_CLI migrate --log-sql ./one-to-many diff --git a/integration-tests/run.sh b/integration-tests/run.sh index ee3faf4..8997fa6 100755 --- a/integration-tests/run.sh +++ b/integration-tests/run.sh @@ -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