From 9ba015d2369d10481f85d94d6ae2d73d34d455c3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Mar 2021 21:57:14 +0100 Subject: [PATCH] [travis] remove cache of composer.lock for deps=low --- .github/rm-invalid-lowest-lock-files.php | 164 ----------------------- .travis.yml | 6 +- 2 files changed, 1 insertion(+), 169 deletions(-) delete mode 100644 .github/rm-invalid-lowest-lock-files.php diff --git a/.github/rm-invalid-lowest-lock-files.php b/.github/rm-invalid-lowest-lock-files.php deleted file mode 100644 index 3e47b861e63f8..0000000000000 --- a/.github/rm-invalid-lowest-lock-files.php +++ /dev/null @@ -1,164 +0,0 @@ - [], 'packages-dev' => []]; - $composerJsons[$composerJson['name']] = [$dir, $composerLock['packages'] + $composerLock['packages-dev'], getRelevantContent($composerJson)]; -} - -$referencedCommits = []; - -foreach ($composerJsons as [$dir, $lockedPackages]) { - foreach ($lockedPackages as $lockedJson) { - if (0 !== strpos($version = $lockedJson['version'], 'dev-') && '-dev' !== substr($version, -4)) { - continue; - } - - if (!isset($composerJsons[$name = $lockedJson['name']])) { - echo "$dir/composer.lock references missing $name.\n"; - @unlink($dir.'/composer.lock'); - continue 2; - } - - if (isset($composerJsons[$name][2]['repositories']) && !isset($lockedJson['repositories'])) { - // the locked package has been patched locally but the lock references a commit, - // which means the referencing package itself is not modified - continue; - } - - foreach (['minimum-stability', 'prefer-stable'] as $key) { - if (array_key_exists($key, $composerJsons[$name][2])) { - $lockedJson[$key] = $composerJsons[$name][2][$key]; - } - } - - // use weak comparison to ignore ordering - if (getRelevantContent($lockedJson) != $composerJsons[$name][2]) { - echo "$dir/composer.lock is not in sync with $name.\n"; - @unlink($dir.'/composer.lock'); - continue 2; - } - - if ($lockedJson['dist']['reference']) { - $referencedCommits[$name][$lockedJson['dist']['reference']][] = $dir; - } - } -} - -if (!$referencedCommits) { - return; -} - -@mkdir($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org', 0777, true); - -$ch = null; -$mh = curl_multi_init(); -$sh = curl_share_init(); -curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); -curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); -curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); -$chs = []; - -foreach ($referencedCommits as $name => $dirsByCommit) { - foreach (['', '~dev'] as $suffix) { - $chs[] = $ch = [curl_init(), fopen($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '~').$suffix.'.json', 'w')]; - curl_setopt($ch[0], CURLOPT_URL, 'https://repo.packagist.org/p2/'.$name.$suffix.'.json'); - curl_setopt($ch[0], CURLOPT_FILE, $ch[1]); - curl_setopt($ch[0], CURLOPT_SHARE, $sh); - curl_multi_add_handle($mh, $ch[0]); - } -} - -do { - curl_multi_exec($mh, $active); - curl_multi_select($mh); -} while ($active); - -foreach ($chs as [$ch, $fd]) { - curl_multi_remove_handle($mh, $ch); - curl_close($ch); - fclose($fd); -} - -foreach ($referencedCommits as $name => $dirsByCommit) { - foreach (['', '~dev'] as $suffix) { - $repo = file_get_contents($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '~').$suffix.'.json'); - $repo = json_decode($repo, true); - - foreach ($repo['packages'][$name] as $version) { - if (isset($version['source']['reference'])) { - unset($referencedCommits[$name][$version['source']['reference']]); - } - } - } -} - -foreach ($referencedCommits as $name => $dirsByCommit) { - foreach ($dirsByCommit as $dirs) { - foreach ($dirs as $dir) { - if (file_exists($dir.'/composer.lock')) { - echo "$dir/composer.lock references old commit for $name.\n"; - @unlink($dir.'/composer.lock'); - } - } - } -} diff --git a/.travis.yml b/.travis.yml index ee0c4c815974d..336224a23bbbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -279,11 +279,7 @@ install: [[ ! $X ]] || (exit 1) elif [[ $deps = low ]]; then - [[ -e ~/php-ext/composer-lowest.lock.tar ]] && tar -xf ~/php-ext/composer-lowest.lock.tar - tar -cf ~/php-ext/composer-lowest.lock.tar --files-from /dev/null - php .github/rm-invalid-lowest-lock-files.php $COMPONENTS - echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'" - echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock + echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'" else if [[ $PHP = 8.0* ]]; then # add return types before running the test suite