Skip to content

Commit 17e4043

Browse files
authored
feat: Add vulnerability check action & fix vulnerability advisories (#774)
* add vulnerability check actions & fix vulnerability advisories * fix assertionerror
1 parent e6cfa9b commit 17e4043

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ jobs:
5353
- name: "Run pre-commit"
5454
run: pre-commit run --all-files --show-diff-on-failure
5555

56+
vulnerabilities:
57+
name: Vulnerabilities
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: PyAnsys Vulnerability check (on main)
61+
if: github.ref == 'refs/heads/master'
62+
uses: ansys/actions/check-vulnerabilities@v8
63+
with:
64+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
65+
python-package-name: ${{ env.PACKAGE_NAME }}
66+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
67+
68+
- name: PyAnsys Vulnerability check (on dev mode)
69+
if: github.ref != 'refs/heads/master'
70+
uses: ansys/actions/check-vulnerabilities@v8
71+
with:
72+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
73+
python-package-name: ${{ env.PACKAGE_NAME }}
74+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
75+
dev-mode: true
76+
5677
tests:
5778
name: tests
5879
runs-on: ${{ matrix.os }}

src/ansys/dpf/post/result_workflows/_connect_workflow_inputs.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,14 @@ def _connect_averaging_eqv_and_principal_workflows(
180180
_WfNames.skin: _WfNames.skin,
181181
_WfNames.skin_input_mesh: _WfNames.skin_input_mesh,
182182
}
183-
assert not (
183+
184+
if (
184185
result_workflows.equivalent_workflow is not None
185186
and result_workflows.principal_workflow is not None
186-
)
187+
):
188+
raise AssertionError(
189+
"The equivalent workflow and principal workflow are both not None."
190+
)
187191

188192
principal_or_eqv_wf = (
189193
result_workflows.equivalent_workflow or result_workflows.principal_workflow
@@ -204,7 +208,11 @@ def _connect_averaging_eqv_and_principal_workflows(
204208
output_wf = result_workflows.averaging_workflow
205209

206210
else:
207-
assert principal_or_eqv_wf is not None
211+
if principal_or_eqv_wf is None:
212+
raise AssertionError(
213+
"The equivalent workflow or principal workflow is None."
214+
)
215+
208216
principal_or_eqv_wf.connect_with(
209217
result_workflows.initial_result_workflow,
210218
output_input_names={_WfNames.output_data: _WfNames.input_data},

src/ansys/dpf/post/result_workflows/_utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,19 @@ def _append_workflow(new_wf: Optional[Workflow], last_wf: Workflow):
8282
if new_wf is None:
8383
return last_wf
8484

85-
assert _WfNames.input_data in new_wf.input_names
86-
assert _WfNames.output_data in new_wf.output_names
87-
assert _WfNames.output_data in last_wf.output_names
85+
if _WfNames.input_data not in new_wf.input_names:
86+
raise AssertionError(
87+
f"Workflow {new_wf} must have an input pin {_WfNames.input_data}"
88+
)
89+
if _WfNames.output_data not in new_wf.output_names:
90+
raise AssertionError(
91+
f"Workflow {new_wf} must have an output pin {_WfNames.output_data}"
92+
)
93+
if _WfNames.output_data not in last_wf.output_names:
94+
raise AssertionError(
95+
f"Workflow {last_wf} must have an output pin {_WfNames.output_data}"
96+
)
97+
8898
new_wf.connect_with(
8999
last_wf,
90100
output_input_names={_WfNames.output_data: _WfNames.input_data},

0 commit comments

Comments
 (0)