-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add GitHub Workflows CI, including testing on PHP 8 and on macOS/Windows/Ubuntu #5268
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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' }} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: https://github.com/sanmai/PHP-CS-Fixer/pull/3/checks?check_run_id=1439764906#step:7:413
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
sanmai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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))) | ||
| )); | ||
| } | ||
|
|
||
|
|
@@ -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) | ||
|
|
@@ -181,4 +188,17 @@ private function getTravisJobs() | |
|
|
||
| return $yaml['jobs']['include']; | ||
| } | ||
|
|
||
| private function getGitHubPhpVersions() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,10 @@ public static function setUpBeforeClass() | |
| { | ||
| parent::setUpBeforeClass(); | ||
|
|
||
| if ('\\' === \DIRECTORY_SEPARATOR) { | ||
| static::markTestIncomplete('This test is broken on Windows'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't working on Windows before due to missing |
||
| } | ||
|
|
||
| try { | ||
| CommandExecutor::create('php --version', __DIR__)->getResult(); | ||
| } catch (\RuntimeException $e) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.