Skip to content

Commit 6caeffe

Browse files
committed
Add compatibility with Composer v2.3
- rewrite production autoload for compat with Composer v2.3 - refresh QA
1 parent ff31830 commit 6caeffe

16 files changed

+150
-103
lines changed

.github/workflows/qa.yml

Lines changed: 69 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,83 @@
11
name: Quality Assurance
2-
on: [push, pull_request]
3-
jobs:
4-
5-
cross_version:
6-
runs-on: ubuntu-latest
7-
if: "!contains(github.event.head_commit.message, 'ci skip')"
82

9-
strategy:
10-
matrix:
11-
php: [ '7.3', '7.4' ]
12-
tools: [ 'composer:v2', 'composer:v1' ]
13-
prefer: [ 'lowest', 'highest' ]
14-
ignore-platform: [ '' ]
15-
experimental: [ false ]
16-
include:
17-
- php: "8.0"
18-
prefer: "highest"
19-
ignore-platform: "--ignore-platform-reqs"
20-
experimental: true
21-
tools: "composer:v2"
22-
- php: "8.0"
23-
prefer: "highest"
24-
ignore-platform: "--ignore-platform-reqs"
25-
experimental: true
26-
tools: "composer:v1"
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
skip-jobs:
9+
required: true
10+
type: choice
11+
default: 'Run all'
12+
description: 'Choose jobs to run'
13+
options:
14+
- 'Run all'
15+
- 'Run static QA only'
16+
- 'Run static unit tests only'
2717

28-
continue-on-error: ${{ matrix.experimental }}
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
2921

30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@v2
22+
jobs:
23+
static-qa:
24+
runs-on: ubuntu-latest
25+
if: ${{ !contains(github.event.head_commit.message, 'skip qa') || github.event.inputs.skip-jobs == 'Run static unit tests only' }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
3329

34-
- name: Setup PHP
35-
uses: shivammathur/setup-php@v2
36-
with:
37-
php-version: ${{ matrix.php }}
38-
tools: ${{ matrix.tools }}
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: 7.4
34+
coverage: none
35+
tools: cs2pr
3936

40-
- name: Check syntax error in sources
41-
run: find ./src/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
37+
- name: Install dependencies
38+
uses: ramsey/composer-install@v2
4239

43-
- name: Install dependencies
44-
uses: "ramsey/composer-install@v1"
45-
with:
46-
dependency-versions: ${{ matrix.prefer }}
47-
composer-options: ${{ matrix.ignore-platform }}
40+
- name: Check code styles
41+
run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr
4842

49-
qa:
50-
runs-on: ubuntu-latest
51-
if: "!contains(github.event.head_commit.message, 'ci skip')"
43+
- name: Check Psalm
44+
run: ./vendor/bin/psalm --output-format=github --no-cache
5245

53-
steps:
54-
- name: Checkout
55-
uses: actions/checkout@v2
46+
unit-tests:
47+
runs-on: ubuntu-latest
48+
if: ${{ !contains(github.event.head_commit.message, 'skip tests') || github.event.inputs.skip-jobs == 'Run static QA only' }}
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
php-ver: [ '7.3', '7.4', '8.0' ]
53+
composer: [ 'composer:2.0', 'composer:2.1', 'composer:2.2', 'composer:2.3', 'composer:v1' ]
54+
dependency-versions: [ 'lowest', 'highest' ]
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v3
5658

57-
- name: Setup PHP
58-
uses: shivammathur/setup-php@v2
59-
with:
60-
php-version: 7.4
59+
- name: Setup PHP
60+
uses: shivammathur/setup-php@v2
61+
with:
62+
php-version: ${{ matrix.php-ver }}
63+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
64+
coverage: none
65+
tools: cs2pr, ${{ matrix.composer }}
6166

62-
- name: Install dependencies
63-
uses: "ramsey/composer-install@v1"
67+
- name: Install parallel-lint
68+
if: ${{ matrix.dependency-versions == 'highest' }}
69+
run: composer require php-parallel-lint/php-parallel-lint:^1.3.1 --dev --no-update
6470

65-
- name: Check cross-version PHP compatibility
66-
run: composer phpcompat
71+
- name: Install dependencies
72+
uses: ramsey/composer-install@v2
73+
with:
74+
dependency-versions: ${{ matrix.dependency-versions }}
75+
composer-options: ${{ matrix.composer-options }}
6776

68-
- name: Check code style
69-
run: composer cs
77+
- name: Lint PHP sources
78+
if: ${{ matrix.dependency-versions == 'highest' }}
79+
run: ./vendor/bin/parallel-lint ./src/ --checkstyle | cs2pr
7080

71-
- name: Check Psalm
72-
run: composer psalm
81+
# TODO: Write tests...
82+
#- name: Run unit tests
83+
# run: ./vendor/bin/phpunit --no-coverage

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
},
2525
"require-dev": {
2626
"composer/composer": "^2",
27-
"inpsyde/php-coding-standards": "^1@dev",
28-
"phpcompatibility/php-compatibility": "^9.3.0",
29-
"vimeo/psalm": "^4.1.1"
27+
"inpsyde/php-coding-standards": "^1",
28+
"vimeo/psalm": "^4.22"
3029
},
3130
"autoload": {
3231
"psr-4": {
@@ -37,13 +36,16 @@
3736
"class": "Inpsyde\\VipComposer\\Plugin"
3837
},
3938
"scripts": {
40-
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
41-
"psalm": "@php ./vendor/vimeo/psalm/psalm --no-cache --show-info=false --output-format=compact --no-progress",
42-
"phpcompat": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -p . --standard=PHPCompatibility --ignore=*/vendor/* --extensions=php --basepath=./ --runtime-set testVersion 7.3-",
39+
"phpcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
40+
"psalm": "@php ./vendor/vimeo/psalm/psalm --no-cache --show-info=false --no-progress",
4341
"qa": [
44-
"@cs",
45-
"@phpcompat",
42+
"@phpcs",
4643
"@psalm"
4744
]
45+
},
46+
"config": {
47+
"allow-plugins": {
48+
"dealerdirect/phpcodesniffer-composer-installer": true
49+
}
4850
}
4951
}

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<arg value="sp"/>
66
<arg name="colors"/>
7-
<config name="testVersion" value="7.2-"/>
7+
<config name="testVersion" value="7.3-"/>
88

99
<rule ref="Inpsyde" />
1010

psalm.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="true"
43
useDocblockPropertyTypes="true"
54
usePhpDocMethodsWithoutMagicCall="true"
65
strictBinaryOperands="true"
7-
allowPhpStormGenerics="true"
8-
allowCoercionFromStringToClassConst="true"
96
ignoreInternalFunctionFalseReturn="false"
107
ignoreInternalFunctionNullReturn="false"
118
hideExternalErrors="true"
@@ -26,6 +23,5 @@
2623
<MissingClosureReturnType errorLevel="suppress" />
2724
<UnresolvableInclude errorLevel="suppress" />
2825
<UndefinedConstant errorLevel="suppress" />
29-
<UnnecessaryVarAnnotation errorLevel="suppress" />
3026
</issueHandlers>
3127
</psalm>

src/Command.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
153153
{
154154
try {
155155
$this->resetComposer();
156-
/** @var Composer $composer */
157-
$composer = $this->getComposer(true);
156+
/**
157+
* @psalm-suppress DeprecatedMethod
158+
* @var Composer $composer
159+
*/
160+
$composer = is_callable([$this, 'requireComposer'])
161+
? $this->requireComposer()
162+
: $this->getComposer(true);
163+
158164
$factory = new Factory($composer, $this->getIO());
159165
$config = $factory->config();
160166

src/Git/EnsureGitIgnore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
final class EnsureGitIgnore
88
{
9-
109
/**
1110
* @param string $dir
1211
* @return bool

src/Git/GitProcess.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
class GitProcess
2121
{
22-
2322
/**
2423
* @var string
2524
*/

src/Git/MirrorCopier.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ private function copyLinks(array $linksPaths): bool
232232
$copied = 0;
233233
foreach ($linksPaths as $link => $target) {
234234
$real = realpath($link);
235+
if (!$real) {
236+
continue;
237+
}
235238
$targetParent = dirname($target);
236239
$saveIn = "{$targetParent}/" . pathinfo($real, PATHINFO_FILENAME) . '.zip';
237240
$git->cd($real)->exec("archive --format zip --output {$saveIn} master");

src/Git/VipGit.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,7 @@ private function mergeAndPush(
305305
$branches = explode($output, "\n") ?: [];
306306
$currentBranch = '';
307307
foreach ($branches as $branch) {
308-
if (strpos(trim($branch), '* ')) {
309-
$currentBranch = ltrim($branch, '* ');
310-
}
308+
strpos(trim($branch), '* ') and $currentBranch = ltrim($branch, '* ');
311309
}
312310

313311
$commands = [];
@@ -481,8 +479,8 @@ private function fillMirrorVendor(MirrorCopier $copier, string $mirrorDir): bool
481479
$vendorDir = $this->config->composerConfigValue('vendor-dir');
482480
$vendorSource = $this->filesystem->normalizePath($vendorDir);
483481
$targetPath = $this->directories->targetPath();
484-
$subdir = $this->filesystem->findShortestPath($targetPath, $vendorSource, true);
485-
$vendorTarget = "{$mirrorDir}/{$subdir}";
482+
$subDir = $this->filesystem->findShortestPath($targetPath, $vendorSource, true);
483+
$vendorTarget = "{$mirrorDir}/{$subDir}";
486484
$this->filesystem->ensureDirectoryExists($vendorTarget);
487485
$toCopy = $this->packages->noDevPackages();
488486

@@ -552,7 +550,7 @@ static function (string $file) use (&$counts): void {
552550
}
553551
);
554552

555-
if ($total < 1) {
553+
if (!$files) {
556554
$this->nothingToDoMessage($push);
557555

558556
return 0;

src/Task/EnsureGitKeep.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
final class EnsureGitKeep implements Task
1414
{
15-
1615
/**
1716
* @var VipDirectories
1817
*/
@@ -76,7 +75,7 @@ private function ensureGitKeepFor(string $dir): void
7675
}
7776

7877
$hasFiles = $this->haveFiles(0, $dir);
79-
$hasGitKeep = file_exists(realpath($dir) . '/.gitkeep');
78+
$hasGitKeep = file_exists((string)realpath($dir) . '/.gitkeep');
8079

8180
if (!$hasFiles && !$hasGitKeep) {
8281
file_put_contents("{$dir}/.gitkeep", "\n");

0 commit comments

Comments
 (0)