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/.circleci/test.sh b/.circleci/test.sh index 47282e1..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" diff --git a/composer.json b/composer.json index 39e5e09..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