Skip to content

Commit c1efb4a

Browse files
authored
v0.3.0 (#3)
* Replace setup.cfg by pyproject.toml * Add pre-commit hooks and resolve detected issues * Add make file for init, test, and clean * Add CI and release workflows * Update docs and add contributing guidance * support 3.9+ only
1 parent 6b69247 commit c1efb4a

15 files changed

Lines changed: 564 additions & 164 deletions

.github/workflows/ci.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
19+
- name: Set up Python 3.12
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.12'
23+
24+
- name: Run pre-commit hooks
25+
uses: pre-commit/action@v3.0.1
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
needs: lint
30+
strategy:
31+
matrix:
32+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v5
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install test dependencies
43+
run: pip install pytest
44+
45+
- name: Run tests
46+
run: python -m pytest
47+
48+
build:
49+
runs-on: ubuntu-latest
50+
needs: test
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v5
54+
55+
- name: Set up Python 3.12
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: '3.12'
59+
60+
- name: Install build dependencies
61+
run: pip install build twine
62+
63+
- name: Build package
64+
run: python -m build
65+
66+
- name: Check package
67+
run: twine check dist/*

.github/workflows/release.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
id-token: write
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Set up Python 3.12
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install build dependencies
23+
run: pip install build
24+
25+
- name: Build package
26+
run: python -m build
27+
28+
- name: Release to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
31+
- name: Create tag
32+
run: |
33+
VERSION=$(python -c "import timerun; print(timerun.__version__)")
34+
git tag "v$VERSION"
35+
git push origin "v$VERSION"

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
repos:
2+
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: fix-byte-order-marker
8+
- id: mixed-line-ending
9+
args:
10+
- --fix=lf
11+
- id: check-yaml
12+
- id: check-toml
13+
14+
- repo: https://github.com/adrienverge/yamllint
15+
rev: v1.37.1
16+
hooks:
17+
- id: yamllint
18+
19+
- repo: https://github.com/pycqa/isort
20+
rev: 6.0.1
21+
hooks:
22+
- id: isort
23+
24+
- repo: https://github.com/psf/black
25+
rev: 25.1.0
26+
hooks:
27+
- id: black
28+
29+
- repo: https://github.com/pre-commit/mirrors-mypy
30+
rev: v1.17.1
31+
hooks:
32+
- id: mypy
33+
34+
- repo: https://github.com/pylint-dev/pylint
35+
rev: v3.3.8
36+
hooks:
37+
- id: pylint
38+
additional_dependencies:
39+
- pytest
40+
41+
- repo: https://github.com/pycqa/bandit
42+
rev: '1.8.6'
43+
hooks:
44+
- id: bandit
45+
args: ['-c', 'pyproject.toml']

CONTRIBUTING.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Contributing to TimeRun
2+
3+
Thank you for your interest in contributing to TimeRun! This document provides guidelines for contributing to the project.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Python 3.9 or higher
10+
- Git
11+
12+
### Development Setup
13+
14+
1. Fork the repository on GitHub
15+
2. Clone your fork locally:
16+
```bash
17+
git clone https://github.com/YOUR_USERNAME/timerun.git
18+
cd timerun
19+
```
20+
21+
3. Set up the development environment:
22+
```bash
23+
make init
24+
```
25+
26+
4. Activate the virtual environment:
27+
```bash
28+
source .venv/bin/activate
29+
```
30+
31+
## Development Workflow
32+
33+
### Running Tests
34+
35+
Run the test suite with coverage:
36+
```bash
37+
make test
38+
```
39+
40+
### Code Style
41+
42+
This project follows these code style guidelines:
43+
- **Black** for code formatting (line length: 79 characters)
44+
- **isort** for import sorting
45+
46+
Pre-commit hooks are installed automatically with `make init` and will run on every commit. You can also run them manually:
47+
```bash
48+
pre-commit run --all-files
49+
```
50+
51+
### Making Changes
52+
53+
1. Create a new branch for your feature or bugfix:
54+
```bash
55+
git checkout -b feature/your-feature-name
56+
```
57+
58+
2. Make your changes following the project conventions
59+
3. Add or update tests as needed
60+
4. Ensure all tests pass: `make test`
61+
5. Commit your changes with a clear message
62+
63+
### Submitting Changes
64+
65+
1. Push your branch to your fork:
66+
```bash
67+
git push origin feature/your-feature-name
68+
```
69+
70+
2. Create a pull request on GitHub with:
71+
- Clear description of the changes
72+
- Reference to any related issues
73+
- Test coverage for new functionality
74+
75+
## Project Structure
76+
77+
- `timerun.py` - Main library code (single file module)
78+
- `tests/` - Test suite
79+
- `pyproject.toml` - Project configuration and dependencies
80+
- `Makefile` - Development commands
81+
82+
## Guidelines
83+
84+
### Code Quality
85+
86+
- Maintain 100% test coverage for new code
87+
- Follow existing code patterns and conventions
88+
- Add docstrings for all public functions and classes
89+
- Use type hints consistently
90+
91+
### Testing
92+
93+
- Write tests for all new functionality
94+
- Use descriptive test names
95+
- Test both success and error cases
96+
- Keep tests focused and independent
97+
98+
### Documentation
99+
100+
- Update docstrings for any API changes
101+
- Add examples for new features
102+
- Update README.md if needed
103+
104+
## Reporting Issues
105+
106+
When reporting bugs or requesting features:
107+
108+
1. Check existing issues first
109+
2. Use the issue templates if available
110+
3. Provide clear reproduction steps for bugs
111+
4. Include Python version and environment details
112+
113+
## Questions?
114+
115+
Feel free to open an issue for questions about contributing or reach out to the maintainers.
116+
117+
## License
118+
119+
By contributing to TimeRun, you agree that your contributions will be licensed under the MIT License.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019-2021 HH-MWB
3+
Copyright (c) 2019-2025 HH-MWB
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Makefile for Timerun
2+
# Description: Development environment setup and project management
3+
# Requirements: Python 3, pip
4+
5+
.DEFAULT_GOAL := help
6+
7+
# Project configuration
8+
VENV_DIR := .venv
9+
10+
.PHONY: help
11+
help: ## Show this help message
12+
@echo "Available targets:"
13+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
14+
awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
15+
16+
.PHONY: init
17+
init: ## Set up Python development environment with pre-commit hooks
18+
@test -d "$(VENV_DIR)" || python3 -m venv "$(VENV_DIR)" >/dev/null 2>&1
19+
@"$(VENV_DIR)/bin/pip" install -e ".[dev]" >/dev/null 2>&1
20+
@"$(VENV_DIR)/bin/pip" install pre-commit >/dev/null 2>&1
21+
@"$(VENV_DIR)/bin/pre-commit" install >/dev/null 2>&1
22+
@echo "Development environment ready! To activate it, run: source $(VENV_DIR)/bin/activate"
23+
24+
.PHONY: test
25+
test: ## Run all tests and display coverage ratio
26+
@"$(VENV_DIR)/bin/pytest" tests/ --cov=timerun --cov-report=term-missing
27+
28+
.PHONY: clean
29+
clean: ## Delete all temporary files including venv
30+
@rm -rf "$(VENV_DIR)" *.egg-info
31+
@rm -rf .mypy_cache .pytest_cache .coverage htmlcov
32+
@find . -name "*.pyc" -delete
33+
@find . -name "__pycache__" -type d -exec rm -rf {} +

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@
1616

1717
TimeRun is a simple, yet elegant elapsed time measurement library for [Python](https://www.python.org). It is distributed as a single file module and has no dependencies other than the [Python Standard Library](https://docs.python.org/3/library/).
1818

19-
- **Elapsed Time**: Customized time delta which represents elapsed time in nanoseconds.
20-
- **Stopwatch**: An elapsed time measurer with the highest available resolution.
21-
- **Timer**: Convenient syntax to capture measured elapsed time result and save it.
19+
- **Elapsed Time**: Customized time delta which represents elapsed time in nanoseconds
20+
- **Stopwatch**: An elapsed time measurer with the highest available resolution
21+
- **Timer**: Convenient syntax to capture and save measured elapsed time results
2222

2323
## Setup
2424

2525
### Prerequisites
2626

27-
The only prerequisite to use TimeRun is running **Python 3.7+**.
27+
The only prerequisite to use TimeRun is running **Python 3.9+**.
2828

2929
### Installation
3030

3131
Install TimeRun from [Python Package Index](https://pypi.org/project/timerun/):
3232

33-
```
33+
```bash
3434
pip install timerun
3535
```
3636

3737
Install TimeRun from [Source Code](https://github.com/HH-MWB/timerun):
3838

39-
```
40-
python setup.py install
39+
```bash
40+
pip install git+https://github.com/HH-MWB/timerun.git
4141
```
4242

4343
## Quickstart
@@ -65,6 +65,10 @@ python setup.py install
6565
0:00:00.000000100
6666
```
6767

68+
## Contributing
69+
70+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.
71+
6872
## License
6973

7074
This project is licensed under the MIT License - see the [LICENSE](https://github.com/HH-MWB/timerun/blob/master/LICENSE) file for details.

0 commit comments

Comments
 (0)