Skip to content

Commit

Permalink
Presubmit check to verify up-to-date generated Go files.
Browse files Browse the repository at this point in the history
Add presubmit detection of generated Go files that need to be
updated.

Bug: skia:13630
Change-Id: I3bc07e69f795697fb4a1d93564ce120b1eb25ca9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/569096
Reviewed-by: Kevin Lubick <[email protected]>
Commit-Queue: Chris Mumford <[email protected]>
  • Loading branch information
cmumford authored and SkCQ committed Aug 23, 2022
1 parent 3915c8c commit 322fdb0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ def _RegenerateAllExamplesCPP(input_api, output_api):
)]
return results


def _CheckOutOfDateGeneratedGo(input_api, output_api):
"""Make sure that all generated Go source are current."""
for affected_file in input_api.AffectedFiles(include_deletes=True):
affected_file_path = affected_file.LocalPath()
if affected_file_path.endswith('.go'):
return _RunCommandAndCheckGitDiff(output_api, ['go', 'generate', './...'])
return [] # No modified Go source files.

def _CheckBazelBUILDFiles(input_api, output_api):
"""Makes sure our BUILD.bazel files are compatible with G3."""
results = []
Expand Down Expand Up @@ -388,6 +397,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckGitConflictMarkers(input_api, output_api))
results.extend(_RegenerateAllExamplesCPP(input_api, output_api))
results.extend(_CheckBazelBUILDFiles(input_api, output_api))
results.extend(_CheckOutOfDateGeneratedGo(input_api, output_api))
return results


Expand Down

0 comments on commit 322fdb0

Please sign in to comment.