Skip to content

Commit

Permalink
Add bandit workflow (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo authored Apr 10, 2024
1 parent 4e32275 commit ed600bf
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/static_code_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Static Code Analysis

on:
release:
types: [published]
workflow_dispatch:

jobs:
code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install bandit==1.7.7
- name: Save code analysis
run: bandit -r . -x ./tests -f txt -o static_code_analysis.txt --exit-zero
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
commit-message: Update static code analysis
title: Latest Code Analysis
body: "This is an auto-generated PR with the **latest** code analysis results."
branch: static-code-analysis
branch-suffix: short-commit-hash
base: main
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ namespaces = false
'*' = [
'* __pycache__',
'*.py[co]',
'static_code_analysis.txt',
]

[tool.bumpversion]
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _get_minimum_versions(dependencies, python_version):
for dependency in dependencies:
if '@' in dependency:
name, url = dependency.split(' @ ')
min_versions[name] = f'{name} @ {url}'
min_versions[name] = f'{url}#egg={name}'
continue

req = Requirement(dependency)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Tests for the ``tasks.py`` file."""

from tasks import _get_minimum_versions


Expand All @@ -14,7 +16,7 @@ def test_get_minimum_versions():
"pandas>=1.2.0,<2;python_version<'3.10'",
"pandas>=1.3.0,<2;python_version>='3.10'",
'humanfriendly>=8.2,<11',
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas'
'pandas @ git+https://github.com/pandas-dev/pandas.git@master',
]

# Run
Expand All @@ -24,12 +26,12 @@ def test_get_minimum_versions():
# Assert
expected_versions_39 = [
'numpy==1.20.0',
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
'git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
'humanfriendly==8.2',
]
expected_versions_310 = [
'numpy==1.23.3',
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
'git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
'humanfriendly==8.2',
]

Expand Down

0 comments on commit ed600bf

Please sign in to comment.