From ecc1e2cb3317d163f772bbce04aee88d3c62a149 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Tue, 12 Mar 2019 23:13:16 +0100 Subject: [PATCH] ci: run tests in parallel (#2515) --- .circleci/config.yml | 12 +++-- .circleci/config.yml.sig | Bin 95 -> 95 bytes phpunit.xml | 14 ++---- .../Auth/AuthControllerTest.php | 2 +- .../Commands/CalculateStatisticsTest.php | 2 +- .../{Unit => }/Commands/ImportVCardsTest.php | 2 +- .../{Unit => }/Commands/SendRemindersTest.php | 2 +- .../Commands/SendStayInTouchTest.php | 2 +- .../ActivityTypeCategoriesTest.php} | 4 +- .../ActivityTypesTest.php} | 4 +- .../CallsTest.php} | 4 +- .../DocumentsTest.php} | 4 +- tests/Feature/SettingsTest.php | 33 +++++++++++++ .../Controllers/SettingsControllerTest.php | 44 ------------------ 14 files changed, 57 insertions(+), 72 deletions(-) rename tests/{Api => Browser}/Auth/AuthControllerTest.php (98%) rename tests/{Unit => }/Commands/CalculateStatisticsTest.php (93%) rename tests/{Unit => }/Commands/ImportVCardsTest.php (99%) rename tests/{Unit => }/Commands/SendRemindersTest.php (98%) rename tests/{Unit => }/Commands/SendStayInTouchTest.php (98%) rename tests/{Unit/Controllers/ActivityTypeCategoriesControllerTest.php => Feature/ActivityTypeCategoriesTest.php} (96%) rename tests/{Unit/Controllers/ActivityTypesControllerTest.php => Feature/ActivityTypesTest.php} (94%) rename tests/{Unit/Controllers/Contact/CallsControllerTest.php => Feature/CallsTest.php} (95%) rename tests/{Unit/Controllers/DocumentsControllerTest.php => Feature/DocumentsTest.php} (93%) delete mode 100644 tests/Unit/Controllers/SettingsControllerTest.php diff --git a/.circleci/config.yml b/.circleci/config.yml index e166ff46e..abc10eb97 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,7 +74,8 @@ aliases: name: Run unit tests command: | php artisan route:cache - phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/junit/unit/results.xml --coverage-clover ./results/coverage.xml + TESTSUITE=$(echo -e "Api-and-Feature\nUnit" | circleci tests split) + phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/junit/unit/results${CIRCLE_NODE_INDEX}.xml --coverage-clover ./results/coverage${CIRCLE_NODE_INDEX}.xml --testsuite $TESTSUITE - &psalm run: name: Run psalm @@ -86,7 +87,7 @@ aliases: - &browser-tests run: name: Run browser tests - command: php artisan dusk --log-junit results/junit/dusk/results.xml + command: php artisan dusk --log-junit results/junit/dusk/results3.xml - &browser-cypress run: name: Run browser tests (cypress) @@ -97,13 +98,13 @@ aliases: run: name: Fix coverage command: | - vendor/bin/phpcov merge --clover=results/coverage2.xml results/coverage/ + vendor/bin/phpcov merge --clover=results/coverage3.xml results/coverage/ rm -rf results/coverage - &fix-coverage2 run: name: Fix coverage command: | - vendor/bin/phpcov merge --clover=results/coverage3.xml results/coverage/ + vendor/bin/phpcov merge --clover=results/coverage4.xml results/coverage/ rm -rf results/coverage - &selenium run: @@ -208,6 +209,7 @@ jobs: environment: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_ROOT_PASSWORD: '' + parallelism: 2 steps: - checkout: @@ -344,7 +346,7 @@ jobs: name: Run sonar scanner command: | export SONAR_RESULT=./results/results.xml - export SONAR_COVERAGE=./results/coverage.xml,./results/coverage2.xml,./results/coverage3.xml + export SONAR_COVERAGE=$(ls -m ./results/coverage*.xml | sed 's/ //g' | sed ':a;N;$!ba;s/\n//g') scripts/tests/runsonar.sh - save_cache: diff --git a/.circleci/config.yml.sig b/.circleci/config.yml.sig index a71f19930792955c830872b1434a64df4970bb54..01fc04d6a32eba22c309048ad87075d89594b452 100644 GIT binary patch delta 66 zcmV-I0KNZTUyvd_h%1Kx3JDOnl9L^yNN4Yl)c~N`!x!TBniT_0#6GE5de_i00iAaM YptE0PWB;^8C+75(9K*{SAPGQC7qXBX+5i9m delta 66 zcmV-I0KNZTUyvd_SeH})3JDOnl9L^yNN4Z5H!{FU%`kTqyPW_ diff --git a/phpunit.xml b/phpunit.xml index 3541da50a..1568bea1c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,20 +9,14 @@ processIsolation="false" stopOnFailure="false"> - - ./tests/Unit - - - + ./tests/Api - - - ./tests/Commands + ./tests/Feature - - ./tests/Feature + + ./tests/Unit diff --git a/tests/Api/Auth/AuthControllerTest.php b/tests/Browser/Auth/AuthControllerTest.php similarity index 98% rename from tests/Api/Auth/AuthControllerTest.php rename to tests/Browser/Auth/AuthControllerTest.php index 9943c3abf..f92bd668c 100644 --- a/tests/Api/Auth/AuthControllerTest.php +++ b/tests/Browser/Auth/AuthControllerTest.php @@ -1,6 +1,6 @@ assertSee('Login'); } + + public function test_it_updates_the_default_profile_view() + { + $user = $this->signin(); + + $response = $this->json('POST', '/settings/updateDefaultProfileView', [ + 'name' => 'life-events', + ]); + + $response->assertStatus(200); + + $this->assertDatabaseHas('users', [ + 'profile_active_tab' => 'life-events', + 'id' => $user->id, + ]); + + $response = $this->json('POST', '/settings/updateDefaultProfileView', [ + 'name' => 'notes', + ]); + + $response->assertStatus(200); + + $this->assertDatabaseHas('users', [ + 'profile_active_tab' => 'notes', + 'id' => $user->id, + ]); + + $response = $this->json('POST', '/settings/updateDefaultProfileView', [ + 'name' => 'nawak', + ]); + + $response->assertStatus(200); + } } diff --git a/tests/Unit/Controllers/SettingsControllerTest.php b/tests/Unit/Controllers/SettingsControllerTest.php deleted file mode 100644 index 2ac07bf3a..000000000 --- a/tests/Unit/Controllers/SettingsControllerTest.php +++ /dev/null @@ -1,44 +0,0 @@ -signin(); - - $response = $this->json('POST', '/settings/updateDefaultProfileView', [ - 'name' => 'life-events', - ]); - - $response->assertStatus(200); - - $this->assertDatabaseHas('users', [ - 'profile_active_tab' => 'life-events', - 'id' => $user->id, - ]); - - $response = $this->json('POST', '/settings/updateDefaultProfileView', [ - 'name' => 'notes', - ]); - - $response->assertStatus(200); - - $this->assertDatabaseHas('users', [ - 'profile_active_tab' => 'notes', - 'id' => $user->id, - ]); - - $response = $this->json('POST', '/settings/updateDefaultProfileView', [ - 'name' => 'nawak', - ]); - - $response->assertStatus(200); - } -}