Add validation that all steps have a name.

This also prevents the validate_yaml script from erroring when trying to log that a step is mishandling continuous-run / continuous-prefix

PiperOrigin-RevId: 686952188
pull/18869/head
Sandy Zhang 3 months ago committed by Copybara-Service
parent 12eadfdfd9
commit 8eef2b3edc
  1. 10
      .github/scripts/validate_yaml.py
  2. 14
      .github/workflows/test_upb.yml

@ -53,15 +53,21 @@ for file in yaml_files:
continuous_condition = 'inputs.continuous-prefix' in jobs[job]['name']
steps = jobs[job]['steps']
for step in steps:
if 'name' in step:
name = step['name']
elif 'with' in step and 'name' in step['with']:
name = step['with']['name']
else:
raise ValueError('Step in job %s does not have a name.' % job)
if continuous_condition and 'continuous-run' not in step.get('if', ''):
raise ValueError(
'Step %s in job %s does not check the continuous-run condition'
% (step['name'], job)
% (name, job)
)
if not continuous_condition and 'continuous-run' in step.get('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)
% (name, job)
)
print('PASSED: All steps in all jobs check the continuous-run condition.')

@ -87,8 +87,9 @@ jobs:
uses: protocolbuffers/protobuf-ci/checkout@v3
with:
ref: ${{ inputs.safe-checkout }}
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
- name: "Setup Python"
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
cache: pip
cache-dependency-path: 'python/requirements.txt'
- name: Run tests
@ -114,7 +115,8 @@ jobs:
uses: protocolbuffers/protobuf-ci/checkout@v3
with:
ref: ${{ inputs.safe-checkout }}
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
- name: "Setup Python"
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
cache: pip
cache-dependency-path: 'python/requirements.txt'
@ -225,7 +227,8 @@ jobs:
with:
name: requirements
path: requirements
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
- name: Setup Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
python-version: ${{ matrix.python-version }}
@ -286,7 +289,8 @@ jobs:
path: wheels
- name: Delete Binary Wheels
run: find wheels -type f | grep -v none-any | xargs rm
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
- name: "Setup Python"
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ matrix.python-version }}
- name: Setup Python venv

Loading…
Cancel
Save