From 2e4c724a04a80d269a8694a0d3d6a6ef6be3f2cc Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Mon, 24 Jan 2022 16:59:18 +1100 Subject: [PATCH 1/4] Adds phpunit coverage settings --- .circleci/test.sh | 2 +- composer.json | 2 +- phpunit.xml.dist | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.circleci/test.sh b/.circleci/test.sh index 47282e1..f2ffde5 100755 --- a/.circleci/test.sh +++ b/.circleci/test.sh @@ -12,4 +12,4 @@ mkdir -p /tmp/artifacts/behat ahoy test-behat || ahoy test-behat -- --rerun echo "==> Run Unit tests" -ahoy cli "/app/vendor/bin/phpunit" +ahoy cli "/app/vendor/bin/phpunit ./dpc-sdp" diff --git a/composer.json b/composer.json index 679ff6f..d97ddd4 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "GPL-2.0-or-later", "type": "drupal-module", "require": { - "dpc-sdp/tide_core": "3.0.0" + "dpc-sdp/tide_core": "^3.1.0" }, "suggest": { "dpc-sdp/tide_media:^3.0.0": "Media and related configuration for Tide Drupal 8 distribution" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3468d79..a7bf38b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,11 +7,7 @@ - ./includes - ./lib - ./modules - ../modules - ../sites + ./dpc-sdp ./modules/*/src/Tests From b5e57abfdc1cabd1bf231a5b2a0ac9c6bb859f01 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Fri, 28 Jan 2022 15:42:03 +1100 Subject: [PATCH 2/4] Update phpunit settings --- .circleci/config.yml | 26 ++++++++++++++++++++++++++ .circleci/phpunit_coverage.sh | 7 +++++++ .circleci/phpunit_results.sh | 6 ++++++ .circleci/phpunit_tests.sh | 9 +++++++++ 4 files changed, 48 insertions(+) create mode 100644 .circleci/phpunit_coverage.sh create mode 100644 .circleci/phpunit_results.sh create mode 100644 .circleci/phpunit_tests.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index f35e1f0..ae14a68 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: Run on fail tests + 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 100644 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 100644 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 100644 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" From aefc0a705ec75976acdc8da4e6b89a77047fa307 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Fri, 28 Jan 2022 15:53:08 +1100 Subject: [PATCH 3/4] fixes file permission issue --- .circleci/config.yml | 2 +- .circleci/phpunit_coverage.sh | 0 .circleci/phpunit_results.sh | 0 .circleci/phpunit_tests.sh | 0 4 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 .circleci/phpunit_coverage.sh mode change 100644 => 100755 .circleci/phpunit_results.sh mode change 100644 => 100755 .circleci/phpunit_tests.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index ae14a68..2c919b7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,7 +55,7 @@ jobs: .circleci/phpunit_tests.sh .circleci/phpunit_coverage.sh - run: - name: Run on fail tests + name: Copy test results command: | .circleci/phpunit_results.sh when: always diff --git a/.circleci/phpunit_coverage.sh b/.circleci/phpunit_coverage.sh old mode 100644 new mode 100755 diff --git a/.circleci/phpunit_results.sh b/.circleci/phpunit_results.sh old mode 100644 new mode 100755 diff --git a/.circleci/phpunit_tests.sh b/.circleci/phpunit_tests.sh old mode 100644 new mode 100755 From a93e9347eaedfebe31970929c16d4d8b17daee3b Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Feb 2022 09:30:10 +1100 Subject: [PATCH 4/4] Removed unit test from build script as it has a separate script now. --- .circleci/test.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/test.sh b/.circleci/test.sh index f2ffde5..41fd68e 100755 --- a/.circleci/test.sh +++ b/.circleci/test.sh @@ -10,6 +10,3 @@ ahoy lint echo "==> Run Behat tests" mkdir -p /tmp/artifacts/behat ahoy test-behat || ahoy test-behat -- --rerun - -echo "==> Run Unit tests" -ahoy cli "/app/vendor/bin/phpunit ./dpc-sdp"