Skip to content

Commit 823bb74

Browse files
authored
Test issue_generation on pull requests. (#7643)
1 parent 143fb82 commit 823bb74

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.github/actions/testing_report_generation/app.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
require 'tzinfo'
2121

2222
REPO_NAME_WITH_OWNER = ENV['GITHUB_REPOSITORY']
23-
NO_WORKFLOW_RUNNING_INFO = 'All nightly cron job were not run. Please make sure there at least exists one cron job running.'.freeze
23+
GITHUB_WORKFLOW_URL = "https://github.com/#{REPO_NAME_WITH_OWNER}/actions/runs/#{ENV['GITHUB_RUN_ID']}"
24+
TESTS_TIME_INTERVAL_IN_HOURS = 24
25+
TESTS_TIME_INTERVAL_IN_SECS = TESTS_TIME_INTERVAL_IN_HOURS * 3600
26+
NO_WORKFLOW_RUNNING_INFO = "All nightly cron job were not run in the last #{TESTS_TIME_INTERVAL_IN_HOURS} hrs. Please review [log](#{GITHUB_WORKFLOW_URL}) make sure there at least exists one cron job running.".freeze
2427
EXCLUDED_WORKFLOWS = []
2528
ISSUE_LABELS = ""
2629
ISSUE_TITLE = "Auto-Generated Testing Report"
@@ -47,10 +50,10 @@ def initialize(title)
4750
@is_empty_table = true
4851
@text = String.new ""
4952
@text << "# %s\n" % [title]
50-
@text << "This issue is generated at %s\n" % [cur_time.strftime('%m/%d/%Y %H:%M %p') ]
53+
@text << "This issue([log](%s)) is generated at %s, fetching workflow runs triggered in the last %s hrs.\n" % [GITHUB_WORKFLOW_URL, cur_time.strftime('%m/%d/%Y %H:%M %p'), TESTS_TIME_INTERVAL_IN_HOURS ]
5154
# get a table with two columns, workflow and the date of yesterday.
5255
@text << "| Workflow |"
53-
@text << (cur_time - 86400).strftime('%m/%d') + "|"
56+
@text << (cur_time - TESTS_TIME_INTERVAL_IN_SECS).strftime('%m/%d') + "|"
5457
@text << "\n| -------- |"
5558
@text << " -------- |"
5659
@text << "\n"
@@ -107,7 +110,7 @@ def get_workflows(client, repo_name)
107110
elsif EXCLUDED_WORKFLOWS.include?(workflow_file)
108111
puts workflow_file + " is excluded in the report."
109112
# Involved workflow runs triggered within one day.
110-
elsif Time.now.utc - latest_run.created_at < 86400
113+
elsif Time.now.utc - latest_run.created_at < TESTS_TIME_INTERVAL_IN_SECS
111114
puts "created_at: %s" % [latest_run.created_at]
112115
puts "conclusion: %s" % [latest_run.conclusion]
113116
result_text = "[%s](%s)" % [latest_run.conclusion.nil? ? "in_process" : latest_run.conclusion, latest_run.html_url]
@@ -119,8 +122,6 @@ def get_workflows(client, repo_name)
119122
else
120123
puts "created_at: %s" % [latest_run.created_at]
121124
puts "conclusion: %s" % [latest_run.conclusion]
122-
result_text = "[%s](%s)" % [latest_run.conclusion.nil? ? "in_process" : latest_run.conclusion, latest_run.html_url]
123-
failure_report.add_workflow_run_and_result(workflow_text, result_text + "The cron job created_at: %s did not run in the last 24 hrs." % [latest_run.created_at])
124125
end
125126
end
126127

.github/workflows/generate_issues.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: generate_issues
2+
23
on:
34
pull_request:
45
paths:
@@ -21,3 +22,19 @@ jobs:
2122
access-token: '${{ secrets.GITHUB_TOKEN }}'
2223
# This is to exclude workflows that will be searched in the nightly report.
2324
exclude-workflow-files: 'performance-integration-tests.yml'
25+
26+
test_generate_an_issue:
27+
# Don't run on private repo.
28+
if: github.repository == 'Firebase/firebase-ios-sdk' && github.event_name != 'schedule'
29+
runs-on: ubuntu-latest
30+
name: Test nightly report generations
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Create a nightly report
34+
uses: ./.github/actions/testing_report_generation/
35+
with:
36+
access-token: '${{ secrets.GITHUB_TOKEN }}'
37+
# This is to exclude workflows that will be searched in the nightly report.
38+
exclude-workflow-files: 'performance-integration-tests.yml'
39+
issue-labels: 'nightly-testing-report-generation-test'
40+
issue-title: 'Nightly Testing Report For Presubmit Testing'

0 commit comments

Comments
 (0)