Skip to content

Feature/test branch #3

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E501
exclude = tests/* src/*
137 changes: 84 additions & 53 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,118 @@
# Name of the GitHub Actions workflow
name: Python Virtual Environment Setup CI
name: Python Virtual Environment Creator Tests

# Define when this workflow should run
# Define when this workflow should be triggered
on:
# Trigger on push events to main and develop branches
push:
branches: [ main ] # Trigger on pushes to main branch
branches: [ main, develop ]
# Trigger on pull requests to main and develop branches
pull_request:
branches: [ main ] # Trigger on pull requests to main branch
branches: [ main, develop ]

# Define the jobs to run
# Define the jobs to run as part of this workflow
jobs:
# First job: testing across different OS and Python versions
# Job for running tests across different environments
test:
# Dynamic OS selection based on matrix strategy
# Dynamic name showing OS and Python version being tested
name: Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
# OS to run the job on, pulled from matrix strategy
runs-on: ${{ matrix.os }}
strategy:
# Continue running other matrix combinations even if one fails
fail-fast: false
# Define test matrix - will run tests on all combinations of these
matrix:
# Define test matrix: will run tests on all combinations of these
os: [ubuntu-latest, windows-latest, macos-latest] # Test on all major OS
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] # Test on multiple Python versions
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
# Step 1: Check out the repository code
# Check out the repository code
- uses: actions/checkout@v3
# Step 2: Set up Python environment

# Set up Python environment with specified version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# Step 3: Install required Python packages
architecture: x64

# Install required Python packages for testing
- name: Install dependencies
run: |
python -m pip install --upgrade pip # Upgrade pip to latest version
pip install pytest pytest-cov flake8 # Install testing and linting tools

# Step 4: Run code quality checks with flake8
- name: Lint with flake8
run: |
# Check for specific critical errors
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Check overall code quality
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics

# Step 5: Create a test virtual environment
- name: Create test virtual environment
python -m pip install --upgrade pip
pip install -r requirements.txt

# Run static type checking with mypy in strict mode
- name: Run type checking
run: |
python -m venv test_venv
# Step 6: Run tests with coverage reporting
- name: Test VenvCreator
mypy src tests

# Run tests with pytest and generate coverage report
- name: Run tests with coverage
run: |
pytest --cov=. --cov-report=xml # Run tests and generate coverage report
# Step 7: Upload coverage reports to Codecov
pytest tests -v --cov=src. --cov-report=xml

# Upload test coverage data to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml # Coverage report file
flags: unittests # Tag these results as unit tests
fail_ci_if_error: true # Fail if upload to Codecov fails
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
fail_ci_if_error: false

# Job for code linting checks
lint:
name: Lint
runs-on: ubuntu-latest
steps:
# Check out repository code
- uses: actions/checkout@v3

# Set up Python 3.11 environment for linting
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

# Install linting tools
- name: Install dependencies
run: |
python -m pip install -r requirements.txt

# Second job: security scanning
# Run various linting checks:
# - flake8 for code style and errors
# - black for code formatting
# - isort for import sorting
- name: Run linters # noqa: E501
run: |
flake8 src tests
black src tests --check
isort src tests --check-only --profile black # noqa: E501

# Job for security vulnerability scanning
security:
runs-on: ubuntu-latest # Security checks only need to run on one OS
name: Security checks
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository code
# Check out repository code
- uses: actions/checkout@v3
# Step 2: Set up Python environment

# Set up Python 3.11 environment for security checks
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Use Python 3.10 for security checks
# Step 3: Install security scanning tools
- name: Install security scanning tools
python-version: '3.11'

# Install security scanning tools
- name: Install dependencies
run: |
pip install bandit safety # bandit for code scanning, safety for dependency checking

# Step 4: Run security scans
- name: Run security scan
python -m pip install -r requirements.txt

# Run security checks:
# - bandit for code security issues
# - safety for known vulnerabilities in dependencies
- name: Run security checks
run: |
bandit -r . # Recursively scan all Python files for security issues
safety check # Check dependencies for known security vulnerabilities
bandit -r src tests
162 changes: 162 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
Loading
Loading