diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9a4f264 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +*.php text eol=lf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary + +# Directories and files we do not want to distribute +/.* export-ignore +/build/ export-ignore +/docs/ export-ignore +/infection.json.dist export-ignore +/tests/ export-ignore +/phpstan-baseline.neon export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml export-ignore +/psalm-baseline.xml export-ignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..f1811f9 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,65 @@ +# yamllint disable rule:line-length +# yamllint disable rule:braces + +name: Tests + +on: + pull_request: + push: + branches: + - main + - master + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-version: ['7.3'] + coverage-driver: [pcov] + + name: CI with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: ${{ matrix.coverage-driver }} + tools: composer:v1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}- + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run tests and generate coverage + run: make test-unit + + - name: Run E2E tests + env: + TERM: xterm-256color + run: make test-e2e + + - name: Upload coverage results to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: vendor/bin/php-coveralls diff --git a/.github/workflows/cs.yaml b/.github/workflows/cs.yaml new file mode 100644 index 0000000..8801323 --- /dev/null +++ b/.github/workflows/cs.yaml @@ -0,0 +1,55 @@ +# yamllint disable rule:line-length +# yamllint disable rule:braces + +name: Coding Standards + +on: + pull_request: + push: + branches: + - main + - master + +jobs: + coding-standards: + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-version: ['7.3'] + check: ['cs', 'static-analyze'] + + name: Coding Standards on PHP ${{ matrix.php-version }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}- + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + + - name: Install dependencies + run: | + composer install --no-interaction --no-progress --prefer-dist + + - name: Run ${{ matrix.check }} + run: make ${{ matrix.check }} diff --git a/.github/workflows/mt.yaml b/.github/workflows/mt.yaml new file mode 100644 index 0000000..d8a0588 --- /dev/null +++ b/.github/workflows/mt.yaml @@ -0,0 +1,55 @@ +# yamllint disable rule:line-length +# yamllint disable rule:braces + +name: Mutation Testing + +on: + pull_request: + push: + branches: + - main + - master + +jobs: + mutation-testing: + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-version: ['7.3'] + coverage-driver: [pcov] + + name: Mutation testing with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: ${{ matrix.coverage-driver }} + tools: composer:v1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}- + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run Infection + run: make infection diff --git a/.gitignore b/.gitignore index 9a9b715..7ab5d82 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ /.composer/ /.idea /.php_cs.cache -/vendor/ -/infection.log /build/ +/infection.log +/vendor/ diff --git a/.prettyci.composer.json b/.prettyci.composer.json deleted file mode 100644 index 6d9218d..0000000 --- a/.prettyci.composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16" - } -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c984ea0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: php -php: - - 7.3 - - 7.4 - - nightly - -stages: - - analyze - - test - -jobs: - fast_finish: true - allow_failures: - - php: nightly - include: - - stage: analyze - php: 7.3 - install: - - phpenv config-rm xdebug.ini - - pecl install ast - - pecl install pcov - - composer install --prefer-dist - script: - - make ci-analyze --keep-going - - composer validate - -cache: - directories: - - $HOME/.composer - - build/cache - -install: - - phpenv config-rm xdebug.ini || true - - pecl install pcov - - composer remove --no-update --dev - phan/phan phpstan/phpstan vimeo/psalm - infection/infection friendsofphp/php-cs-fixer - - if [[ $TRAVIS_PHP_VERSION = nightly ]]; then export COMPOSER_FLAGS="--ignore-platform-reqs"; fi - - travis_retry composer install --prefer-dist $COMPOSER_FLAGS - -script: - - make ci-test --keep-going - -after_success: - - travis_retry php vendor/bin/php-coveralls diff --git a/Makefile b/Makefile index dda708a..7f7e4fb 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,13 @@ # Use any most recent PHP version PHP=$(shell which php) -PHPDBG=php # Default parallelism JOBS=$(shell nproc) -# Default silencer if installed -SILENT=$(shell which chronic) - # PHP CS Fixer PHP_CS_FIXER=vendor/bin/php-cs-fixer -PHP_CS_FIXER_ARGS=--cache-file=build/cache/.php_cs.cache --verbose +PHP_CS_FIXER_ARGS=--diff --diff-format=udiff --verbose export PHP_CS_FIXER_IGNORE_ENV=1 # PHPUnit @@ -33,39 +29,32 @@ COMPOSER=$(PHP) $(shell which composer) # Infection INFECTION=vendor/bin/infection -MIN_MSI=76 -MIN_COVERED_MSI=98 -INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=default --show-mutations +MIN_MSI=52.212389380531 +MIN_COVERED_MSI=95 +INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=none --no-interaction --no-progress all: test -############################################################## -# Continuous Integration # -############################################################## - -ci-test: SILENT= -ci-test: prerequisites - $(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_COVERAGE_CLOVER) - tests/e2e_tests +cs: + $(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS) --dry-run + LC_ALL=C sort -c -u .gitignore -ci-analyze: SILENT= -ci-analyze: prerequisites ci-cs ci-infection ci-phpstan ci-psalm +phpstan: + $(PHPSTAN) $(PHPSTAN_ARGS) --no-progress -ci-phpunit: ci-cs - $(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_ARGS) - cp build/logs/junit.xml build/logs/phpunit.junit.xml +psalm: + $(PSALM) $(PSALM_ARGS) --no-cache --shepherd -ci-infection: - $(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS) +static-analyze: phpstan psalm -ci-phpstan: ci-cs - $(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS) --no-progress +test-unit: + $(PHPUNIT) $(PHPUNIT_ARGS) -ci-psalm: ci-cs - $(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS) --no-cache --shepherd +test-e2e: + tests/e2e_tests -ci-cs: prerequisites - $(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --dry-run --stop-on-violation fix +infection: + $(INFECTION) $(INFECTION_ARGS) ############################################################## # Development Workflow # @@ -75,21 +64,21 @@ test: phpunit analyze composer-validate .PHONY: composer-validate composer-validate: test-prerequisites - $(SILENT) $(COMPOSER) validate --strict + $(COMPOSER) validate --strict test-prerequisites: prerequisites composer.lock -phpunit: cs - $(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_ARGS) --verbose +phpunit: cs-fix + $(PHPUNIT) $(PHPUNIT_ARGS) --verbose cp build/logs/junit.xml build/logs/phpunit.junit.xml - $(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS) + $(PHP) $(INFECTION) $(INFECTION_ARGS) -analyze: cs - $(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS) - $(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS) +analyze: cs-fix + $(PHPSTAN) $(PHPSTAN_ARGS) + $(PSALM) $(PSALM_ARGS) -cs: test-prerequisites - $(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --diff fix +cs-fix: test-prerequisites + $(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS) LC_ALL=C sort -u .gitignore -o .gitignore ############################################################## @@ -98,21 +87,17 @@ cs: test-prerequisites # We need both vendor/autoload.php and composer.lock being up to date .PHONY: prerequisites -prerequisites: report-php-version build/cache vendor/autoload.php composer.lock infection.json.dist .phpstan.neon +prerequisites: build/cache vendor/autoload.php composer.lock infection.json.dist .phpstan.neon # Do install if there's no 'vendor' vendor/autoload.php: - $(SILENT) $(COMPOSER) install --prefer-dist - test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(SILENT) $(COMPOSER) dump-autoload || true + $(COMPOSER) install --prefer-dist + test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(COMPOSER) dump-autoload || true # If composer.lock is older than `composer.json`, do update, # and touch composer.lock because composer not always does that composer.lock: composer.json - $(SILENT) $(COMPOSER) update && touch composer.lock + $(COMPOSER) update && touch composer.lock build/cache: mkdir -p build/cache - -.PHONY: report-php-version -report-php-version: - # Using $(PHP) diff --git a/README.md b/README.md index c0ebfe8..aaf8b5f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/infection/codeception-adapter.svg?branch=master)](https://travis-ci.org/infection/codeception-adapter) +[![Continuous Integration](https://github.com/infection/codeception-adapter/workflows/Continuous%20Integration/badge.svg)](https://github.com/infection/codeception-adapter) [![Coverage Status](https://coveralls.io/repos/github/infection/codeception-adapter/badge.svg?branch=master)](https://coveralls.io/github/infection/codeception-adapter?branch=master) # Codeception Test Framework Adapter for Infection diff --git a/tests/e2e/Codeception_Basic/composer.json b/tests/e2e/Codeception_Basic/composer.json index e7bf6e0..bf83f4e 100644 --- a/tests/e2e/Codeception_Basic/composer.json +++ b/tests/e2e/Codeception_Basic/composer.json @@ -13,7 +13,7 @@ } }, "require": { - "infection/infection": "dev-master", + "infection/infection": "0.18.2", "infection/codeception-adapter": "dev-master" }, "repositories": [ diff --git a/tests/e2e/Codeception_Basic/expected-output.txt b/tests/e2e/Codeception_Basic/expected-output.txt index 9963a4b..97392cd 100644 --- a/tests/e2e/Codeception_Basic/expected-output.txt +++ b/tests/e2e/Codeception_Basic/expected-output.txt @@ -4,4 +4,5 @@ Killed: 3 Errored: 0 Escaped: 1 Timed Out: 0 +Skipped: 0 Not Covered: 0 diff --git a/tests/e2e/Codeception_Basic/run_tests.bash b/tests/e2e/Codeception_Basic/run_tests.bash index 4e33bb4..9573ba6 100755 --- a/tests/e2e/Codeception_Basic/run_tests.bash +++ b/tests/e2e/Codeception_Basic/run_tests.bash @@ -24,13 +24,13 @@ cd "$(dirname "$0")" rm -rf codeception-package mkdir codeception-package -git_branch="${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}" +git_branch="$(git rev-parse --abbrev-ref HEAD)" if [ "$git_branch" == "master" ]; then exit 0; fi; -sed -i "s/\"infection\/codeception-adapter\": \"dev-master\"/\"infection\/codeception-adapter\": \"dev-${git_branch}\"/" composer.json +sed -i "s/\"infection\/codeception-adapter\": \"dev-master\"/\"infection\/codeception-adapter\": \"dev-master#${git_branch}\"/" composer.json cp -r ../../../src codeception-package/src cp ../../../composer.json codeception-package diff --git a/tests/e2e/Codeception_With_Suite_Overridings/composer.json b/tests/e2e/Codeception_With_Suite_Overridings/composer.json index 278a61c..848968c 100644 --- a/tests/e2e/Codeception_With_Suite_Overridings/composer.json +++ b/tests/e2e/Codeception_With_Suite_Overridings/composer.json @@ -1,7 +1,7 @@ { "require-dev": { "codeception/codeception": "^3.1", - "infection/infection": "^0.15.0" + "infection/infection": "0.18.2" }, "autoload": { "psr-4": { diff --git a/tests/e2e/Codeception_With_Suite_Overridings/expected-output.txt b/tests/e2e/Codeception_With_Suite_Overridings/expected-output.txt index 021f3f3..76a558a 100644 --- a/tests/e2e/Codeception_With_Suite_Overridings/expected-output.txt +++ b/tests/e2e/Codeception_With_Suite_Overridings/expected-output.txt @@ -1,6 +1,8 @@ Total: 2 + Killed: 2 Errored: 0 Escaped: 0 Timed Out: 0 -Not Covered: 0 \ No newline at end of file +Skipped: 0 +Not Covered: 0