Skip to content

Commit ed600bf

Browse files
authored
Add bandit workflow (#393)
1 parent 4e32275 commit ed600bf

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Static Code Analysis
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
code-analysis:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: '3.10'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install bandit==1.7.7
21+
- name: Save code analysis
22+
run: bandit -r . -x ./tests -f txt -o static_code_analysis.txt --exit-zero
23+
- name: Create pull request
24+
id: cpr
25+
uses: peter-evans/create-pull-request@v4
26+
with:
27+
token: ${{ secrets.GH_ACCESS_TOKEN }}
28+
commit-message: Update static code analysis
29+
title: Latest Code Analysis
30+
body: "This is an auto-generated PR with the **latest** code analysis results."
31+
branch: static-code-analysis
32+
branch-suffix: short-commit-hash
33+
base: main

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ namespaces = false
173173
'*' = [
174174
'* __pycache__',
175175
'*.py[co]',
176+
'static_code_analysis.txt',
176177
]
177178

178179
[tool.bumpversion]

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _get_minimum_versions(dependencies, python_version):
6666
for dependency in dependencies:
6767
if '@' in dependency:
6868
name, url = dependency.split(' @ ')
69-
min_versions[name] = f'{name} @ {url}'
69+
min_versions[name] = f'{url}#egg={name}'
7070
continue
7171

7272
req = Requirement(dependency)

tests/test_tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Tests for the ``tasks.py`` file."""
2+
13
from tasks import _get_minimum_versions
24

35

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

2022
# Run
@@ -24,12 +26,12 @@ def test_get_minimum_versions():
2426
# Assert
2527
expected_versions_39 = [
2628
'numpy==1.20.0',
27-
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
29+
'git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
2830
'humanfriendly==8.2',
2931
]
3032
expected_versions_310 = [
3133
'numpy==1.23.3',
32-
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
34+
'git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
3335
'humanfriendly==8.2',
3436
]
3537

0 commit comments

Comments
 (0)