Skip to content

Commit

Permalink
Add CI/CD configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFoxKD committed Nov 23, 2024
1 parent f88d822 commit 80590b3
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Default owners for everything in the repo
* @TheFoxKD

# Specific owners for critical parts
/src/ @TheFoxKD
/tests/ @TheFoxKD
*.toml @TheFoxKD
*.yml @TheFoxKD
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2
updates:
# Update GitHub actions in workflows
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"

# Enable version updates for Python/Pip
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
groups:
python-packages:
patterns:
- "*"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
pull_request:
branches: [ "main", "master" ]
push:
branches: [ "main", "master" ]

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pre-commit
uses: pre-commit/action@v3.0.1

pytest:
runs-on: ubuntu-latest
needs: linter
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
pytest --cov=./src --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true

type-check:
runs-on: ubuntu-latest
needs: linter
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run MyPy
run: mypy src
22 changes: 13 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ wheels/
.installed.cfg
*.egg

# Virtual Environment
# Testing
.tox/
.coverage
.coverage.*
.cache
coverage.xml
*.cover
*.py,cover
.pytest_cache/
.mypy_cache/
.venv/
env/
ENV/

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# Project specific
data/*.json
!data/.gitkeep

# OS
.DS_Store
Thumbs.db
/data/*.json
!/data/.gitkeep
/uv.lock
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Book Manager System

[![CI](https://github.com/TheFoxKD/book-manager-sys/actions/workflows/ci.yml/badge.svg)](https://github.com/TheFoxKD/book-manager-sys/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/TheFoxKD/book-manager-sys/branch/main/graph/badge.svg)](https://codecov.io/gh/TheFoxKD/book-manager-sys)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/release/python-3120/)
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)

A lightweight command-line library management system with JSON storage and intuitive CLI interface.

## Features
Expand All @@ -9,12 +14,15 @@ A lightweight command-line library management system with JSON storage and intui
- Track book availability status
- Persistent JSON storage
- Error handling and input validation
- 100% type-annotated code
- High test coverage

## Installation

```bash
git clone https://github.com/TheFoxKD/book-manager-sys.git
cd book-manager-sys
pip install -r requirements.txt
```

## Usage
Expand All @@ -23,13 +31,62 @@ cd book-manager-sys
python src/main.py
```

## Development

### Testing and Quality Assurance

The project uses several tools to ensure code quality:

- **pytest**: For unit testing
- **mypy**: For static type checking
- **ruff**: For linting and code formatting
- **pre-commit**: For automated code quality checks

### Continuous Integration

The project uses GitHub Actions for CI/CD with the following checks:

- Code linting and formatting
- Type checking
- Unit tests with coverage reporting
- Dependency updates via Dependabot

### Pre-commit Hooks

Before committing, ensure pre-commit hooks are installed:

```bash
pip install pre-commit
pre-commit install
```

### Running Tests Locally

```bash
# Run tests
pytest

# Run tests with coverage
pytest --cov=./src --cov-report=term-missing

# Run type checking
mypy src tests

# Run linting
ruff check .
```

## Requirements

- Python 3.8+
- Python 3.12+
- No external dependencies required

## Project Structure

- `src/` - Main source code
- `data/` - JSON storage
- `tests/` - Unit tests

## License

MIT

0 comments on commit 80590b3

Please sign in to comment.