Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions : Added Mypy and Python Bandit Security automation #1284

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
27 changes: 27 additions & 0 deletions .github/workflows/bandit_security_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Security check - Bandit # Name of the GitHub Actions workflow

on: [push, pull_request] # Trigger the workflow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you thinking we should run the actions on both the time we "push" changes and open "pull requests".


jobs:
build:
runs-on: ubuntu-latest # Executes the job on the latest version of Ubuntu

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point to a ubuntu version (preferably 22.04), not pinning a version might introduce regression in future

strategy:
matrix:
os: [ubuntu-latest, macos-latest] # Running matrix jobs on both Ubuntu and macOS
name: Python ${{ matrix.os }} # Name the job based on the OS being used

steps:
- uses: actions/checkout@v2 # Checks out your repository's code

- name: Security check - Bandit # Run Bandit security check
uses: ioggstream/[email protected] # Using Bandit for security checks
with:
project_path: . # Path to the project to scan
ignore_failure: true # Continue the workflow even if Bandit reports issues

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we obviously dont want to ignore errors and failures. we want the checks to fail on encountering such errors


# This step is optional, it uploads the Bandit report as an artifact
- name: Security check report artifacts
uses: actions/upload-artifact@v1
with:
name: Security report # Name of the artifact
path: output/security_report.txt # Path to the Bandit security report
28 changes: 28 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "mypy check" # Name of the GitHub Actions workflow

on: [push, pull_request] # Trigger the workflow

jobs:

static-type-check:
runs-on: ubuntu-latest # Executes the job on the latest version of Ubuntu

steps:
- uses: actions/checkout@v2 # Checks out your repository's code
- uses: actions/setup-python@v3 # Sets up Python for the job
with:
python-version: '3.x' # Specifies Python version 3.x

- run: pip install mypy # Installs mypy for static type checking, you can specify a version here

- name: Get Python changed files # Identifies changed Python files
id: changed-py-files
uses: tj-actions/changed-files@v23
with:
files: |
*.py
**/*.py

- name: Run if any of the listed files above is changed # Runs mypy on changed files
if: steps.changed-py-files.outputs.any_changed == 'true' # Conditional execution if any Python files changed
run: mypy ${{ steps.changed-py-files.outputs.all_changed_files }} --ignore-missing-imports
Loading