mirror of
https://github.com/certbot/certbot.git
synced 2026-05-23 02:37:13 -04:00
Fixes #10617 I restructured the conditionals to avoid too much nesting. This should have the same effect, just with the additional check conditioned on all the target snap files being available. Here is the logic I used for the restructuring: start ```python dump_output = exit_code != 0 or failed_archs if exit_code == 0 and not failed_archs: # We expect to have all target snaps available, or something bad happened. snaps_list = glob.glob(join(workspace, '*.snap')) if not len(snaps_list) == len(archs): print('Some of the expected snaps for a successful build are missing ' f'(current list: {snaps_list}).') dump_output = True else: build_success = True break ``` note that `(exit_code == 0 and not failed_archs) == not (exit_code != 0 or failed_archs) == not dump_output` ```python dump_output = exit_code != 0 or failed_archs if not dump_output: # We expect to have all target snaps available, or something bad happened. snaps_list = glob.glob(join(workspace, '*.snap')) if not len(snaps_list) == len(archs): print('Some of the expected snaps for a successful build are missing ' f'(current list: {snaps_list}).') dump_output = True else: build_success = True break ``` distribute the if ```python dump_output = exit_code != 0 or failed_archs snaps_list = glob.glob(join(workspace, '*.snap')) if not dump_output and (not len(snaps_list) == len(archs)): # We expect to have all target snaps available, or something bad happened. print('Some of the expected snaps for a successful build are missing ' f'(current list: {snaps_list}).') dump_output = True if not dump_output and (len(snaps_list) == len(archs)): # redundant; if it were false, we would have changed dump_output right above this build_success = True break ``` remove redundant check ```python dump_output = exit_code != 0 or failed_archs snaps_list = glob.glob(join(workspace, '*.snap')) if not dump_output and (not len(snaps_list) == len(archs)): # We expect to have all target snaps available, or something bad happened. print('Some of the expected snaps for a successful build are missing ' f'(current list: {snaps_list}).') dump_output = True if not dump_output: build_success = True break ``` As this shows, we can now add additional checks that only happen if we think we're in danger of succeeding based on checks thus far, and simply change `dump_output` to `True` if the additional check fails. You can see the build step failing when the [file contains html](https://github.com/certbot/certbot/compare/html-problem...refs/heads/test-html-problem-2) at https://github.com/certbot/certbot/actions/runs/26071811878/job/76654623490#step:5:42 |
||
|---|---|---|
| .. | ||
| docker | ||
| pinning | ||
| snap | ||
| _release.sh | ||
| extract_changelog.py | ||
| finish_release.py | ||
| notify_mattermost.py | ||
| oldest_constraints.txt | ||
| pip_install.py | ||
| pipstrap.py | ||
| release.sh | ||
| requirements.txt | ||
| retry.sh | ||
| sphinx-quickstart.sh | ||
| venv.py | ||