Skip to content

Commit c30be71

Browse files
authored
Make the check/dump composer root version more loose (#337)
1 parent e8ae870 commit c30be71

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

bin/check-composer-root-version.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
return;
2424
}
2525

26+
if (100 === $exception->getCode()) {
27+
// This is the GitHub API playing tricks on us... I could not find a way to reliably fix it so it is just better
28+
// to avoid bailing out because of it for now.
29+
return;
30+
}
31+
2632
throw $exception;
2733
}
2834

bin/dump-composer-root-version.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@
1414

1515
require_once __DIR__.'/root-version.php';
1616

17-
$composerRootVersion = get_composer_root_version(get_last_tag_name());
17+
try {
18+
$composerRootVersion = get_composer_root_version(get_last_tag_name());
19+
} catch (RuntimeException $exception) {
20+
if (false !== getenv('TRAVIS') && false === getenv('GITHUB_TOKEN')) {
21+
// Ignore this PR to avoid too many builds to fail untimely or locally due to API rate limits because the last
22+
// release version could not be retrieved.
23+
return;
24+
}
25+
26+
if (100 === $exception->getCode()) {
27+
return;
28+
}
29+
30+
throw $exception;
31+
}
1832

1933
file_put_contents(
2034
__DIR__.'/../.composer-root-version',

bin/root-version.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function get_last_tag_name(): string
4848
sprintf(
4949
'No tag name could be found in: %s',
5050
$lastReleaseEndpointContents
51-
)
51+
),
52+
100
5253
);
5354
}
5455

0 commit comments

Comments
 (0)