From 4a4b584a46d9ea0c47995cf1ac15203e95403ee5 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 7 Jan 2024 22:29:51 +0100 Subject: [PATCH] Move prepare database commands to the bootstrap file --- .github/workflows/continuous-integration.yml | 16 ++++--------- GNUmakefile | 9 ++----- tests/bootstrap.php | 25 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 172f40324..ca38ff098 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -73,12 +73,8 @@ jobs: with: composer-options: "--optimize-autoloader --prefer-dist" - - name: "Prepare database" - run: | - cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - php bin/console doctrine:database:drop --force --env=test - php bin/console doctrine:database:create --env=test - php bin/console doctrine:migrations:migrate --no-interaction --env=test -vv + - name: "Prepare database configuration" + run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - name: "Prepare fixtures" run: "make fixtures" @@ -148,12 +144,8 @@ jobs: with: composer-options: "--optimize-autoloader --prefer-dist" - - name: "Prepare database" - run: | - cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - php bin/console doctrine:database:drop --force --env=test - php bin/console doctrine:database:create --env=test - php bin/console doctrine:migrations:migrate --no-interaction --env=test -vv + - name: "Prepare database configuration" + run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - name: "Prepare fixtures" run: "make fixtures" diff --git a/GNUmakefile b/GNUmakefile index 403551e08..dd3a2dba1 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -31,15 +31,10 @@ build: ## Run webpack @yarn install @yarn build:$(ENV) -prepare: ## Prepare database for testsuite - -php bin/console doctrine:database:drop --force --env=test - php bin/console doctrine:database:create --env=test - php bin/console doctrine:migrations:migrate --no-interaction --env=test -vv - fixtures: ## Load fixtures into database php bin/console doctrine:fixtures:load --no-interaction --env=test -test: prepare fixtures ## Launch wallabag testsuite +test: fixtures ## Launch wallabag testsuite XDEBUG_MODE=off php -dmemory_limit=-1 bin/phpunit -v release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). @@ -51,6 +46,6 @@ endif deploy: ## Deploy wallabag @bundle exec cap staging deploy -.PHONY: help prepare install fixtures update build test release deploy run dev +.PHONY: help install fixtures update build test release deploy run dev .DEFAULT_GOAL := install diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ab7b163e3..76ba2f059 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,32 @@ remove(__DIR__ . '/../var/cache/test'); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:drop', + '--force', + '--env=test', +]))->run(); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:create', + '--env=test', +]))->mustRun(); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:migrations:migrate', + '--no-interaction', + '--env=test', + '-vv', +]))->mustRun();