From d80b8f8da9ddd67f03161420888a310283408f85 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 11:35:21 +0100 Subject: [PATCH 1/6] clear DB before running integration tests --- .github/mysql.sh | 2 ++ .github/postgres.sh | 1 + .github/workflows/ci.yml | 34 +++++++++++++++++++++++----------- integration-tests/run.sh | 3 +++ 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100755 .github/mysql.sh create mode 100755 .github/postgres.sh diff --git a/.github/mysql.sh b/.github/mysql.sh new file mode 100755 index 0000000..57ba2d2 --- /dev/null +++ b/.github/mysql.sh @@ -0,0 +1,2 @@ +mysqladmin -u username -ppassword drop db || true +mysqladmin -u username -ppassword create db || true diff --git a/.github/postgres.sh b/.github/postgres.sh new file mode 100755 index 0000000..928b1a7 --- /dev/null +++ b/.github/postgres.sh @@ -0,0 +1 @@ +PGPASSWORD=password psql -U username db -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab72c92..8bce1aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,43 +56,43 @@ jobs: 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,6 +124,14 @@ jobs: with: compiler: ${{ matrix.compiler }} + - name: Install MySQL client to clear DB in tests + if: ${{ matrix.config == 'mysql' }} + run: apt install mariadb-client + + - name: Install MySQL client to clear DB in tests + if: ${{ matrix.config == 'postgres' }} + run: apt install postgresql-client + - name: Build & test dorm run: dub build && dub test @@ -132,7 +140,11 @@ jobs: working-directory: testapp - 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/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 From 58be0d457614594b378681d055930ef6308b3f1b Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 11:51:14 +0100 Subject: [PATCH 2/6] add missing sudo, debug tests right now --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bce1aa..faaf8a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ 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: @@ -126,11 +126,11 @@ jobs: - name: Install MySQL client to clear DB in tests if: ${{ matrix.config == 'mysql' }} - run: apt install mariadb-client + run: sudo apt install mariadb-client - - name: Install MySQL client to clear DB in tests + - name: Install PostgreSQL client to clear DB in tests if: ${{ matrix.config == 'postgres' }} - run: apt install postgresql-client + run: sudo apt install postgresql-client - name: Build & test dorm run: dub build && dub test From c43060f64c8095cab9e1ebaa28ba3a836a765ba4 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 11:54:39 +0100 Subject: [PATCH 3/6] fix CI 2 --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faaf8a7..bfe0263 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: @@ -126,11 +128,11 @@ jobs: - name: Install MySQL client to clear DB in tests if: ${{ matrix.config == 'mysql' }} - run: sudo apt install mariadb-client + run: sudo apt update && sudo apt install mariadb-client - name: Install PostgreSQL client to clear DB in tests if: ${{ matrix.config == 'postgres' }} - run: sudo apt install postgresql-client + run: sudo apt update && sudo apt install postgresql-client - name: Build & test dorm run: dub build && dub test From 8b8e7706169e7bfd22994b0483f484a3eb6d56f1 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 11:59:22 +0100 Subject: [PATCH 4/6] use localhost in SQL test scripts --- .github/mysql.sh | 4 ++-- .github/postgres.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/mysql.sh b/.github/mysql.sh index 57ba2d2..3cc077b 100755 --- a/.github/mysql.sh +++ b/.github/mysql.sh @@ -1,2 +1,2 @@ -mysqladmin -u username -ppassword drop db || true -mysqladmin -u username -ppassword create db || true +mysqladmin -h 127.0.0.1 -u username -ppassword 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 index 928b1a7..c2bdd4a 100755 --- a/.github/postgres.sh +++ b/.github/postgres.sh @@ -1 +1 @@ -PGPASSWORD=password psql -U username db -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true +PGPASSWORD=password psql -h 127.0.0.1 -U username db -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true From f026c462a187453c4e472aa5519ca9623689d320 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 12:03:15 +0100 Subject: [PATCH 5/6] CI improvements --- .github/mysql.sh | 2 +- .github/postgres.sh | 2 +- .github/workflows/ci.yml | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/mysql.sh b/.github/mysql.sh index 3cc077b..b0f4c1a 100755 --- a/.github/mysql.sh +++ b/.github/mysql.sh @@ -1,2 +1,2 @@ -mysqladmin -h 127.0.0.1 -u username -ppassword drop db || true +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 index c2bdd4a..4085154 100755 --- a/.github/postgres.sh +++ b/.github/postgres.sh @@ -1 +1 @@ -PGPASSWORD=password psql -h 127.0.0.1 -U username db -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true +PGPASSWORD=password psql -h 127.0.0.1 -U username -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfe0263..bfd88f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,12 +134,8 @@ jobs: if: ${{ matrix.config == 'postgres' }} run: sudo apt update && sudo apt install postgresql-client - - name: Build & test dorm - run: dub build && dub test - - - name: Build test app - run: dub build - working-directory: testapp + - name: Test dorm + run: dub test - name: Prepare the integration tests run: | From 6bac3f30038b74e0948d09670556ebd7b5aaf568 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 1 Dec 2022 12:08:10 +0100 Subject: [PATCH 6/6] extra verbosity in integration tests --- .github/postgres.sh | 2 +- integration-tests/all-fields/run.sh | 2 +- integration-tests/crud-vibe/run.sh | 2 +- integration-tests/crud/run.sh | 2 +- integration-tests/nested-join/run.sh | 2 +- integration-tests/one-to-many/run.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/postgres.sh b/.github/postgres.sh index 4085154..02725e0 100755 --- a/.github/postgres.sh +++ b/.github/postgres.sh @@ -1 +1 @@ -PGPASSWORD=password psql -h 127.0.0.1 -U username -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true +PGPASSWORD=password psql -h 127.0.0.1 -U username postgres -c 'DROP DATABASE db;' -c 'CREATE DATABASE db;' || true 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