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

Fourth iteration #1

Merged
merged 1 commit into from
Jan 26, 2025
Merged
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
16 changes: 9 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Install Poetry and Dependencies and run tests with coverage and upload test results and coverage reports as artifacts
# Install dependencies
- name: Install Poetry and Dependencies
run: |
pip install poetry
poetry install
sudo apt-get update
sudo apt-get install make
make setup
make install

# Run unit tests with coverage
- name: Run Tests with Coverage
run: |
poetry run pytest tests/ --doctest-modules --cov=src/ --cov-report xml \
--cov-report html:htmlcov-${{ matrix.python-version }} \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
continue-on-error: true # Continue on error to upload test results and coverage reports as artifacts
make test
make coverage
continue-on-error: true

- name: Upload Test Results and Coverage Reports
uses: actions/upload-artifact@v4
Expand Down
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,38 @@ POETRY = poetry
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: setup
setup: ## Install dependencies for development (need sudo and make installed already)
sudo apt-get update
sudo apt-get install -y python3-pip
$(PIP) install poetry

.PHONY: install
install: ## Install dependencies
install: ## Install Python dependencies
$(POETRY) install

.PHONY: update
update: ## Update Python dependencies
$(POETRY) update

.PHONY: test
test: ## Run tests
test: ## Run unit tests
$(POETRY) run pytest

.PHONY: lint
lint: ## Run ruff and flake8
lint: ## Perform linting with ruff
$(POETRY) run ruff check .
$(POETRY) run flake8 .

.PHONY: format
format: ## Format code with ruff and black
format: ## Format code with ruff (not inplace by default)
$(POETRY) run ruff format .
$(POETRY) run black .

.PHONY: mypy
mypy: ## Run mypy
.PHONY: typecheck
typecheck: ## Perform typechecking with mypy
$(POETRY) run mypy .

.PHONY: clean
clean: ## Clean up generated files
clean: ## Remove temporary files and directories
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -exec rm -r {} +
rm -rf .mypy_cache
Expand All @@ -45,20 +53,20 @@ clean: ## Clean up generated files
rm -rf junit

.PHONY: coverage
coverage: ## Run tests with coverage
coverage: ## Run tests with code coverage
$(POETRY) run pytest --cov=src --cov-report=term-missing

.PHONY: build
build: ## Build the project
$(POETRY) build

.PHONY: check
check: lint mypy test ## Run lint, mypy, and tests

.PHONY: all
all: install check build ## Install dependencies, run checks, and build the project
check: lint typecheck test ## Perform linting, typechecking, and run tests

.PHONY: precommit
precommit: ## Install and run pre-commit hooks
$(POETRY) run pre-commit install
$(POETRY) run pre-commit run --all-files

.PHONY: all
all: install check build ## Install Python dependencies, run checks, and build the project
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template-python-project/
├── src/ # Source code for the project
├── models/ # ML models and related files
├── tests/ # Unit tests and test files
├── pyproject.toml # Project metadata and dependencies
├── pyproject.toml # Poetry configuration file
├── LICENSE # License information
├── README.md # Project documentation
└── Makefile # Makefile for managing common tasks like linting and testing
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ packages = [{ include = "src", from = "." }]
[tool.poetry.dependencies]
python = "^3.10"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
poetry-dynamic-versioning = "^1.4.0"
pytest = "^8.0.1"
pytest-cov = "^6.0.0"
pytest-mock = "^3.14.0"
mypy = "^1.11.1"
ruff = "^0.8.6"
black = "^24.10.0"
flake8 = "^7.1.1"
ruff = "^0.9.3"

[tool.poetry.scripts]
cli_script = "src.cli:main"
Expand Down