https://github.com/zhikhareval/python-ci
A modern Python project template with comprehensive CI/CD setup using GitHub Actions and state-of-the-art development tools.
https://github.com/zhikhareval/python-ci
allure ci code-coverage pre-commit-hook python ruff uv
Last synced: about 1 year ago
JSON representation
A modern Python project template with comprehensive CI/CD setup using GitHub Actions and state-of-the-art development tools.
- Host: GitHub
- URL: https://github.com/zhikhareval/python-ci
- Owner: ZhikharevAl
- Created: 2025-01-17T16:54:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-17T17:32:02.000Z (over 1 year ago)
- Last Synced: 2025-02-17T18:35:52.172Z (over 1 year ago)
- Topics: allure, ci, code-coverage, pre-commit-hook, python, ruff, uv
- Language: Python
- Homepage: https://zhikhareval.github.io/python-ci/
- Size: 1.23 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/ZhikharevAl/python-ci/actions/workflows/code-quality.yaml)
# Python CI Template
A modern Python project template with comprehensive CI/CD setup using GitHub Actions and state-of-the-art development tools.
## Table of Contents
- [Features](#features)
- [Project Setup](#project-setup)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Development](#development)
- [Code Quality Tools](#code-quality-tools)
- [GitHub Actions Workflow](#github-actions-workflow)
- [Pre-commit Hooks](#pre-commit-hooks)
- [Allure Reports](#allure-reports)
- [Example Allure Reports](#example-allure-reports)
- [Viewing Reports](#viewing-reports)
- [Local Report Generation](#local-report-generation)
- [Codecov Coverage](#codecov-coverage)
- [Contributing](#contributing)
## Features
- **Python 3.13+** support
- **Modern dependency management** with [uv](https://github.com/astral-sh/uv)
- **Comprehensive code quality checks**:
- Linting with [Ruff](https://github.com/astral-sh/ruff)
- Type checking with [Pyright](https://github.com/microsoft/pyright)
- Test coverage reporting with [pytest-cov](https://github.com/pytest-dev/pytest-cov)
- Code coverage tracking with [Codecov](https://codecov.io)
- **Allure Reports**: Detailed test reports with [Allure Framework](https://docs.qameta.io/allure/)
- **Pre-commit hooks** for consistent code quality
- **Automated CI/CD** with GitHub Actions
## Project Setup
### Prerequisites
- Python 3.13 or higher
- [uv](https://github.com/astral-sh/uv) package manager
### Installation
1. Clone the repository:
```bash
git clone https://github.com/ZhikharevAl/python-ci.git
cd python-ci
```
2. Create and activate a virtual environment:
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
3. Install dependencies:
```bash
uv pip install -e ".[dev]"
```
4. Install pre-commit hooks:
```bash
pre-commit install
```
## Development
### Code Quality Tools
This project uses several tools to ensure code quality:
- **Ruff**: A fast Python linter and formatter
- Configured with strict rules (see `pyproject.toml`)
- Line length set to 100 characters
- Google docstring convention
- **Pyright**: Static type checker
- Strict type checking enabled
- Compatible with Python 3.13
- **pytest**: Testing framework
- Coverage reporting enabled
- Test files should be placed in the `tests` directory
- **Allure Framework**: Generates detailed test reports
- Reports are automatically published to GitHub Pages
- Allure results are stored in the `allure-results` directory
### GitHub Actions Workflow
The CI pipeline includes the following steps:
1. **Lock file verification**
2. **Code linting**
3. **Code formatting check**
4. **Type consistency check**
5. **Unit tests with coverage reporting**
6. **Allure Report generation**:
- Test results are saved as artifacts
- Allure reports are generated and published to GitHub Pages
7. **Project build**
### Pre-commit Hooks
The following pre-commit hooks are configured:
- `uv-lock`: Ensures dependency lock file is up to date
- `ruff`: Lints and formats code
- `pyright`: Checks type consistency
- `trailing-whitespace`: Removes trailing whitespace
- `end-of-file-fixer`: Ensures files end with a newline
- `check-yaml`: Validates YAML files
## Allure Reports
This project uses [Allure Framework](https://docs.qameta.io/allure/) to generate detailed test reports. Reports are automatically published to GitHub Pages after each CI run.
## Example Allure Reports
Here are some examples of Allure reports generated by the CI pipeline:


### Viewing Reports
1. After a CI run, navigate to the **Actions** tab in your GitHub repository.
2. Find the latest workflow run and click on it.
3. Scroll down to the **Artifacts** section and download the `allure-results` artifact (if needed).
4. The Allure report is automatically published to GitHub Pages. You can view it at:
```bash
https://zhikhareval.github.io/python-ci/
```
### Local Report Generation
To generate Allure reports locally:
1. Run tests with Allure results:
```bash
uv run pytest --alluredir=allure-results
```
2. Generate and serve the report:
```bash
allure serve allure-results
```
---
## Codecov Coverage
This project uses [Codecov](https://codecov.io) to track test coverage. Below is an example of the coverage report:

---
## Contributing
Contributions are welcome! Please follow these steps:
1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Commit your changes and push to the branch.
4. Open a pull request with a detailed description of your changes.