Skip to content

Commit

Permalink
Add debug line
Browse files Browse the repository at this point in the history
  • Loading branch information
xvilo committed Dec 18, 2023
1 parent e77d36d commit db701c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
tools: phpunit-bridge
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql, zip
coverage: xdebug

- name: Get composer cache directory
Expand Down Expand Up @@ -65,6 +65,6 @@ jobs:
DATABASE_URL: postgres://postgres:[email protected]:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8

- name: Run tests
run: php vendor/bin/phpunit --coverage-text
run: git status && php vendor/bin/phpunit tests/Unit/Service/PackageSynchronizer/ComposerPackageSynchronizerTest.php --testdox --filter testSynchronizePackageWithGitLabToken
env:
DATABASE_URL: postgres://postgres:[email protected]:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
DATABASE_URL: postgres://postgres:[email protected]:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
21 changes: 19 additions & 2 deletions src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,50 @@ public function synchronize(Package $package): void
try {
$io = $this->createIO($package);
/** @var RepositoryInterface $repository */
$io->write('1');
$repository = current(RepositoryFactory::defaultRepos($io, $this->createConfig($package, $io)));
$io->write('2');
$json = ['packages' => []];
$io->write('3');
$packages = $repository->getPackages();
$io->write('4');

usort($packages, static function (PackageInterface $a, PackageInterface $b): int {
usort($packages, static function (PackageInterface $a, PackageInterface $b) use ($io): int {
$io->write('5');
if ($a->getVersion() === $b->getVersion()) {
return $a->getReleaseDate() <=> $b->getReleaseDate();
}

$io->write('6');
if ($a->getStability() === Version::STABILITY_STABLE && $b->getStability() !== Version::STABILITY_STABLE) {
return -1;
}

$io->write('7');
if ($a->getStability() !== Version::STABILITY_STABLE && $b->getStability() === Version::STABILITY_STABLE) {
return 1;
}

$io->write('8');
return Comparator::greaterThan($a->getVersion(), $b->getVersion()) ? 1 : -1;
});

$io->write('9');
if ($packages === []) {
throw new \RuntimeException('Package not found');
}

$latest = current($packages);

$io->write('10 ');
foreach ($packages as $p) {
$io->write('11 ');
$json['packages'][$p->getPrettyName()][$p->getPrettyVersion()] = $this->packageNormalizer->normalize($p);
if (Comparator::greaterThan($p->getVersion(), $latest->getVersion()) && $p->getStability() === Version::STABILITY_STABLE) {
$latest = $p;
}
}

$io->write('12');
/** @var string|null $name */
$name = $latest->getPrettyName();

Expand All @@ -110,7 +121,9 @@ public function synchronize(Package $package): void
}

$versions = [];
$io->write('13 ');
foreach ($packages as $p) {
$io->write('14 ');
if ($p->getDistUrl() !== null) {
$versions[] = [
'organizationAlias' => $package->organizationAlias(),
Expand All @@ -127,10 +140,12 @@ public function synchronize(Package $package): void
}
}

$io->write('15');
usort($versions, fn ($item1, $item2) => $item2['releaseDate'] <=> $item1['releaseDate']);

$encounteredVersions = [];
$encounteredLinks = [];
$io->write('16');
foreach ($versions as $version) {
$dist = new Dist(
$version['organizationAlias'],
Expand Down Expand Up @@ -218,6 +233,8 @@ public function synchronize(Package $package): void

$this->packageManager->saveProvider($json, $package->organizationAlias(), $name);
} catch (\Throwable $exception) {
dump($io->getOutput());
throw $exception;
$package->syncFailure(sprintf('Error: %s%s',
$exception->getMessage(),
isset($io) && strlen($io->getOutput()) > 1 ? "\nLogs:\n".$io->getOutput() : ''
Expand Down

0 comments on commit db701c4

Please sign in to comment.