Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# yamllint disable rule:line-length

name: Continuous Integration

on:
- pull_request
- push

jobs:
tests:
strategy:
matrix:
operating-system:
- ubuntu-latest
php-version:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'

include:
- operating-system: 'ubuntu-latest'
php-version: '8.0'
composer-flags: '--ignore-platform-req=php'
PHP_CS_FIXER_IGNORE_ENV: 1

- operating-system: 'ubuntu-latest'
php-version: '5.6'
PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: 1
SYMFONY_DEPRECATIONS_HELPER: disabled

- operating-system: 'windows-latest'
php-version: '7.3'
FAST_LINT_TEST_CASES: 1

- operating-system: 'windows-latest'
php-version: '5.6'
SKIP_LINT_TEST_CASES: 1

- operating-system: 'macos-latest'
php-version: '7.4'
PHP_CS_FIXER_FUTURE_MODE: 1

name: PHP ${{ matrix.php-version }} CI on ${{ matrix.operating-system }} ${{ matrix.composer-flags }}

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

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-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.composer-flags }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-

- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
retry_wait_seconds: 30
command: |
composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}

- name: Run tests
continue-on-error: ${{ matrix.php-version == '8.0' }}
Copy link
Contributor Author

@sanmai sanmai Nov 23, 2020

Choose a reason for hiding this comment

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

Several tests are broken on PHP 8 since not very long time ago due to a bug in TimeEfficientLongestCommonSubsequenceImplementation. It looks like this:

Undefined array key 140725147700175

/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/vendor/php-cs-fixer/diff/src/v1_4/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php:57
/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/vendor/php-cs-fixer/diff/src/v1_4/Differ.php:230
/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/vendor/php-cs-fixer/diff/src/v1_4/Differ.php:55
/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/src/Differ/SebastianBergmannShortDiffer.php:37
/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/tests/Differ/SebastianBergmannShortDifferTest.php:36
/home/runner/work/PHP-CS-Fixer/PHP-CS-Fixer/vendor/phpunitgoodpractices/traits/src/ExpectationViaCodeOverAnnotationTrait7.php:39

https://github.com/sanmai/PHP-CS-Fixer/pull/3/checks?check_run_id=1439764906#step:7:413
https://github.com/sanmai/PHP-CS-Fixer/runs/1439738972?#step:7:411

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be a PHP 8 bug FWIW.

env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
SKIP_LINT_TEST_CASES: ${{ matrix.SKIP_LINT_TEST_CASES }}
PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: ${{ matrix.PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER }}
SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.SYMFONY_DEPRECATIONS_HELPER }}
run: |
vendor/bin/phpunit

- name: Run PHP CS Fixer
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
PHP_CS_FIXER_FUTURE_MODE: ${{ matrix.PHP_CS_FIXER_FUTURE_MODE }}
run: |
php php-cs-fixer --diff --dry-run -v fix
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ jobs:
- vendor/bin/phpunit --testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml || travis_terminate 1
- php vendor/bin/php-coveralls -v

-
<<: *STANDARD_TEST_JOB
stage: Test
php: nightly
env: COMPOSER_FLAGS="--ignore-platform-reqs" PHP_CS_FIXER_IGNORE_ENV=1 SYMFONY_DEPRECATIONS_HELPER=weak

-
stage: Deployment
php: 7.4
Expand Down
24 changes: 22 additions & 2 deletions tests/AutoReview/TravisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ private static function assertUpcomingPhpVersionIsCoveredByCiJob($lastSupportedV
new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion)),
// if `$lastsupportedVersion` is not snapshot version, expect CI to run snapshot of next PHP version
new TraversableContains('nightly'),
new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion + 0.1))
new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion + 0.1)),
// GitHub CI uses just versions, without suffix, e.g. 8.1 for 8.1snapshot as of writing
new TraversableContains(sprintf('%.1f', $lastSupportedVersion + 0.1)),
new TraversableContains(sprintf('%.1f', round($lastSupportedVersion + 1)))
));
}

Expand Down Expand Up @@ -124,9 +127,13 @@ private function getAllPhpVersionsUsedByCiForTests()
return false !== strpos($job['stage'], 'Test');
});

return array_map(function ($job) {
$travisPhpVersions = array_map(function ($job) {
return (string) $job['php'];
}, $jobs);

$gitHubPhpVersions = $this->getGitHubPhpVersions();

return array_merge($travisPhpVersions, $gitHubPhpVersions);
}

private function convertPhpVerIdToNiceVer($verId)
Expand Down Expand Up @@ -181,4 +188,17 @@ private function getTravisJobs()

return $yaml['jobs']['include'];
}

private function getGitHubPhpVersions()
Copy link
Member

Choose a reason for hiding this comment

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

👍

{
$yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.github/workflows/ci.yaml'));

$phpVersions = $yaml['jobs']['tests']['strategy']['matrix']['php-version'];

foreach ($yaml['jobs']['tests']['strategy']['matrix']['include'] as $job) {
$phpVersions[] = $job['php-version'];
}

return $phpVersions;
}
}
4 changes: 4 additions & 0 deletions tests/Smoke/InstallViaComposerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static function setUpBeforeClass()
{
parent::setUpBeforeClass();

if ('\\' === \DIRECTORY_SEPARATOR) {
static::markTestIncomplete('This test is broken on Windows');
Copy link
Contributor Author

@sanmai sanmai Nov 15, 2020

Choose a reason for hiding this comment

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

It wasn't working on Windows before due to missing composer executable. Otherwise put, this is a reflection of a status quo.

}

try {
CommandExecutor::create('php --version', __DIR__)->getResult();
} catch (\RuntimeException $e) {
Expand Down