From 1e2785d6900b4d709a31f4c669381dc340cad605 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 9 Jan 2024 10:46:18 -0800 Subject: [PATCH] fix saving of comment ids to disk (#221) See the failure here https://github.com/dart-lang/build/actions/runs/7463208455/job/20307339352?pr=3638#step:9:3. Changes `findCommentId` to again return an `int?` instead of an `IssueComment?`. Alternatively, we could rename this to `findComment`, and return the entire comment, but we only ever use the ID. We just call `toString()` on the return value of this function and serialize it to disk, so when it changed to an `IssueComment` it no longer serialized the ID. --- pkgs/firehose/CHANGELOG.md | 4 ++++ pkgs/firehose/lib/src/github.dart | 4 ++-- pkgs/firehose/pubspec.yaml | 2 +- pkgs/firehose/test/github_test.dart | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 23613cda..1eb0dbe7 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.1 + +- Fix comment ID serialization to disk. + ## 0.5.0 - Split health checks in individual workflows. diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 866bf32a..c37da5b7 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -91,7 +91,7 @@ class GithubApi { /// Find a comment on the PR matching the given criteria ([user], /// [searchTerm]). Return the issue ID if a matching comment is found or null /// if there's no match. - Future findCommentId({ + Future findCommentId({ required String user, String? searchTerm, }) async { @@ -107,7 +107,7 @@ class GithubApi { }, orElse: () => null, ); - return matchingComment; + return matchingComment?.id; } Future> listFilesForPR() async => await github.pullRequests diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 57e90f3f..6d657bb8 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.5.0 +version: 0.5.1 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: diff --git a/pkgs/firehose/test/github_test.dart b/pkgs/firehose/test/github_test.dart index ae3a195a..ef47b54e 100644 --- a/pkgs/firehose/test/github_test.dart +++ b/pkgs/firehose/test/github_test.dart @@ -26,14 +26,14 @@ Future main() async { }); test('Find comment', () async { var commentId = await github.findCommentId(user: 'auto-submit[bot]'); - expect(commentId?.id, 1660891263); + expect(commentId, 1660891263); }); test('Find comment with searchterm', () async { var commentId = await github.findCommentId( user: 'auto-submit[bot]', searchTerm: 'before re-applying this label.', ); - expect(commentId?.id, 1660891263); + expect(commentId, 1660891263); }); test('Find comment with searchterm', () async { var commentId = await github.findCommentId(