Browse Source

Drop Travis CI

Dariusz Ruminski 4 years ago
parent
commit
d665dd62f0
4 changed files with 31 additions and 69 deletions
  1. 23 2
      .github/workflows/ci.yml
  2. 0 45
      .travis.yml
  3. 1 1
      dev-tools/build.sh
  4. 7 21
      tests/AutoReview/CiConfigurationTest.php

+ 23 - 2
.github/workflows/ci.yml

@@ -40,6 +40,11 @@ jobs:
             calculate-code-coverage: 'yes'
             phpunit-flags: '--testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml'
 
+          - operating-system: 'ubuntu-20.04'
+            php-version: '7.4'
+            job-description: 'with deployment'
+            execute-deployment: 'yes'
+
           - operating-system: 'ubuntu-20.04'
             php-version: '7.4'
             job-description: 'with migration rules'
@@ -99,8 +104,8 @@ jobs:
             composer-
 
       - name: Configure Symfony Flex
+        if: matrix.execute-flex-with-symfony-version
         run: composer config extra.symfony.require ${{ matrix.execute-flex-with-symfony-version }}
-        if: "matrix.execute-flex-with-symfony-version"
 
       - name: Install dependencies
         uses: nick-invision/retry@v2
@@ -113,8 +118,8 @@ jobs:
             composer info -D
 
       - name: Execute migration rules
+        if: matrix.execute-migration-rules == 'yes'
         run: php php-cs-fixer fix --rules @PHP73Migration,@PHP71Migration:risky,blank_line_after_opening_tag -q
-        if: "matrix.execute-migration-rules == 'yes'"
 
       - name: Run tests
         continue-on-error: ${{ matrix.php-version == '8.0' }}
@@ -136,3 +141,19 @@ jobs:
           PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
           PHP_CS_FIXER_FUTURE_MODE: 1
         run: php php-cs-fixer --diff --dry-run -v fix
+
+      - name: Execute deployment checks
+        if: matrix.execute-deployment == 'yes'
+        run: |
+          ./dev-tools/build.sh
+          PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS=0 vendor/bin/phpunit tests/Smoke/
+
+      - name: Execute deployment post-hook
+        if: matrix.execute-deployment == 'yes' && startsWith(github.ref, 'refs/tags/v')
+        env:
+          TRAVIS_TOKEN: ${{ secrets.TRAVIS_TOKEN }}
+        run: |
+          # ensure that deployment is happening only if tag matches version of PHP CS Fixer
+          test $(php dev-tools/info-extractor.php | jq -r .version.vnumber) == "${GITHUB_REF#refs/tags/}"
+          # trigger website update
+          ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${GITHUB_REF#refs/tags/}

+ 0 - 45
.travis.yml

@@ -1,45 +0,0 @@
-dist: xenial
-os: linux
-
-language: php
-
-git:
-    depth: 10
-
-cache:
-    directories:
-        - $HOME/.composer
-        - $HOME/bin
-
-env:
-    global:
-        - DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress"
-        - COMPOSER_FLAGS=""
-
-before_install:
-    # turn off XDebug
-    - phpenv config-rm xdebug.ini || return 0
-
-jobs:
-    include:
-        -
-            stage: Deployment
-            php: 7.4
-            install: ./dev-tools/build.sh
-            script:
-                - PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS=0 vendor/bin/phpunit tests/Smoke/
-
-            before_deploy:
-                # ensure that deployment is happening only if tag matches version of PHP CS Fixer
-                - test $(php dev-tools/info-extractor.php | jq .version.vnumber) == "\"$TRAVIS_TAG\""
-            deploy:
-                provider: releases
-                token:
-                    secure: K9NKi7X1OPz898fxtVc1RfWrSI+4hTFFYOik932wTz1jC4dQJ64Khh1LV9frA1+JiDS3+R6TvmQtpzbkX3y4L75UrSnP1ADH5wfMYIVmydG3ZjTMo8SWQWHmRMh3ORAKTMMpjl4Q7EkRkLp6RncKe+FAFPP5mgv55mtIMaE4qUk=
-                file: php-cs-fixer.phar
-                skip_cleanup: true
-                on:
-                    repo: FriendsOfPHP/PHP-CS-Fixer
-                    tags: true
-            after_deploy:
-                - ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${TRAVIS_TAG}

+ 1 - 1
dev-tools/build.sh

@@ -9,7 +9,7 @@ composer require --no-update symfony/polyfill-mbstring
 
 # install package deps without dev-deps / remove already installed dev-deps
 # box can ignore dev-deps, but dev-deps, when installed, may lower version of prod-deps
-composer update --no-interaction --no-progress --no-dev --prefer-stable
+composer update --no-interaction --no-progress --no-dev --prefer-stable --optimize-autoloader
 composer info -D | sort
 
 composer show -d dev-tools humbug/box -q || composer update -d dev-tools --no-interaction --no-progress

+ 7 - 21
tests/AutoReview/CiConfigurationTest.php

@@ -125,21 +125,18 @@ final class CiConfigurationTest extends TestCase
 
     private function getAllPhpVersionsUsedByCiForDeployments()
     {
-        $jobs = array_filter($this->getTravisJobs(), function ($job) {
-            return 'Deployment' === $job['stage'];
+        $jobs = array_filter($this->getGitHubJobs(), function ($job) {
+            return isset($job['execute-deployment']) && 'yes' === $job['execute-deployment'];
         });
 
         return array_map(function ($job) {
-            return \is_string($job['php']) ? $job['php'] : sprintf('%.1f', $job['php']);
+            return \is_string($job['php-version']) ? $job['php-version'] : sprintf('%.1f', $job['php-version']);
         }, $jobs);
     }
 
     private function getAllPhpVersionsUsedByCiForTests()
     {
-        return array_merge(
-            $this->getPhpVersionsUsedByTravis(),
-            $this->getPhpVersionsUsedByGitHub()
-        );
+        return $this->getPhpVersionsUsedByGitHub();
     }
 
     private function convertPhpVerIdToNiceVer($verId)
@@ -188,11 +185,11 @@ final class CiConfigurationTest extends TestCase
         return $this->convertPhpVerIdToNiceVer($phpVerId);
     }
 
-    private function getTravisJobs()
+    private function getGitHubJobs()
     {
-        $yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.travis.yml'));
+        $yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.github/workflows/ci.yml'));
 
-        return $yaml['jobs']['include'];
+        return $yaml['jobs']['tests']['strategy']['matrix']['include'];
     }
 
     private function getPhpVersionsUsedByGitHub()
@@ -207,15 +204,4 @@ final class CiConfigurationTest extends TestCase
 
         return $phpVersions;
     }
-
-    private function getPhpVersionsUsedByTravis()
-    {
-        $jobs = array_filter($this->getTravisJobs(), function ($job) {
-            return false !== strpos($job['stage'], 'Test');
-        });
-
-        return array_map(function ($job) {
-            return (string) $job['php'];
-        }, $jobs);
-    }
 }