Skip to content

Commit

Permalink
Migrate to GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Dec 8, 2020
1 parent 7258055 commit badf545
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 85 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Continuous Integration"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1"

jobs:
tests:
name: "CI"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
dependencies: [locked]
include:
- php-version: "5.3"
dependencies: lowest
- php-version: "8.1"
dependencies: lowest

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Handle lowest dependencies update"
if: "contains(matrix.dependencies, 'lowest')"
run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --prefer-lowest\" >> $GITHUB_ENV"

- name: "Install latest dependencies"
run: |
# Remove PHPStan as it requires a newer PHP
composer remove phpstan/phpstan --dev --no-update
composer update ${{ env.COMPOSER_FLAGS }}
- name: "Run tests"
run: "vendor/bin/simple-phpunit --verbose"
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "PHP Lint"

on:
- push
- pull_request

jobs:
tests:
name: "Lint"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "5.3"
- "8.0"

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Lint PHP files"
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
51 changes: 51 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "PHPStan"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
SYMFONY_PHPUNIT_VERSION: ""

jobs:
tests:
name: "PHPStan"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
# pinned to 7.4 because we need PHPUnit 7.5 which does not support PHP 8
- "7.4"

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install latest dependencies"
run: "composer update ${{ env.COMPOSER_FLAGS }}"

- name: Run PHPStan
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
run: |
composer require --dev phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}
vendor/bin/phpstan analyse
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
.idea/
.phpunit.result.cache
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@
"composer-plugin-api": "^1.0 || ^2.0"
},
"require-dev": {
"composer/composer": "1.6.* || 2.0.*@dev",
"composer/composer": "1.6.* || ^2.0",
"composer/semver": "^1 || ^3",
"phpunit/phpunit": "^4.8.36",
"sebastian/comparator": "^1.2.4",
"symfony/phpunit-bridge": "^4.2 || ^5",
"phpstan/phpstan": "^0.12.55",
"symfony/process": "^2.3"
},
"scripts": {
"test": "phpunit"
"test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit",
"phpstan": "vendor/bin/phpstan analyse"
}
}
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 5
paths:
- src
- tests
12 changes: 6 additions & 6 deletions src/Composer/Installers/BaseInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function getInstallPath(PackageInterface $package, $frameworkType = '')
/**
* For an installer to override to modify the vars per installer.
*
* @param array $vars
* @return array
* @param array{name: string, vendor: string, type: string} $vars
* @return array{name: string, vendor: string, type: string}
*/
public function inflectPackageVars($vars)
{
Expand All @@ -85,7 +85,7 @@ public function inflectPackageVars($vars)
/**
* Gets the installer's locations
*
* @return array
* @return array<string, string> map of package types => install path
*/
public function getLocations()
{
Expand All @@ -95,8 +95,8 @@ public function getLocations()
/**
* Replace vars in a path
*
* @param string $path
* @param array $vars
* @param string $path
* @param array<string, string> $vars
* @return string
*/
protected function templatePath($path, array $vars = array())
Expand All @@ -121,7 +121,7 @@ protected function templatePath($path, array $vars = array())
* @param string $name
* @param string $type
* @param string $vendor = NULL
* @return string
* @return string|false
*/
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
{
Expand Down
11 changes: 2 additions & 9 deletions src/Composer/Installers/CakePHPInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Composer\Installers;

use Composer\DependencyResolver\Pool;
use Composer\Semver\Constraint\Constraint;

class CakePHPInstaller extends BaseInstaller
{
Expand Down Expand Up @@ -49,14 +50,6 @@ public function getLocations()
*/
protected function matchesCakeVersion($matcher, $version)
{
if (class_exists('Composer\Semver\Constraint\MultiConstraint')) {
$multiClass = 'Composer\Semver\Constraint\MultiConstraint';
$constraintClass = 'Composer\Semver\Constraint\Constraint';
} else {
$multiClass = 'Composer\Package\LinkConstraint\MultiConstraint';
$constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint';
}

$repositoryManager = $this->composer->getRepositoryManager();
if (! $repositoryManager) {
return false;
Expand All @@ -67,6 +60,6 @@ protected function matchesCakeVersion($matcher, $version)
return false;
}

return $repos->findPackage('cakephp/cakephp', new $constraintClass($matcher, $version)) !== null;
return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null;
}
}
4 changes: 1 addition & 3 deletions src/Composer/Installers/CockpitInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class CockpitInstaller extends BaseInstaller
*
* Strip `module-` prefix from package name.
*
* @param array @vars
*
* @return array
* {@inheritDoc}
*/
public function inflectPackageVars($vars)
{
Expand Down
13 changes: 6 additions & 7 deletions src/Composer/Installers/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $

// If not, execute the code right away as parent::uninstall executed synchronously (composer v1, or v2 without async)
$outputStatus();

return null;
}

/**
Expand All @@ -197,23 +199,20 @@ public function supports($packageType)
/**
* Finds a supported framework type if it exists and returns it
*
* @param string $type
* @return string
* @param string $type
* @return string|false
*/
protected function findFrameworkType($type)
{
$frameworkType = false;

krsort($this->supportedTypes);

foreach ($this->supportedTypes as $key => $val) {
if ($key === substr($type, 0, strlen($key))) {
$frameworkType = substr($type, 0, strlen($key));
break;
return substr($type, 0, strlen($key));
}
}

return $frameworkType;
return false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Installers/OxidInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OxidInstaller extends BaseInstaller
*
* @param PackageInterface $package
* @param string $frameworkType
* @return void
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
Expand Down
4 changes: 1 addition & 3 deletions src/Composer/Installers/SyDESInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class SyDESInstaller extends BaseInstaller
*
* Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present.
*
* @param array @vars
*
* @return array
* {@inerhitDoc}
*/
public function inflectPackageVars($vars)
{
Expand Down
Loading

0 comments on commit badf545

Please sign in to comment.