Skip to content

Commit c1a03b1

Browse files
authored
Disable posting new issues if there are consecutive successful report. (#7193)
1 parent dbc1d41 commit c1a03b1

File tree

1 file changed

+17
-4
lines changed
  • .github/actions/testing_report_generation

1 file changed

+17
-4
lines changed

.github/actions/testing_report_generation/app.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,27 @@ def get_report()
7070
end
7171
end
7272

73+
def get_workflows(client, repo_name)
74+
workflow_page = 0
75+
workflows = []
76+
loop do
77+
workflow_page += 1
78+
cur_page_workflows = client.workflows(repo_name, :page => workflow_page).workflows
79+
if cur_page_workflows.length == 0
80+
break
81+
end
82+
workflows.push(*cur_page_workflows)
83+
end
84+
return workflows
85+
end
86+
7387
failure_report = Table.new(ISSUE_TITLE)
7488
success_report = Table.new(ISSUE_TITLE)
7589
client = Octokit::Client.new(access_token: ENV["INPUT_ACCESS-TOKEN"])
7690
last_issue = client.list_issues(REPO_NAME_WITH_OWNER, :labels => ISSUE_LABELS, :state => "all")[0]
77-
workflows = client.workflows(REPO_NAME_WITH_OWNER)
7891

7992
puts "Excluded workflow files: " + EXCLUDED_WORKFLOWS.join(",")
80-
for wf in workflows.workflows do
93+
for wf in get_workflows(client, REPO_NAME_WITH_OWNER) do
8194
# skip if it is the issue generation workflow.
8295
if wf.name == ENV["GITHUB_WORKFLOW"]
8396
next
@@ -120,7 +133,7 @@ def get_report()
120133
# If the last issue is open, then failed report will be commented to the issue.
121134
elsif !last_issue.nil? and last_issue.state == "open"
122135
client.add_comment(REPO_NAME_WITH_OWNER, last_issue.number,failure_report.get_report)
123-
# Creat an new issue otherwise.
136+
# Create a new issue if there exists failed workflows.
124137
else
125-
client.create_issue(REPO_NAME_WITH_OWNER, ISSUE_TITLE, failure_report.get_report, labels: ISSUE_LABELS, assignee: ASSIGNEE)
138+
client.create_issue(REPO_NAME_WITH_OWNER, ISSUE_TITLE, failure_report.get_report, labels: ISSUE_LABELS, assignee: ASSIGNEE) unless !failure_report.get_report.nil?
126139
end

0 commit comments

Comments
 (0)