From 1f7781c0aa48732845ec13c2f07f83c3f09fe164 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 21 Nov 2023 16:21:26 +0100 Subject: [PATCH 1/4] Add retries to pub client calls --- pkgs/firehose/lib/src/pub.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/pub.dart b/pkgs/firehose/lib/src/pub.dart index 9b875dfb..77945998 100644 --- a/pkgs/firehose/lib/src/pub.dart +++ b/pkgs/firehose/lib/src/pub.dart @@ -13,8 +13,8 @@ class Pub { http.Client get httpClient => _httpClient ??= http.Client(); Future hasPublishedVersion(String name, String version) async { - var response = - await httpClient.get(Uri.parse('https://pub.dev/api/packages/$name')); + var uri = Uri.parse('https://pub.dev/api/packages/$name'); + http.Response response = await getCall(uri, retries: 3); if (response.statusCode != 200) { return false; } @@ -26,6 +26,20 @@ class Pub { .contains(version); } + Future getCall(Uri uri, {required int retries}) async { + for (var i = 0; i < retries + 1; i++) { + try { + var response = await httpClient.get(uri); + return response; + } catch (e) { + if (i >= retries) { + rethrow; + } + } + } + throw AssertionError('This should be unreachable'); + } + void close() { _httpClient?.close(); } From e82485254f51aec6e5de431a6fdfe33de3734121 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 21 Nov 2023 16:22:05 +0100 Subject: [PATCH 2/4] Remove type --- pkgs/firehose/lib/src/pub.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/pub.dart b/pkgs/firehose/lib/src/pub.dart index 77945998..49f9e77e 100644 --- a/pkgs/firehose/lib/src/pub.dart +++ b/pkgs/firehose/lib/src/pub.dart @@ -14,7 +14,7 @@ class Pub { Future hasPublishedVersion(String name, String version) async { var uri = Uri.parse('https://pub.dev/api/packages/$name'); - http.Response response = await getCall(uri, retries: 3); + var response = await getCall(uri, retries: 3); if (response.statusCode != 200) { return false; } From 7a78bae65b4e65673f00dd27570f778f029d10db Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 21 Nov 2023 16:25:29 +0100 Subject: [PATCH 3/4] Add changelog entry --- pkgs/firehose/CHANGELOG.md | 4 ++++ pkgs/firehose/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 8d800845..abf42074 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.33 + +- Retry calls to pub.dev API. + ## 0.3.32 - Fix an issue validating pre-release git publishing tags (#176). diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 04cde484..28902f9f 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -1,6 +1,6 @@ name: firehose description: A tool to automate publishing of Pub packages from GitHub actions. -version: 0.3.32 +version: 0.3.33 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: From bbb1323f16aece7b0db79021d8c157cc616874d8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 21 Nov 2023 16:26:39 +0100 Subject: [PATCH 4/4] Also post workflow failures --- .github/workflows/post_summaries.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/post_summaries.yaml b/.github/workflows/post_summaries.yaml index 1548c996..cfca7574 100644 --- a/.github/workflows/post_summaries.yaml +++ b/.github/workflows/post_summaries.yaml @@ -17,8 +17,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' + github.event.workflow_run.event == 'pull_request' continue-on-error: true steps: