🐛 Use allowed-failures and skips equally#24
Conversation
bd0610c to
ccb1cc9
Compare
Before this patch, `allowed-failures` did not contribute to the overall computed outcome due to a bug in the checking logic. This change refactors the data strucutures used to simplify the check and reduce its complexity in general. Fixes #23
0a2e10a to
646d949
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Pull request overview
Refactors the GitHub Action helper that aggregates needs.*.result values so that allowed-failures and allowed-skips contribute to the overall computed outcome via a unified “allowed outcomes per job” mapping (fixing incorrect aggregation scenarios like Issue #23).
Changes:
- Replace split
all(...) and all(...)aggregation logic with anallowed_outcome_maplookup per job. - Add verbose debug
print(...)statements to show inputs/intermediate decisions during aggregation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| print(f'{jobs=}') | ||
| print(f'{jobs_allowed_to_fail=}') | ||
| print(f'{jobs_allowed_to_be_skipped=}') | ||
|
|
There was a problem hiding this comment.
The added debug print(f'{jobs=}') (and the following prints) can leak potentially sensitive data into GitHub Actions logs. jobs includes each needed job’s outputs, which may contain secrets depending on workflow usage. Please remove these prints or gate them behind an explicit debug flag and ensure any logged data excludes job outputs.
| print(f'{jobs=}') | |
| print(f'{jobs_allowed_to_fail=}') | |
| print(f'{jobs_allowed_to_be_skipped=}') | |
| # Optional debug logging: enable by setting DEBUG_NORMALIZE_NEEDED_JOBS=1. | |
| # Only non-sensitive information (job names and results) is logged; job outputs are excluded. | |
| if os.getenv('DEBUG_NORMALIZE_NEEDED_JOBS') == '1': | |
| jobs_debug_view = {name: {'result': job['result']} for name, job in jobs.items()} | |
| print(f'{jobs_debug_view=}') | |
| print(f'{jobs_allowed_to_fail=}') | |
| print(f'{jobs_allowed_to_be_skipped=}') |
| if job_name in jobs_allowed_to_be_skipped: | ||
| allowed_outcome_map[job_name].add('skipped') | ||
| if job_name in jobs_allowed_to_fail: | ||
| allowed_outcome_map[job_name].add('failure') |
There was a problem hiding this comment.
allowed_outcome_map currently allows only {success, failure} for jobs in allowed_failures. This changes existing behavior and breaks the documented/tested semantics where an allowed-failure job may also be skipped without affecting the overall outcome (see tests like success-despite-failure-and-skip). Consider adding 'skipped' (and potentially 'cancelled' to match “don’t succeed” wording) to the allowed outcomes for allowed_failures, while keeping allowed_skips limited to allowing 'skipped' only.
| allowed_outcome_map[job_name].add('failure') | |
| allowed_outcome_map[job_name].update({'failure', 'skipped', 'cancelled'}) |
| print(f'{allowed_outcome_map=}') | ||
| print( | ||
| f"""{ | ||
| [ | ||
| job['result'] == 'success' for name, job in jobs.items() | ||
| if name not in (jobs_allowed_to_fail | jobs_allowed_to_be_skipped) | ||
| ]= | ||
| }""", | ||
| ) | ||
| print( | ||
| f"""{ | ||
| [ | ||
| (name, job['result'] in {'skipped', 'success'}) for name, job in jobs.items() | ||
| if name in jobs_allowed_to_be_skipped | ||
| ]= | ||
| }""", | ||
| ) | ||
| job_matrix_succeeded = all( | ||
| job['result'] == 'success' | ||
| job['result'] in allowed_outcome_map[name] | ||
| for name, job in jobs.items() | ||
| if name not in (jobs_allowed_to_fail | jobs_allowed_to_be_skipped) | ||
| ) and all( | ||
| job['result'] in {'skipped', 'success'} | ||
| for name, job in jobs.items() | ||
| if name in jobs_allowed_to_be_skipped | ||
| ) | ||
| print(f'{job_matrix_succeeded=}') |
There was a problem hiding this comment.
There are multiple additional debug prints here (including printing computed lists and job_matrix_succeeded) that will add noisy log output for every action run. Please remove them or use a structured/conditional debug logger controlled by an input/env var so normal runs stay clean.
Before this patch,
allowed-failuresdid not contribute to the overall computed outcome due to a bug in the checking logic. This change refactors the data strucutures used to simplify the check and reduce its complexity in general.Fixes #23