|
19 | 19 |
|
20 | 20 | # Number of days to look back for new commits |
21 | 21 | # We allow some buffer time between when a commit is made and when it is queried |
22 | | -# for reviews. This is allow time for any events to propogate in the GitHub |
23 | | -# Archive BigQuery tables. |
| 22 | +# for reviews. This is to allow time for any new GitHub events to propogate. |
24 | 23 | LOOKBACK_DAYS = 2 |
25 | 24 |
|
26 | 25 | # Template GraphQL subquery to check if a commit has an associated pull request |
|
57 | 56 | class LLVMCommitInfo: |
58 | 57 | commit_sha: str |
59 | 58 | commit_timestamp_seconds: int |
60 | | - files_modified: set[str] |
| 59 | + diff: list[dict[str, int | str]] |
61 | 60 | commit_author: str = "" # GitHub username of author is unknown until API call |
62 | 61 | has_pull_request: bool = False |
63 | 62 | pull_request_number: int = 0 |
@@ -117,7 +116,15 @@ def query_for_reviews( |
117 | 116 | commit.hexsha: LLVMCommitInfo( |
118 | 117 | commit_sha=commit.hexsha, |
119 | 118 | commit_timestamp_seconds=commit.committed_date, |
120 | | - files_modified=set(commit.stats.files.keys()), |
| 119 | + diff=[ |
| 120 | + { |
| 121 | + "file": file, |
| 122 | + "additions": line_stats["insertions"], |
| 123 | + "deletions": line_stats["deletions"], |
| 124 | + "total": line_stats["lines"], |
| 125 | + } |
| 126 | + for file, line_stats in commit.stats.files.items() |
| 127 | + ], |
121 | 128 | ) |
122 | 129 | for commit in new_commits |
123 | 130 | } |
@@ -210,7 +217,10 @@ def upload_daily_metrics_to_bigquery( |
210 | 217 | ) |
211 | 218 | table = bq_client.get_table(table_ref) |
212 | 219 | commit_records = [dataclasses.asdict(commit) for commit in new_commits] |
213 | | - bq_client.insert_rows(table, commit_records) |
| 220 | + errors = bq_client.insert_rows(table, commit_records) |
| 221 | + if errors: |
| 222 | + logging.error("Failed to upload commit info to BigQuery: %s", errors) |
| 223 | + exit(1) |
214 | 224 |
|
215 | 225 |
|
216 | 226 | def main() -> None: |
|
0 commit comments