Skip to content

Commit 9c43766

Browse files
authored
More E2E tests (semi-autogenerated) (#190)
1 parent 77f3be3 commit 9c43766

File tree

6 files changed

+195
-27
lines changed

6 files changed

+195
-27
lines changed

.github/workflows/e2e.yml

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,92 @@ jobs:
99
matrix:
1010
include:
1111
-
12-
repo: phpstan/phpstan-src
13-
name: phpstan
14-
cdaArgs: --config=build/composer-dependency-analyser.php
12+
repo: TomasVotruba/unused-public
1513
-
16-
repo: shipmonk-rnd/phpstan-rules
17-
name: shipmonk-rules
14+
repo: VincentLanglet/Twig-CS-Fixer
1815
-
19-
repo: vincentlanglet/twig-cs-fixer
20-
name: twig-cs-fixer
16+
repo: alex-kalanis/kw_files
2117
-
22-
repo: qossmic/deptrac-src
23-
name: deptrac
18+
repo: alex-kalanis/kw_paths
19+
-
20+
repo: alex-kalanis/kw_storage
21+
-
22+
repo: cdn77/PhpFunctions
23+
-
24+
repo: cdn77/RabbitMQBundle
25+
-
26+
repo: contao/contao
27+
cdaArgs: --config=depcheck.php
28+
-
29+
repo: idleberg/php-vite-manifest
30+
-
31+
repo: idleberg/php-wordpress-vite-assets
32+
-
33+
repo: inspirum/arrayable-php
34+
-
35+
repo: inspirum/balikobot-php
36+
-
37+
repo: inspirum/balikobot-php-symfony
38+
-
39+
repo: inspirum/xml-php
2440
-
2541
repo: kreait/firebase-php
26-
name: firebase
42+
-
43+
repo: numero2/contao-marketing-suite
44+
cdaArgs: --config=depcheck.php
45+
-
46+
repo: numero2/contao-opengraph3
47+
cdaArgs: --config=depcheck.php
48+
-
49+
repo: oveleon/contao-company-bundle
50+
composerArgs: --no-plugins
51+
cdaArgs: --config=depcheck.php
52+
-
53+
repo: oveleon/contao-config-driver-bundle
54+
composerArgs: --no-plugins
55+
cdaArgs: --config=depcheck.php
2756
-
2857
repo: oveleon/contao-cookiebar
29-
name: contao-cookiebar
58+
composerArgs: --no-plugins
3059
cdaArgs: --config=depcheck.php
60+
-
61+
repo: oveleon/contao-glossary-bundle
3162
composerArgs: --no-plugins
63+
cdaArgs: --config=depcheck.php
64+
-
65+
repo: oveleon/contao-theme-compiler-bundle
66+
composerArgs: --no-plugins
67+
cdaArgs: --config=depcheck.php
68+
-
69+
repo: phpstan/phpstan-src
70+
cdaArgs: --config=build/composer-dependency-analyser.php
71+
-
72+
repo: qossmic/deptrac-src
3273
-
3374
repo: rectorphp/rector-src
34-
name: rector
3575
-
36-
repo: inspirum/balikobot-php
37-
name: balikobot
76+
repo: rectorphp/swiss-knife
3877
-
39-
repo: wallabag/wallabag
40-
name: wallabag
78+
repo: shipmonk-rnd/dead-code-detector
79+
-
80+
repo: shipmonk-rnd/doctrine-hint-driven-sql-walker
81+
-
82+
repo: shipmonk-rnd/doctrine-mysql-index-hints
83+
-
84+
repo: shipmonk-rnd/doctrine-mysql-optimizer-hints
85+
-
86+
repo: shipmonk-rnd/doctrine-two-phase-migrations
87+
-
88+
repo: shipmonk-rnd/input-mapper
4189
-
42-
repo: tomasvotruba/unused-public
43-
name: unused-public
90+
repo: shipmonk-rnd/name-collision-detector
91+
-
92+
repo: shipmonk-rnd/phpstan-rules
93+
-
94+
repo: teamneusta/pimcore-testing-framework
95+
-
96+
repo: wallabag/wallabag
97+
4498
fail-fast: false
4599
steps:
46100
-
@@ -57,7 +111,7 @@ jobs:
57111
name: Clone ${{ matrix.repo }}
58112
uses: actions/checkout@v4
59113
with:
60-
path: ${{ matrix.name }}
114+
path: ${{ matrix.repo }}
61115
repository: ${{ matrix.repo }}
62116

63117
-
@@ -73,16 +127,16 @@ jobs:
73127

74128
-
75129
name: Disable autoloader prepend
76-
working-directory: ${{ matrix.name }}
130+
working-directory: ${{ matrix.repo }}
77131
run: |
78132
echo "$(jq --indent 4 '.config += {"prepend-autoloader": false}' composer.json)" > composer.json
79133
80134
-
81-
name: Install ${{ matrix.name }} dependencies
82-
working-directory: ${{ matrix.name }}
135+
name: Install ${{ matrix.repo }} dependencies
136+
working-directory: ${{ matrix.repo }}
83137
run: composer install --no-progress --no-interaction --ignore-platform-reqs ${{ matrix.composerArgs }}
84138

85139
-
86140
name: Run analyser
87-
working-directory: ${{ matrix.name }}
88-
run: php ../analyser/bin/composer-dependency-analyser ${{ matrix.cdaArgs }}
141+
working-directory: ${{ matrix.repo }}
142+
run: php ../../analyser/bin/composer-dependency-analyser ${{ matrix.cdaArgs }}

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"@check:types",
6868
"@check:tests",
6969
"@check:self",
70-
"@check:collisions"
70+
"@check:collisions",
71+
"@check:scripts"
7172
],
7273
"check:collisions": "detect-collisions src tests",
7374
"check:composer": [
@@ -76,6 +77,7 @@
7677
],
7778
"check:cs": "phpcs",
7879
"check:ec": "ec src tests",
80+
"check:scripts": "phpstan analyse -vv --ansi --level=6 scripts/*.php",
7981
"check:self": "bin/composer-dependency-analyser",
8082
"check:tests": "phpunit -vvv tests",
8183
"check:types": "phpstan analyse -vv --ansi",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<file>bin/composer-dependency-analyser</file>
2020
<file>src/</file>
2121
<file>tests/</file>
22+
<file>scripts/</file>
2223

2324
<exclude-pattern>tests/data/*</exclude-pattern>
2425

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
includes:
2-
- phar://phpstan.phar/conf/config.levelmax.neon
32
- phar://phpstan.phar/conf/bleedingEdge.neon
43
- ./vendor/phpstan/phpstan-strict-rules/rules.neon
54
- ./vendor/phpstan/phpstan-phpunit/extension.neon
65
- ./vendor/phpstan/phpstan-phpunit/rules.neon
76

87
parameters:
8+
level: max
99
phpVersion: 70200
1010
paths:
1111
- bin/composer-dependency-analyser

scripts/refresh-e2e.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php declare(strict_types = 1);
2+
3+
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
4+
// phpcs:disable Squiz.Functions.GlobalFunction.Found
5+
6+
/**
7+
* https://github.com/composer/packagist/blob/main/src/Controller/PackageController.php#L1282
8+
*
9+
* @return list<string>
10+
*/
11+
function fetchDependents(string $packageName, int $page = 1): array
12+
{
13+
$url = "https://packagist.org/packages/{$packageName}/dependents.json?page={$page}&requires=require-dev";
14+
$data = json_decode(file_get_contents($url), true);
15+
$packages = $data['packages'] ?? [];
16+
17+
$result = [];
18+
19+
foreach ($packages as $package) {
20+
$packageName = $package['name'];
21+
$downloads = $package['downloads'] ?? 0;
22+
23+
if ($downloads < 2000) {
24+
continue;
25+
}
26+
27+
$result[] = $packageName;
28+
}
29+
30+
return $result;
31+
}
32+
33+
function fetchRepository(string $packageName): string
34+
{
35+
$url = "https://repo.packagist.org/p2/{$packageName}.json";
36+
$data = json_decode(file_get_contents($url), true);
37+
$packageData = $data['packages'][$packageName][0] ?? null;
38+
39+
preg_match('/github\.com\/([^\/]+)\/([^\/]+).git/', $packageData['source']['url'], $matches);
40+
[, $owner, $repo] = $matches;
41+
42+
return "$owner/$repo";
43+
}
44+
45+
/**
46+
* @param list<array{repo: string, cdaArgs?: string, composerArgs?: string}> $items
47+
*/
48+
function outputYaml(array $items): void
49+
{
50+
foreach ($items as $item) {
51+
echo " -\n";
52+
53+
foreach ($item as $key => $value) {
54+
echo " $key: $value\n";
55+
}
56+
}
57+
}
58+
59+
$packageName = 'shipmonk/composer-dependency-analyser';
60+
$page = 1;
61+
$result = [];
62+
63+
do {
64+
$dependents = fetchDependents($packageName, $page);
65+
66+
foreach ($dependents as $dependent) {
67+
$repository = fetchRepository($dependent);
68+
$result[] = [
69+
'repo' => $repository,
70+
];
71+
}
72+
73+
$page++;
74+
} while (count($dependents) > 0);
75+
76+
// manual adjustments for some repositories
77+
$result[] = [
78+
'repo' => 'phpstan/phpstan-src',
79+
'cdaArgs' => '--config=build/composer-dependency-analyser.php',
80+
];
81+
$result[] = [
82+
'repo' => 'qossmic/deptrac-src',
83+
];
84+
85+
foreach ($result as $index => &$item) {
86+
if (strpos($item['repo'], 'oveleon') === 0) {
87+
$item['composerArgs'] = '--no-plugins';
88+
}
89+
90+
if (
91+
strpos($item['repo'], 'oveleon') === 0
92+
|| strpos($item['repo'], 'contao') === 0
93+
|| strpos($item['repo'], 'numero2') === 0
94+
) {
95+
$item['cdaArgs'] = '--config=depcheck.php';
96+
}
97+
98+
if (
99+
strpos($item['repo'], 'Setono') === 0
100+
|| $item['repo'] === 'contao-thememanager/core'
101+
|| $item['repo'] === 'oveleon/contao-recommendation-bundle'
102+
) {
103+
unset($result[$index]); // failing builds
104+
}
105+
}
106+
107+
usort($result, static function (array $a, array $b): int {
108+
return $a['repo'] <=> $b['repo'];
109+
});
110+
111+
outputYaml($result);

0 commit comments

Comments
 (0)