Skip to content

Commit ad48e4c

Browse files
committed
Show error in Actions summary for safety issues in normal/scheduled runs
Details: * Safety issues that are detected in normal and scheduled Actions runs now cause an error to be shown in the Actions summary. They still (intentionally) do not cause the Actions run to fail. Note that safety issues detected during an Actions release run, or during local use, do cause the make command and Actions run to fail. * In addition, the safety command is now always run for both development and install before checking for failure. Signed-off-by: Andreas Maier <maiera@de.ibm.com>
1 parent d18923b commit ad48e4c

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,21 @@ pylint: $(done_dir)/pylint_$(pymn)_$(PACKAGE_LEVEL).done
443443

444444
.PHONY: safety
445445
safety: Makefile $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(safety_develop_policy_file) $(safety_install_policy_file) minimum-constraints-develop.txt minimum-constraints-install.txt
446-
safety check --policy-file $(safety_develop_policy_file) -r minimum-constraints-develop.txt --full-report || test '$(RUN_TYPE)' == 'normal' || test '$(RUN_TYPE)' == 'scheduled' || exit 1
447-
safety check --policy-file $(safety_install_policy_file) -r minimum-constraints-install.txt --full-report || test '$(RUN_TYPE)' == 'normal' || exit 1
446+
safety check --policy-file $(safety_develop_policy_file) -r minimum-constraints-develop.txt --full-report; \
447+
rc_dev=$$?; \
448+
safety check --policy-file $(safety_install_policy_file) -r minimum-constraints-install.txt --full-report; \
449+
rc_ins=$$?; \
450+
where=""; \
451+
if [[ $${rc_dev} -ne 0 ]]; then where="development"; fi; \
452+
if [[ $${rc_ins} -ne 0 ]]; then where="$${where:+$$where,}install"; fi; \
453+
if [[ -n $${where} ]]; then \
454+
if [[ "$(RUN_TYPE)" == "release" -o "$(RUN_TYPE)" == "local" ]]; then \
455+
echo "Safety issues found in $${where}"; \
456+
exit 1; \
457+
else \
458+
echo "::error::Safety issues found in $${where} - They need to be fixed before the next release"; \
459+
fi; \
460+
fi
448461
@echo "Makefile: $@ done."
449462

450463
.PHONY: bandit

changes/noissue.33.feature.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Dev: Safety issues that are detected in normal and scheduled Actions runs
2+
now cause an error to be shown in the Actions summary. They still
3+
(intentionally) do not cause the Actions run to fail. Note that safety issues
4+
detected during an Actions release run, or during local use, do cause the
5+
make command and Actions run to fail. In addition, the safety command is now
6+
always run for both development and install before checking for failure.

0 commit comments

Comments
 (0)