From a5c29fff2d30ac23eecb2bb7bb0d7d3c9193ac98 Mon Sep 17 00:00:00 2001 From: Michka Popoff Date: Mon, 11 Apr 2022 22:36:42 +0200 Subject: [PATCH] utils/github.rb: convert pr to integer Follow up adter #13124 I made the choice to convert the pr variable to an integer at the very end and adjust the tests. It would be maybe more consistent to work with an integer everywhere, but this needs a more careful analysis and we are in a hurry to fix the homberew-core upload CI Fixes: 2022-04-11T20:19:34.1395885Z [31mError:[0m : Variable $pr of type Int! was provided invalid value 2022-04-11T20:19:34.1398279Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github/api.rb:261:in `open_graphql' 2022-04-11T20:19:34.1399774Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:310:in `get_workflow_run' 2022-04-11T20:19:34.1403699Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:418:in `block (4 levels) in pr_pull' 2022-04-11T20:19:34.1405233Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `each' 2022-04-11T20:19:34.1406723Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `block (3 levels) in pr_pull' 2022-04-11T20:19:34.1408112Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `chdir' 2022-04-11T20:19:34.1408986Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `cd' 2022-04-11T20:19:34.1409813Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:400:in `block (2 levels) in pr_pull' 2022-04-11T20:19:34.1410671Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir' 2022-04-11T20:19:34.1411495Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:399:in `block in pr_pull' 2022-04-11T20:19:34.1412250Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `each' 2022-04-11T20:19:34.1413056Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `pr_pull' --- Library/Homebrew/test/utils/github_spec.rb | 6 +++--- Library/Homebrew/utils/github.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index cda4db78ea..8221b76b2f 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -69,7 +69,7 @@ describe GitHub do it "fails to find a nonexistent workflow" do expect { described_class.get_artifact_url( - described_class.get_workflow_run("Homebrew", "homebrew-core", 1), + described_class.get_workflow_run("Homebrew", "homebrew-core", "1"), ) }.to raise_error(/No matching check suite found/) end @@ -77,14 +77,14 @@ describe GitHub do it "fails to find artifacts that don't exist" do expect { described_class.get_artifact_url( - described_class.get_workflow_run("Homebrew", "homebrew-core", 79751, artifact_name: "false_bottles"), + described_class.get_workflow_run("Homebrew", "homebrew-core", "79751", artifact_name: "false_bottles"), ) }.to raise_error(/No artifact .+ was found/) end it "gets an artifact link" do url = described_class.get_artifact_url( - described_class.get_workflow_run("Homebrew", "homebrew-core", 79751, artifact_name: "bottles"), + described_class.get_workflow_run("Homebrew", "homebrew-core", "79751", artifact_name: "bottles"), ) expect(url).to eq("https://api.github.com/repos/Homebrew/homebrew-core/actions/artifacts/70494047/zip") end diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 0ab38369bf..d7b617fbca 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -305,7 +305,7 @@ module GitHub variables = { user: user, repo: repo, - pr: pr, + pr: pr.to_i, } result = API.open_graphql(query, variables: variables, scopes: scopes)