Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove AppVeyor, run E2E tests during CI #1365

Merged
merged 1 commit into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/autoreview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.dependencies }}
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 }}-${{ hashFiles('composer.*') }}-
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need to consider two files here, no others in tests/e2e or otherwise.

composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
Expand Down
52 changes: 43 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ jobs:

strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
operating-system: [ubuntu-latest]
php-version: ['7.4']
dependencies: ['']
coverage-driver: [pcov, xdebug]
include:
- { operating-system: 'windows-latest', php-version: '7.4', dependencies: '', coverage-driver: 'xdebug' }
- { operating-system: 'ubuntu-latest', php-version: '7.4', dependencies: '--prefer-lowest', coverage-driver: 'pcov' }
- { operating-system: 'ubuntu-latest', php-version: '8.0', dependencies: '--ignore-platform-req=php', coverage-driver: 'pcov' }

Expand All @@ -36,6 +37,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage-driver }}
ini-values: memory_limit=512M
tools: composer:v2

- name: Get composer cache directory
Expand All @@ -46,9 +48,9 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.dependencies }}
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 }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
Expand All @@ -57,16 +59,48 @@ jobs:
run: |
composer update --no-interaction --prefer-dist --no-progress ${{ matrix.dependencies }}

- name: Run tests using Makefile
if: runner.os != 'Windows'
- name: Run tests
shell: bash
run: |
make test-unit

- name: Run tests without Makefile
- name: Run integration tests
shell: bash
run: |
make test-unit PHPUNIT_GROUP=integration

- name: Cache E2E tests dependencies
if: runner.os == 'Windows'
uses: actions/cache@v2
with:
path: tests/e2e/*/vendor
key: e2e-vendor-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('tests/e2e/*/composer.json') }}-${{ matrix.dependencies }}
restore-keys: |
e2e-vendor-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('tests/e2e/*/composer.json') }}-
e2e-vendor-${{ runner.os }}-${{ matrix.php-version }}-
e2e-vendor-${{ runner.os }}-
composer-
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing anything with Composer is insanely slow in Windows, just compare these 4 seconds on Linux with these 34 seconds on Windows. The solution is to cache the dependencies, but not only archives, the whole vendor folders. Note that we don't cache composer.lock here: it takes far less time to verify that all is in order.

This might be a mistake, but let's see.


- name: Install Composer dependencies for E2E tests
shell: bash
run: |
vendor/bin/phpunit --group default
ls tests/e2e/*/composer.json | xargs dirname |
xargs -I{} composer --working-dir={} update --no-interaction --prefer-dist --no-progress ${{ matrix.dependencies }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprise! This works on Windows too!


- name: Run Infection
- name: Run a subset of E2E tests
if: runner.os == 'Windows'
shell: bash
run: |
make test-e2e-phpunit PHP='phpdbg -qrr' E2E_PHPUNIT_GROUP=e2e BENCHMARK_SOURCES=
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just wouldn't work with Xdebug. It seems installed, but then it is not.


- name: Install Linux dependencies for E2E tests
if: runner.os != 'Windows'
run: |
sudo apt-get install -y --no-install-recommends expect
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting Expect on Windows, is, well, complicated.

This could be worked around with WSL, but it'll make Windows VM "unpure": we can't expect everyone using Infection with Windows with WSL.


- name: Run the whole set of E2E tests
if: runner.os != 'Windows'
env:
TERM: xterm-256color
run: |
php bin/infection -j2 --test-framework-options="--group=default" --ignore-msi-with-no-mutations
make test-e2e E2E_PHPUNIT_GROUP=e2e INFECTION=bin/infection BENCHMARK_SOURCES=
File renamed without changes.
66 changes: 66 additions & 0 deletions .github/workflows/mt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Mutation Testing

on:
pull_request:
push:
branches:
- main
- master

env:
MIN_MSI: 68.00
MIN_COVERED_MSI: 80.00

jobs:
tests:
runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
php-version: ['7.4']
dependencies: ['']
coverage-driver: [pcov]

name: Mutation testing on ${{ matrix.operating-system }} 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:v2

- 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 update --no-interaction --prefer-dist --no-progress ${{ matrix.dependencies }}

- name: Collect coverage report
run: |
php vendor/phpunit/phpunit/phpunit --stop-on-failure --coverage-xml=build/logs/coverage-xml --log-junit=build/logs/junit.xml

- name: Run Infection
run: |
php bin/infection -j2 --skip-initial-tests --min-msi=$MIN_MSI --min-covered-msi=$MIN_COVERED_MSI --coverage=build/logs --log-verbosity=none --skip-initial-tests --no-interaction --no-progress
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL=bash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the default for Windows, therefore we have to be explicit here.

.DEFAULT_GOAL := help

# See https://tech.davis-hansson.com/p/make/
Expand All @@ -22,7 +23,7 @@ PHP_CS_FIXER_CACHE=build/cache/.php_cs.cache

PHPSTAN=./vendor/bin/phpstan

PHPUNIT=vendor/bin/phpunit
PHPUNIT=vendor/phpunit/phpunit/phpunit
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path works both under Linux and on Windows.


INFECTION=./build/infection.phar

Expand All @@ -39,6 +40,8 @@ BENCHMARK_SOURCES=tests/benchmark/MutationGenerator/sources \
tests/benchmark/Tracing/coverage \
tests/benchmark/Tracing/sources

E2E_PHPUNIT_GROUP=integration,e2e
PHPUNIT_GROUP=default
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To let us override these from outside.


#
# Commands (phony targets)
Expand Down Expand Up @@ -104,19 +107,19 @@ test-autoreview:
.PHONY: test-unit
test-unit: ## Runs the unit tests
test-unit: $(PHPUNIT)
$(PHPUNIT) --group default
$(PHPUNIT) --group $(PHPUNIT_GROUP)

.PHONY: test-unit-docker
test-unit-docker: ## Runs the unit tests on the different Docker platforms
test-unit-docker: test-unit-74-docker test-unit-80-docker

.PHONY: test-unit-74-docker
test-unit-74-docker: $(DOCKER_RUN_74_IMAGE) $(PHPUNIT)
$(DOCKER_RUN_74) $(PHPUNIT) --group default
$(DOCKER_RUN_74) $(PHPUNIT) --group $(PHPUNIT_GROUP)

.PHONY: test-unit-80-docker
test-unit-80-docker: $(DOCKER_RUN_80_IMAGE) $(PHPUNIT)
$(DOCKER_RUN_80) $(PHPUNIT) --group default
$(DOCKER_RUN_80) $(PHPUNIT) --group $(PHPUNIT_GROUP)

.PHONY: test-e2e
test-e2e: ## Runs the end-to-end tests
Expand All @@ -126,7 +129,7 @@ test-e2e: test-e2e-phpunit
.PHONY: test-e2e-phpunit
test-e2e-phpunit: ## Runs PHPUnit-enabled subset of end-to-end tests
test-e2e-phpunit: $(PHPUNIT) $(BENCHMARK_SOURCES)
$(PHPUNIT) --group integration,e2e
$(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)

.PHONY: test-e2e-docker
test-e2e-docker: ## Runs the end-to-end tests on the different Docker platforms
Expand All @@ -137,25 +140,25 @@ test-e2e-phpdbg-docker: test-e2e-phpdbg-74-docker test-e2e-phpdbg-80-docker

.PHONY: test-e2e-phpdbg-74-docker
test-e2e-phpdbg-74-docker: $(DOCKER_RUN_74_IMAGE) $(INFECTION)
$(DOCKER_RUN_74) $(PHPUNIT) --group integration,e2e
$(DOCKER_RUN_74) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_74) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)

.PHONY: test-e2e-phpdbg-80-docker
test-e2e-phpdbg-80-docker: $(DOCKER_RUN_80_IMAGE) $(INFECTION)
$(DOCKER_RUN_80) $(PHPUNIT) --group integration,e2e
$(DOCKER_RUN_80) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_80) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)

.PHONY: test-e2e-xdebug-docker
test-e2e-xdebug-docker: test-e2e-xdebug-74-docker test-e2e-xdebug-80-docker

.PHONY: test-e2e-xdebug-74-docker
test-e2e-xdebug-74-docker: $(DOCKER_RUN_74_IMAGE) $(INFECTION)
$(DOCKER_RUN_74) $(PHPUNIT) --group integration,e2e
$(DOCKER_RUN_74) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_74) ./tests/e2e_tests $(INFECTION)

.PHONY: test-e2e-xdebug-80-docker
test-e2e-xdebug-80-docker: $(DOCKER_RUN_80_IMAGE) $(INFECTION)
$(DOCKER_RUN_80) $(PHPUNIT) --group integration,e2e
$(DOCKER_RUN_80) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_80) ./tests/e2e_tests $(INFECTION)

.PHONY: test-infection
Expand Down
55 changes: 1 addition & 54 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,2 @@
build: false
platform:
- x64
clone_folder: c:\projects\workspace

environment:
matrix:
- dependencies: highest
php_ver_target: 7.4.11
xdebug_ver: '2.9.2-7.4-vc15'
- dependencies: current
php_ver_target: 7.4.11
xdebug_ver: '2.9.2-7.4-vc15'

cache: # cache is cleared when linked file is modified
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
- composer.phar
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
- C:\tools\php -> appveyor.yml

init:
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH%
- SET ANSICON=121x90 (121x90)
- SET COMPOSER_NO_INTERACTION=1
- SET COMPOSER_FLAGS=--no-interaction --no-progress --no-suggest --prefer-dist

install:
# Enable Windows update service
- ps: Set-Service wuauserv -StartupType Manual
# Install PHP
- choco search php --exact --all-versions -r
- ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version $env:php_ver_target
- cd c:\tools\php
- copy php.ini-production php.ini /Y
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo memory_limit=512M >> php.ini
# Install composer and update per matrix
- cd c:\projects\workspace
- php -r "readfile('http://getcomposer.org/installer');" | php
- IF %dependencies%==current appveyor-retry php composer.phar install %COMPOSER_FLAGS%
- IF %dependencies%==highest appveyor-retry php composer.phar update %COMPOSER_FLAGS%
# Install Xdebug for code coverage
- ps: .ci\appveyor_install_xdebug.ps1

test_script:
- cd c:\projects\workspace
- vendor\bin\phpunit --prepend=tests/xdebug-filter.php --coverage-clover=clover.xml --coverage-xml=coverage/coverage-xml --log-junit=coverage/junit.xml
- php bin\infection --threads=%NUMBER_OF_PROCESSORS% --log-verbosity=none --coverage=coverage --no-progress --only-covered --ignore-msi-with-no-mutations

matrix:
fast_finish: true
clone_depth: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to keep this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor will fail the build without it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so will we remove once 0.18 is not maintained anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the idea. Remove it once we don't need it anywhere.

2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groups>
<exclude>
<group>large</group>
<group>e2e</group>
</exclude>
</groups>

Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/SymfonyFlex/run_tests.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

if [ "$DRIVER" = "pcov" ]
then
# `pcov` requires at least PHPUnit 8.0 (used by symfony/phpunit-bridge)
export SYMFONY_PHPUNIT_VERSION="8.0"
fi

set -e

run () {
local INFECTION=${1}
local PHPARGS=${2}

if [ "$DRIVER" = "phpdbg" ]
then
phpdbg $PHPARGS -qrr $INFECTION
else
php $PHPARGS $INFECTION
fi

diff -u -w expected-output.txt infection.log
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SymfonyFlex needs a special environment variable, and it uses old version of PHPUnit which is not compatible with the one we use, so we can't really run this test from E2ETest. Adding this file prevents this test from running from E2ETest, and also solves env variable issue.

6 changes: 0 additions & 6 deletions tests/e2e/standard_script.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ readonly INFECTION=../../../${1}

set -e pipefail

if [ "$DRIVER" = "pcov" ]
then
# `pcov` requires at least PHPUnit 8.0 (used by symfony/phpunit-bridge)
export SYMFONY_PHPUNIT_VERSION="8.0"
fi

if [ "$DRIVER" = "phpdbg" ]
then
phpdbg -qrr $INFECTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public function test_it_builds_and_dump_the_xml_configuration(): void

public function test_it_preserves_white_spaces_and_formatting(): void
{
if (PHP_EOL === "\r\n") {
maks-rafalko marked this conversation as resolved.
Show resolved Hide resolved
$this->markTestSkipped('Test fixture uses Unix line endings');
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't run this test on Windows before, apparently.

$builder = $this->createConfigBuilder(
self::FIXTURES . '/format-whitespace/original-phpunit.xml',
true
Expand Down