Skip to content
Snippets Groups Projects

Issue #3390941: Investigate adding a Mutation testing stage

Open Conrad Lara requested to merge issue/s3fs-3390941:3390941-investigate-adding-a into 4.0.x
3 files
+ 93
2
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 46
2
@@ -32,7 +32,7 @@ variables:
@@ -32,7 +32,7 @@ variables:
value: "$CORE_PHP_MAX"
value: "$CORE_PHP_MAX"
# Collect code coverage data.
# Collect code coverage data.
_PHPUNIT_EXTRA:
_PHPUNIT_EXTRA:
value: --coverage-cobertura $CI_PROJECT_DIR/coverage.xml --coverage-filter $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/ --coverage-text --colors=never
value: --coverage-xml=$CI_PROJECT_DIR/build/coverage/coverage-xml --coverage-cobertura $CI_PROJECT_DIR/coverage.xml --coverage-filter $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/ --coverage-text --colors=never
# Generate a new phpstan baseline.
# Generate a new phpstan baseline.
GENERATE_PHPSTAN_BASELINE:
GENERATE_PHPSTAN_BASELINE:
value: "0"
value: "0"
@@ -112,7 +112,7 @@ phpstan-new-baseline:
@@ -112,7 +112,7 @@ phpstan-new-baseline:
# * Enable PCOV Coverage Reporting.
# * Enable PCOV Coverage Reporting.
# * Collect code coverage data.
# * Collect code coverage data.
################
################
phpunit:
.local-phpunit-base:
extends: .phpunit-base
extends: .phpunit-base
services:
services:
# Include the normal containers.
# Include the normal containers.
@@ -132,6 +132,8 @@ phpunit:
@@ -132,6 +132,8 @@ phpunit:
# write the aliases to the hosts file.
# write the aliases to the hosts file.
- echo "$localstack_ipaddr s3.localhost.localstack.cloud s3fs-test-bucket.s3.localhost.localstack.cloud" >> /etc/hosts
- echo "$localstack_ipaddr s3.localhost.localstack.cloud s3fs-test-bucket.s3.localhost.localstack.cloud" >> /etc/hosts
 
phpunit:
 
extends: .local-phpunit-base
after_script:
after_script:
# Ensure paths for coverage are git-relative.
# Ensure paths for coverage are git-relative.
- sed -i "s#<source>$CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME#<source>$CI_PROJECT_DIR#" coverage.xml
- sed -i "s#<source>$CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME#<source>$CI_PROJECT_DIR#" coverage.xml
@@ -147,3 +149,45 @@ phpunit:
@@ -147,3 +149,45 @@ phpunit:
- apache.access.log.txt
- apache.access.log.txt
- $BROWSERTEST_OUTPUT_DIRECTORY
- $BROWSERTEST_OUTPUT_DIRECTORY
- coverage.xml
- coverage.xml
 
- build
 
 
################
 
# Mutation tests.
 
################
 
mutation:
 
extends: .local-phpunit-base
 
needs:
 
- job: composer
 
optional: false
 
- job: phpunit
 
optional: false
 
before_script:
 
# We don't need PCOV as we use existing coverage report.
 
# GitLab doesn't support aliases when setting up the container.
 
# Get the IP for the localstack container.
 
- localstack_ipaddr=$(getent hosts localstack-localstack | cut -d " " -f 1)
 
# write the aliases to the hosts file.
 
- echo "$localstack_ipaddr s3.localhost.localstack.cloud s3fs-test-bucket.s3.localhost.localstack.cloud" >> /etc/hosts
 
script:
 
# Infection requres the junit file in the coverage folder.
 
- ln -s $CI_PROJECT_DIR/junit.xml $CI_PROJECT_DIR/build/coverage/junit.xml
 
# Setup the container for testing.
 
- !reference [.setup-webserver]
 
- !reference [.simpletest-db]
 
- !reference [.show-environment-variables]
 
# Provide some context on the test run.
 
- vendor/bin/drush status
 
# If $CI_MERGE_REQUEST_DIFF_BASE_SHA is empty run over all files
 
# otherwise run over only altered lines.
 
- >
 
if [ -z $CI_MERGE_REQUEST_DIFF_BASE_SHA ]; then
 
cd $CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME; sudo -u www-data -E $CI_PROJECT_DIR/vendor/bin/infection --configuration=$CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME/infection.json5.dist --skip-initial-tests --only-covering-test-cases --threads=6 --coverage=$CI_PROJECT_DIR/build/coverage --filter=$CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME --logger-gitlab="$CI_PROJECT_DIR/infection-gitlab.json" --logger-html="$CI_PROJECT_DIR/mutation-report.html"
 
else
 
cd $CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME; sudo -u www-data -E $CI_PROJECT_DIR/vendor/bin/infection --git-diff-base=$CI_MERGE_REQUEST_DIFF_BASE_SHA --git-diff-lines --configuration=$CI_PROJECT_DIR/web/modules/custom/$CI_PROJECT_NAME/infection.json5.dist --skip-initial-tests --only-covering-test-cases --threads=6 --coverage=$CI_PROJECT_DIR/build/coverage --logger-gitlab="$CI_PROJECT_DIR/infection-gitlab.json" --logger-html="$CI_PROJECT_DIR/mutation-report.html"
 
fi
 
artifacts:
 
reports:
 
codequality: infection-gitlab.json
 
paths:
 
- infection-gitlab.json
 
- mutation-report.html
Loading