Skip to content

Commit

Permalink
Disable posting new issues if there are consecutive successful report. (
Browse files Browse the repository at this point in the history
  • Loading branch information
granluo authored Dec 17, 2020
1 parent dbc1d41 commit c1a03b1
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions .github/actions/testing_report_generation/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,27 @@ def get_report()
end
end

def get_workflows(client, repo_name)
workflow_page = 0
workflows = []
loop do
workflow_page += 1
cur_page_workflows = client.workflows(repo_name, :page => workflow_page).workflows
if cur_page_workflows.length == 0
break
end
workflows.push(*cur_page_workflows)
end
return workflows
end

failure_report = Table.new(ISSUE_TITLE)
success_report = Table.new(ISSUE_TITLE)
client = Octokit::Client.new(access_token: ENV["INPUT_ACCESS-TOKEN"])
last_issue = client.list_issues(REPO_NAME_WITH_OWNER, :labels => ISSUE_LABELS, :state => "all")[0]
workflows = client.workflows(REPO_NAME_WITH_OWNER)

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

0 comments on commit c1a03b1

Please sign in to comment.