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

Implement GitHub Workflow for Pre-Commit Checks and Validation #113

Open
wants to merge 1 commit into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Dependency Check and Update

on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight

jobs:
dependency-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8 # Replace with your desired Python version

- name: Install pip-tools
run: |
python -m pip install --upgrade pip
pip install pip-tools

- name: Check for Updates
run: |
pip-compile --generate-hashes --output-file=requirements.txt requirements.in

- name: Commit and Push Updated Dependencies
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add requirements.txt
git commit -m "Update dependencies"
git push

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update dependencies"
branch: dependency-update
title: "Update Dependencies"
body: "Automated dependency update."
36 changes: 36 additions & 0 deletions .github/workflows/pre-commit-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pre-commit Checks

on:
push:
branches:
- '*'

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8 # Replace with your desired Python version

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest black

- name: Run Flake8 (Linting)
run: |
flake8

- name: Run pytest (Tests)
run: |
pytest

- name: Run Black (Code Formatting)
run: |
black --check . # This checks for code formatting issues without modifying files
71 changes: 71 additions & 0 deletions .github/workflows/pull-request-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Pull Request Tests

on:
pull_request:
branches:
- '*'

jobs:
pull-request-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8 # Replace with your desired Python version

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt # Adjust for your project's requirements

- name: Run Flake8 (Linting)
run: |
pip install flake8
flake8

- name: Run pytest (Unit Tests)
run: |
pip install pytest
pytest

- name: Run Black (Code Formatting Check)
run: |
pip install black
black --check . # This checks for code formatting issues without modifying files

- name: Run Mypy (Type Checking)
run: |
pip install mypy
mypy --strict .

- name: Generate Coverage Report
run: |
pip install coverage pytest-cov
pytest --cov-report term-missing --cov=your_module tests/

- name: Check Dependencies for Updates
run: |
pip install pip-tools
pip-compile --generate-hashes --output-file=requirements.txt requirements.in

- name: Check for Security Vulnerabilities
run: |
pip install safety
safety check -r requirements.txt

- name: Publish Test Results
uses: actions/upload-artifact@v2
with:
name: test-results
path: pytest.xml # Replace with the actual path to your test results XML file

- name: Publish Coverage Report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: htmlcov/ # Replace with the actual path to your coverage report directory