From 274a9be651943d1c2d7128394e398829776b93b3 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Tue, 7 Dec 2021 15:42:38 +1100 Subject: [PATCH] adding test coverage test coverage Update test coverage settings update Update circleci configs Update phpunit test settings Update test test update update update update update update --- .circleci/config.yml | 26 +++++++++++++++++++ .circleci/phpunit_coverage.sh | 7 +++++ .circleci/phpunit_results.sh | 6 +++++ .circleci/phpunit_tests.sh | 9 +++++++ dev-tools.sh | 1 + .../src/Kernel/TideSitePreviewHelperTest.php | 1 + 6 files changed, 50 insertions(+) create mode 100755 .circleci/phpunit_coverage.sh create mode 100755 .circleci/phpunit_results.sh create mode 100755 .circleci/phpunit_tests.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index f35e1f0..2c919b7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,9 +39,35 @@ jobs: INSTALL_SUGGEST: 1 BEHAT_PROFILE: "--profile=suggest" + phpunit_tests: + <<: *job-build + steps: + - attach_workspace: + at: /workspace + - checkout + - run: if [ -f "./dev-tools.sh" ] && [ ! "$DEV_TOOLS" ]; then ./dev-tools.sh; fi + - setup_remote_docker: + docker_layer_caching: true + - run: .circleci/build.sh + - run: + name: Run phpunit tests and generate coverage + command: | + .circleci/phpunit_tests.sh + .circleci/phpunit_coverage.sh + - run: + name: Copy test results + command: | + .circleci/phpunit_results.sh + when: always + - store_artifacts: + path: /tmp/phpunit + - store_test_results: + path: /tmp/phpunit + workflows: version: 2 main: jobs: - build - build_suggest + - phpunit_tests diff --git a/.circleci/phpunit_coverage.sh b/.circleci/phpunit_coverage.sh new file mode 100755 index 0000000..905e7bc --- /dev/null +++ b/.circleci/phpunit_coverage.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +## +# Generate coverage report +# +set -e +echo "==> Generate coverage report" +ahoy cli "phpdbg -qrr vendor/bin/phpunit ./dpc-sdp --coverage-html /app/phpunit/coverage-report" diff --git a/.circleci/phpunit_results.sh b/.circleci/phpunit_results.sh new file mode 100755 index 0000000..98cc64f --- /dev/null +++ b/.circleci/phpunit_results.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +## +# Moves phpunit results from inside container to outside. +# +set -e +docker cp $(docker-compose ps -q cli):/app/phpunit/ /tmp/ diff --git a/.circleci/phpunit_tests.sh b/.circleci/phpunit_tests.sh new file mode 100755 index 0000000..e5771b3 --- /dev/null +++ b/.circleci/phpunit_tests.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +## +# Run phpunit tests in CI. +# +set -e + +ahoy cli "mkdir -p /app/phpunit" +echo "==> Run phpunit tests" +ahoy cli "vendor/bin/phpunit ./dpc-sdp --log-junit /app/phpunit/junit.xml" diff --git a/dev-tools.sh b/dev-tools.sh index d7573df..281696b 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -34,5 +34,6 @@ # # Uncomment and set the Dev-Tools's commit value and commit this change. # export GH_COMMIT=COMMIT_SHA +export GH_COMMIT=aefc0a705ec75976acdc8da4e6b89a77047fa307 bash <(curl -L https://raw.githubusercontent.com/dpc-sdp/dev-tools/master/install?"$(date +%s)") "$@" diff --git a/modules/tide_site_preview/tests/src/Kernel/TideSitePreviewHelperTest.php b/modules/tide_site_preview/tests/src/Kernel/TideSitePreviewHelperTest.php index 41e5db3..08e7b9c 100644 --- a/modules/tide_site_preview/tests/src/Kernel/TideSitePreviewHelperTest.php +++ b/modules/tide_site_preview/tests/src/Kernel/TideSitePreviewHelperTest.php @@ -10,6 +10,7 @@ /** * Tests the TideSitePreviewHelper. * + * @coversDefaultClass \Drupal\tide_site_preview\TideSitePreviewHelper * @group tide_site_preview */ class TideSitePreviewHelperTest extends EntityKernelTestBase {