From 958fa550c96e9d87bbfe398dcab65de9562371a0 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Tue, 19 Nov 2024 10:21:05 +0100 Subject: [PATCH] refactor: cleanup unit test job Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com> --- gitlab-ci-1.2.yml | 2 +- includes/tests/unit.yml | 72 +++++++++++------------------------------ 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/gitlab-ci-1.2.yml b/gitlab-ci-1.2.yml index 3ef68de..234a43a 100644 --- a/gitlab-ci-1.2.yml +++ b/gitlab-ci-1.2.yml @@ -1,5 +1,5 @@ variables: - WPDESK_CI_VERSION: "2024.11.04" + WPDESK_CI_VERSION: "2024.11.19" MYSQL_ROOT_PASSWORD: "mysql" MYSQL_DATABASE: "wptest" MYSQL_USER: "mysql" diff --git a/includes/tests/unit.yml b/includes/tests/unit.yml index 6126234..765887e 100644 --- a/includes/tests/unit.yml +++ b/includes/tests/unit.yml @@ -1,71 +1,37 @@ -.template: &job-test-template +test:unit: image: gitlab.wpdesk.dev:5050/wpdesk/docker-tests/php-box:8.3.2 + variables: + PHPUNIT_OPTIONS: "--no-coverage" tags: - unit stage: tests - except: - variables: - - $IS_NPM_LIBRARY + rules: + - if: $IS_NPM_LIBRARY + when: never + - if: $CI_COMMIT_BRANCH == "devel" + exists: + - phpunit-unit.xml + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG + exists: + - phpunit-unit.xml + variables: + PHPUNIT_OPTIONS: "--coverage-text --coverage-html tmp_artifacts/unit/coverage --colors=never" + - exists: + - phpunit-unit.xml + when: manual coverage: '/^\s*Lines:\s*\d+.\d+\%/' artifacts: paths: - tmp_artifacts/unit reports: junit: tmp_artifacts/unit/report.xml + expire_in: 3 mos interruptible: true - -.template: &job-test-unit-template - <<: *job-test-template before_script: - echo ${WPDESK_CI_VERSION} - php --version - echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini script: - - vendor/bin/phpunit -d memory_limit=-1 --configuration phpunit-unit.xml --coverage-text --colors=never --log-junit tmp_artifacts/unit/report.xml --coverage-html tmp_artifacts/unit/coverage + - vendor/bin/phpunit -d memory_limit=-1 --configuration phpunit-unit.xml --log-junit tmp_artifacts/unit/report.xml $PHPUNIT_OPTIONS after_script: - 'if [[ ${REPORTPORTAL_AUTHORIZATION} && ${REPORTPORTAL_PROJECT} ]]; then curl -X POST "http://195.201.225.204:8080/api/v1/${REPORTPORTAL_PROJECT}/launch/import" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "${REPORTPORTAL_AUTHORIZATION}" -F "file=file=@tmp_artifacts/unit/report.xml;type=text/xml;type=text/xml;filename=${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}-unit.xml"; fi' - -.template: &job-test-unit-template-fast - <<: *job-test-template - script: - - echo ${WPDESK_CI_VERSION} - - ls -l - - php --version - - vendor/bin/phpunit -d memory_limit=-1 --configuration phpunit-unit.xml --no-coverage --log-junit tmp_artifacts/unit/report.xml - -unit test lastest: - <<: *job-test-unit-template-fast - only: - refs: - - devel - - tags - except: - variables: - - $IS_NPM_LIBRARY - -unit test lastest coverage: - <<: *job-test-unit-template - only: - refs: - - master - - main - -unit test lastest manual: - <<: *job-test-unit-template-fast - when: manual - allow_failure: true - except: - refs: - - devel - - tags - variables: - - $DISABLE_COVERAGE - -unit test lastest coverage manual: - <<: *job-test-unit-template - when: manual - allow_failure: true - except: - refs: - - master - - main -- GitLab