-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GHA tests to return single pass/fail signal at the end
Before this PR, we stored a list internally of tests that must pass on presubmit and tried to keep it up to date. This PR moves that information keeping into GitHub by adding a 'continuous-only' variable to most testing matrices to allow authors to specify which of their tests should be skipped on presubmit. During presubmit, tests that were specified to not run on presubmit will not be run and their names will be prefixed with "[SKIPPED]". All continuous only tests will be suffixed with "(Continuous)". At the end of running all the tests, we have a single "All Blocking Tests" signal that will tell us whether all of the necessary tests have passed (either for presubmit or continuous based on how the test was triggered). I've tested this from a different branch [here](https://github.com/protocolbuffers/protobuf/actions/runs/9602443750?pr=17151) and from a different fork [here](https://github.com/protocolbuffers/protobuf/actions/runs/9602554500?pr=17192). These should be the same and are as far as I can tell. I also have a continuous test run [here](https://github.com/protocolbuffers/protobuf/actions/runs/9603824200) which runs the entire test suite. Closes #17198 PiperOrigin-RevId: 659994321
- Loading branch information
1 parent
61b96dd
commit e7b928f
Showing
14 changed files
with
422 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Validate the YAML files for GitHub Actions workflows.""" | ||
|
||
import os | ||
|
||
import yaml | ||
|
||
# Ensure every job is in the list of blocking jobs. | ||
with open( | ||
os.path.join(os.path.dirname(__file__), '../workflows/test_runner.yml'), 'r' | ||
) as f: | ||
data = yaml.safe_load(f) | ||
|
||
all_jobs = data['jobs'].keys() | ||
blocking_jobs = data['jobs']['all_blocking_tests']['needs'] | ||
for job in all_jobs: | ||
if job != 'all_blocking_tests': | ||
if job not in blocking_jobs: | ||
raise ValueError( | ||
'Job %s is not in the list of blocking jobs.' | ||
% (job) | ||
) | ||
|
||
# Ensure every job with a continuous prefix conditions every step on whether we | ||
# are in a continuous run. | ||
for root, dirs, files in os.walk( | ||
os.path.join(os.path.dirname(__file__), '../workflows') | ||
): | ||
for file in files: | ||
if file.endswith('.yml'): | ||
with open(os.path.join(root, file), 'r') as f: | ||
data = yaml.safe_load(f) | ||
if 'jobs' not in data: | ||
continue | ||
jobs = data['jobs'] | ||
for job in jobs: | ||
if 'steps' not in jobs[job]: | ||
continue | ||
continuous_condition = 'inputs.continuous-prefix' in jobs[job]['name'] | ||
steps = jobs[job]['steps'] | ||
for step in steps: | ||
if 'if' in step: | ||
if continuous_condition: | ||
if 'continuous-run' not in step['if']: | ||
raise ValueError( | ||
'Step %s in job %s does not check the continuous-run ' | ||
'condition' % (step['name'], job) | ||
) | ||
elif 'continuous-run' in step['if']: | ||
raise ValueError( | ||
'Step %s in job %s checks the continuous-run condition but ' | ||
'the job does not contain the continuous-prefix' | ||
% (step['name'], job) | ||
) | ||
elif continuous_condition: | ||
raise ValueError( | ||
'Step %s in job %s does not check the continuous-run ' | ||
'condition' % (step['name'], job) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.