Skip to content

Commit

Permalink
feat: Add vulnerability check action & fix vulnerability advisories (#…
Browse files Browse the repository at this point in the history
…774)

* add vulnerability check actions & fix vulnerability advisories

* fix assertionerror
  • Loading branch information
klmcadams authored Jan 2, 2025
1 parent e6cfa9b commit 17e4043
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ jobs:
- name: "Run pre-commit"
run: pre-commit run --all-files --show-diff-on-failure

vulnerabilities:
name: Vulnerabilities
runs-on: ubuntu-latest
steps:
- name: PyAnsys Vulnerability check (on main)
if: github.ref == 'refs/heads/master'
uses: ansys/actions/check-vulnerabilities@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
python-package-name: ${{ env.PACKAGE_NAME }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}

- name: PyAnsys Vulnerability check (on dev mode)
if: github.ref != 'refs/heads/master'
uses: ansys/actions/check-vulnerabilities@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
python-package-name: ${{ env.PACKAGE_NAME }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
dev-mode: true

tests:
name: tests
runs-on: ${{ matrix.os }}
Expand Down
14 changes: 11 additions & 3 deletions src/ansys/dpf/post/result_workflows/_connect_workflow_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ def _connect_averaging_eqv_and_principal_workflows(
_WfNames.skin: _WfNames.skin,
_WfNames.skin_input_mesh: _WfNames.skin_input_mesh,
}
assert not (

if (
result_workflows.equivalent_workflow is not None
and result_workflows.principal_workflow is not None
)
):
raise AssertionError(
"The equivalent workflow and principal workflow are both not None."
)

principal_or_eqv_wf = (
result_workflows.equivalent_workflow or result_workflows.principal_workflow
Expand All @@ -204,7 +208,11 @@ def _connect_averaging_eqv_and_principal_workflows(
output_wf = result_workflows.averaging_workflow

else:
assert principal_or_eqv_wf is not None
if principal_or_eqv_wf is None:
raise AssertionError(
"The equivalent workflow or principal workflow is None."
)

principal_or_eqv_wf.connect_with(
result_workflows.initial_result_workflow,
output_input_names={_WfNames.output_data: _WfNames.input_data},
Expand Down
16 changes: 13 additions & 3 deletions src/ansys/dpf/post/result_workflows/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,19 @@ def _append_workflow(new_wf: Optional[Workflow], last_wf: Workflow):
if new_wf is None:
return last_wf

assert _WfNames.input_data in new_wf.input_names
assert _WfNames.output_data in new_wf.output_names
assert _WfNames.output_data in last_wf.output_names
if _WfNames.input_data not in new_wf.input_names:
raise AssertionError(
f"Workflow {new_wf} must have an input pin {_WfNames.input_data}"
)
if _WfNames.output_data not in new_wf.output_names:
raise AssertionError(
f"Workflow {new_wf} must have an output pin {_WfNames.output_data}"
)
if _WfNames.output_data not in last_wf.output_names:
raise AssertionError(
f"Workflow {last_wf} must have an output pin {_WfNames.output_data}"
)

new_wf.connect_with(
last_wf,
output_input_names={_WfNames.output_data: _WfNames.input_data},
Expand Down

0 comments on commit 17e4043

Please sign in to comment.