From db701c43cca22318a04cc9f99f5c61f88f215e11 Mon Sep 17 00:00:00 2001 From: Sem Schilder Date: Mon, 18 Dec 2023 13:10:53 +0100 Subject: [PATCH] Add debug line --- .github/workflows/phpunit-tests.yml | 6 +++--- .../ComposerPackageSynchronizer.php | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index be75fd3d..721c4234 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -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 @@ -65,6 +65,6 @@ jobs: DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ 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:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 + DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 diff --git a/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php b/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php index eda1d6bd..234ac82a 100644 --- a/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php +++ b/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php @@ -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(); @@ -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(), @@ -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'], @@ -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() : ''