|
| 1 | +# `workflow_information.py` Script |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | +- [Python](https://www.python.org/) and required packages. |
| 5 | + ``` |
| 6 | + pip install requests argparse |
| 7 | + ``` |
| 8 | +
|
| 9 | +## Usage |
| 10 | +- Collect last `90` days' `Postsubmit` `ci_workflow.yml` workflow runs: |
| 11 | + ``` |
| 12 | + python workflow_information.py --token ${your_github_toke} --branch master --event push --d 90 |
| 13 | + ``` |
| 14 | +
|
| 15 | +- Collect last `30` days' `Presubmit` `ci_workflow.yml` workflow runs: |
| 16 | + ``` |
| 17 | + python workflow_information.py --token ${your_github_toke} --event pull_request --d 30 |
| 18 | + ``` |
| 19 | +
|
| 20 | +- Please refer to `Inputs` section for more use cases, and `Outputs` section for the workflow summary report format. |
| 21 | +
|
| 22 | +## Inputs |
| 23 | +- `-o, --repo_owner`: **[Required]** GitHub repo owner, default value is `firebase`. |
| 24 | +
|
| 25 | +- `-n, --repo_name`: **[Required]** GitHub repo name, default value is `firebase-android-sdk`. |
| 26 | +
|
| 27 | +- `-t, --token`: **[Required]** GitHub access token. See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). |
| 28 | +
|
| 29 | +- `-w, --workflow_name`: **[Required]** Workflow filename, default value is `ci_tests.yml`. |
| 30 | +
|
| 31 | +- `-d, --days`: Filter workflows that running in past -d days, default value is `90`. See [retention period for GitHub Actions artifacts and logs](https://docs.github.com/en/organizations/managing-organization-settings/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization). |
| 32 | +
|
| 33 | +- `-b, --branch`: Filter branch name that workflows run against. |
| 34 | +
|
| 35 | +- `-a, --actor`: Filter the actor who triggers the workflow runs. |
| 36 | +
|
| 37 | +- `-e, --event`: Filter workflows trigger event, could be one of the following values `['push', 'pull_request', 'issue']`. |
| 38 | +
|
| 39 | +- `-j, --jobs`: Filter workflows jobs, default is `all` (including rerun jobs), could be one of the following values `['latest', 'all']`. |
| 40 | +
|
| 41 | +- `-f, --folder`: Workflow and job information will be store here, default value is the current datatime. |
| 42 | +
|
| 43 | +
|
| 44 | +## Outputs |
| 45 | +
|
| 46 | +- `workflow_summary_report.txt`: a general report contains workflow pass/failure count, running time, etc. |
| 47 | +
|
| 48 | + ``` |
| 49 | + 2023-03-03 01:37:07.114500 |
| 50 | + Namespace(actor=None, branch=None, days=30, event='pull_request', folder='presubmit_30', jobs='all', repo_name='firebase-android-sdk', repo_owner='firebase', token=${your_github_token}, workflow_name='ci_tests.yml') |
| 51 | +
|
| 52 | + Workflow 'ci_tests.yml' Report: |
| 53 | + Workflow Failure Rate:64.77% |
| 54 | + Workflow Total Count: 193 (success: 68, failure: 125) |
| 55 | +
|
| 56 | + Workflow Runtime Report: |
| 57 | + 161 workflow runs finished without rerun, the average running time: 0:27:24.745342 |
| 58 | + Including: |
| 59 | + 56 passed workflow runs, with average running time: 0:17:29.214286 |
| 60 | + 105 failed workflow runs, with average running time: 0:32:42.361905 |
| 61 | +
|
| 62 | + 32 runs finished with rerun, the average running time: 1 day, 3:57:53.937500 |
| 63 | + The running time for each workflow reruns are: |
| 64 | + ['1 day, 2:24:32', '3:35:54', '3:19:14', '4 days, 6:10:50', '15:33:39', '1:57:21', '1:13:12', '1:55:18', '12 days, 21:51:29', '0:48:48', '0:45:28', '1:40:21', '2 days, 1:46:35', '19:47:16', '0:45:49', '2:22:36', '0:25:22', '0:55:30', '1:40:32', '1:10:05', '20:08:38', '0:31:03', '5 days, 9:19:25', '5:10:44', '1:20:57', '0:28:47', '1:52:44', '20:19:17', '0:35:15', '21:31:07', '3 days, 1:06:44', '3 days, 2:18:14'] |
| 65 | +
|
| 66 | + Job Failure Report: |
| 67 | + Unit Tests (:firebase-storage): |
| 68 | + Failure Rate:54.61% |
| 69 | + Total Count: 152 (success: 69, failure: 83) |
| 70 | + Unit Tests (:firebase-messaging): |
| 71 | + Failure Rate:35.37% |
| 72 | + Total Count: 147 (success: 95, failure: 52) |
| 73 | + ``` |
| 74 | +
|
| 75 | +
|
| 76 | +- Intermediate file `workflow_summary.json`: contains all the workflow runs and job information attached to each workflow. |
| 77 | +
|
| 78 | + ``` |
| 79 | + { |
| 80 | + 'workflow_name':'ci_tests.yml', |
| 81 | + 'total_count':81, |
| 82 | + 'success_count':32, |
| 83 | + 'failure_count':49, |
| 84 | + 'created':'>2022-11-30T23:15:04Z', |
| 85 | + 'workflow_runs':[ |
| 86 | + { |
| 87 | + 'workflow_id':4296343867, |
| 88 | + 'conclusion':'failure', |
| 89 | + 'head_branch':'master', |
| 90 | + 'actor':'vkryachko', |
| 91 | + 'created_at':'2023-02-28T18:47:40Z', |
| 92 | + 'updated_at':'2023-02-28T19:20:16Z', |
| 93 | + 'run_started_at':'2023-02-28T18:47:40Z', |
| 94 | + 'run_attempt':1, |
| 95 | + 'html_url':'https://github.com/firebase/firebase-android-sdk/actions/runs/4296343867', |
| 96 | + 'jobs_url':'https://api.github.com/repos/firebase/firebase-android-sdk/actions/runs/4296343867/jobs', |
| 97 | + 'jobs':{ |
| 98 | + 'total_count':95, |
| 99 | + 'success_count':92, |
| 100 | + 'failure_count':3, |
| 101 | + 'job_runs':[ |
| 102 | + { |
| 103 | + 'job_id':11664775180, |
| 104 | + 'job_name':'Determine changed modules', |
| 105 | + 'conclusion':'success', |
| 106 | + 'created_at':'2023-02-28T18:47:42Z', |
| 107 | + 'started_at':'2023-02-28T18:47:50Z', |
| 108 | + 'completed_at':'2023-02-28T18:50:11Z', |
| 109 | + 'run_attempt': 1, |
| 110 | + 'html_url':'https://github.com/firebase/firebase-android-sdk/actions/runs/4296343867/jobs/7487936863', |
| 111 | + } |
| 112 | + ] |
| 113 | + } |
| 114 | + } |
| 115 | + ] |
| 116 | + } |
| 117 | + ``` |
| 118 | +
|
| 119 | +- Intermediate file `job_summary.json`: contains all the job runs organized by job name. |
| 120 | + ``` |
| 121 | + { |
| 122 | + 'Unit Test Results':{ # job name |
| 123 | + 'total_count':17, |
| 124 | + 'success_count':7, |
| 125 | + 'failure_count':10, |
| 126 | + 'failure_jobs':[ # data structure is the same as same as workflow_summary['workflow_runs']['job_runs'] |
| 127 | + { |
| 128 | + 'job_id':11372664143, |
| 129 | + 'job_name':'Unit Test Results', |
| 130 | + 'conclusion':'failure', |
| 131 | + 'created_at':'2023-02-15T22:02:06Z', |
| 132 | + 'started_at':'2023-02-15T22:02:06Z', |
| 133 | + 'completed_at':'2023-02-15T22:02:06Z', |
| 134 | + 'run_attempt': 1, |
| 135 | + 'html_url':'https://github.com/firebase/firebase-android-sdk/runs/11372664143', |
| 136 | + } |
| 137 | + ] |
| 138 | + } |
| 139 | + } |
| 140 | + ``` |
| 141 | +
|
| 142 | +
|
| 143 | +# `collect_ci_test_logs.py` Script |
| 144 | +
|
| 145 | +## Usage |
| 146 | +- Collect `ci_test.yml` job failure logs from `workflow_information.py` script's intermediate file: |
| 147 | + ``` |
| 148 | + python collect_ci_test_logs.py --token ${github_toke} --folder ${folder} |
| 149 | + ``` |
| 150 | +
|
| 151 | +## Inputs |
| 152 | +
|
| 153 | +- `-t, --token`: **[Required]** GitHub access token. See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). |
| 154 | +
|
| 155 | +- `-f, --folder`: **[Required]** Folder that store intermediate files generated by `workflow_information.py`. `ci_workflow.yml` job failure logs will also be stored here. |
| 156 | +
|
| 157 | +## Outputs |
| 158 | +
|
| 159 | +- `${job name}.log`: contains job failure rate, list all failed job links and failure logs. |
| 160 | + ``` |
| 161 | + Unit Tests (:firebase-storage): |
| 162 | + Failure rate:40.00% |
| 163 | + Total count: 20 (success: 12, failure: 8) |
| 164 | + Failed jobs: |
| 165 | +
|
| 166 | + https://github.com/firebase/firebase-android-sdk/actions/runs/4296343867/jobs/7487989874 |
| 167 | + firebase-storage:testDebugUnitTest |
| 168 | + Task :firebase-storage:testDebugUnitTest |
| 169 | + 2023-02-28T18:54:38.1333725Z |
| 170 | + 2023-02-28T18:54:38.1334278Z com.google.firebase.storage.DownloadTest > streamDownloadWithResumeAndCancel FAILED |
| 171 | + 2023-02-28T18:54:38.1334918Z org.junit.ComparisonFailure at DownloadTest.java:190 |
| 172 | + 2023-02-28T18:57:20.3329130Z |
| 173 | + 2023-02-28T18:57:20.3330165Z 112 tests completed, 1 failed |
| 174 | + 2023-02-28T18:57:20.5329189Z |
| 175 | + 2023-02-28T18:57:20.5330505Z > Task :firebase-storage:testDebugUnitTest FAILED |
| 176 | + ``` |
0 commit comments