From ad06fdf0cd89ba3cc38b876ff8473ce5ea3099fb Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Fri, 13 Nov 2026 22:47:53 +0100 Subject: [PATCH] Migrate blocks-releases label to issue field --- lib/pyxis/checks/canary_release.rb | 2 +- lib/pyxis/checks/open_issues.rb | 79 +++++++++++++++++++++++++++--- lib/pyxis/global_status.rb | 3 +- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/lib/pyxis/checks/canary_release.rb b/lib/pyxis/checks/canary_release.rb index f5fa6ec..60574ea 100644 --- a/lib/pyxis/checks/canary_release.rb +++ b/lib/pyxis/checks/canary_release.rb @@ -9,7 +9,7 @@ def initialize(build_id_to_promote) 'Canary release', [ TucanaVersionMatch.new(info), - OpenIssues.new('release blocking', ['blocks-releases']) + OpenIssues.new('release blocking', field: 'Blocker', values: ['Release', 'Release: Canary']) ] ) end diff --git a/lib/pyxis/checks/open_issues.rb b/lib/pyxis/checks/open_issues.rb index 77b9602..7c11e5c 100644 --- a/lib/pyxis/checks/open_issues.rb +++ b/lib/pyxis/checks/open_issues.rb @@ -5,11 +5,16 @@ module Checks class OpenIssues include Check - attr_reader :check_context, :labels + Issue = Struct.new(:title, :html_url) - def initialize(check_context, labels) + PAGE_SIZE = 100 + + attr_reader :check_context, :field, :values + + def initialize(check_context, field:, values:) @check_context = check_context - @labels = labels + @field = field + @values = values end def perform_check! @@ -31,9 +36,71 @@ def status_message private def issues - @issues ||= GithubClient.octokit.search_issues( - "org:#{GithubClient::ORGANIZATION_NAME} is:open is:issue #{labels.map { |l| "label:#{l}" }.join(' ')}" - ).items + @issues ||= values + .flat_map { |value| fetch_issues_for(value) } + .uniq(&:html_url) + end + + def fetch_issues_for(value) + issues = [] + after = nil + + loop do + page = fetch_page(value, after) + repositories = page&.dig(:nodes) || [] + + repositories.each do |repository| + (repository.dig(:issues, :nodes) || []).each do |issue| + issues << Issue.new(issue[:title], issue[:url]) + end + end + + page_info = page&.dig(:pageInfo) || {} + break unless page_info[:hasNextPage] + + after = page_info[:endCursor] + end + + issues + end + + def fetch_page(value, after) + response = Pyxis::GlobalStatus.with_faraday_dry_run_bypass do + variables = { org: GithubClient::ORGANIZATION_NAME, field: field, value: value, after: after } + GithubClient.octokit.post( + '/graphql', + { query: issues_query, variables: variables }.to_json + ) + end + + response.dig(:data, :organization, :repositories) + end + + def issues_query + <<~GRAPHQL + query ($org: String!, $field: String!, $value: String!, $after: String) { + organization(login: $org) { + repositories(first: #{PAGE_SIZE}, after: $after) { + pageInfo { + hasNextPage + endCursor + } + nodes { + issues( + first: #{PAGE_SIZE}, + states: OPEN, + filterBy: { issueFieldValues: [{ fieldName: $field, multiSelectOptionValues: [$value] }] } + ) { + nodes { + title + url + } + } + } + } + } + } + GRAPHQL end end end diff --git a/lib/pyxis/global_status.rb b/lib/pyxis/global_status.rb index 1791dc0..7c6caef 100644 --- a/lib/pyxis/global_status.rb +++ b/lib/pyxis/global_status.rb @@ -9,10 +9,11 @@ def dry_run? end def with_faraday_dry_run_bypass + previous = @faraday_dry_run_bypass @faraday_dry_run_bypass = true yield ensure - @faraday_dry_run_bypass = false + @faraday_dry_run_bypass = previous end def faraday_dry_run_bypass?