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

Feat add hatch #30

Merged
merged 7 commits into from
Feb 25, 2024
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
8 changes: 0 additions & 8 deletions .bumpversion.cfg

This file was deleted.

44 changes: 26 additions & 18 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,54 @@

## Setting up development environment

You can install the development environment, i.e. all the dependencies required to run all tests and checks that are run when you submit a PR, by running. There are two main ways of doing this, one is to do it without cloning the repository, and the other is to clone the repository and then install the dependencies.
You can install the development environment, i.e. all the dependencies required to run all tests and checks that are run when you submit a PR, by following these steps:

1. [Install](https://hatch.pypa.io/1.9/install/#installation) `hatch`.
2. Clone the repository:
```bash
git clone https://github.com/manmartgarc/stochatreat
cd stochatreat
```
3. Confirm `hatch` picked up the project:
```bash
hatch status
```

### Without cloning the repository

```bash
pip install "stochatreat[dev] @ git+https://github.com/manmartgarc/stochatreat"
```
## Tests

### Cloning the repository
To run tests in the default environment:

```bash
git clone https://github.com/manmartgarc/stochatreat
cd stochatreat
pip install -e .[dev]
hatch run default:test
```

## Tests

To run tests run:
To run tests in all environments:

```bash
make test
hatch run all:test
```

## Format

When submitting a PR, the CI will run `make format` and also `make lint` to check the format of the code. You can run this locally by running:

```bash
make format lint
hatch fmt
```

## Release

- Run `bump2version` to update the version number in the `setup.py` file and create a new tag:
- Run `hatch` to update the version number file and create a new tag:

```bash
bump2version [major|minor|patch]
hatch version [major|minor|patch]
```

- Commit the changes and push them to your fork.
- Tag the new version:
```bash
git tag -a v0.0.0 -m "v0.0.0"
git push origin v0.0.0
```
- Submit a PR.
- Once the PR is merged, run `make release` to create a new release in GitHub.
- Once the PR is merged, run `hatch publish` to create a new release in PyPI.
22 changes: 9 additions & 13 deletions .github/workflows/test.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: test
name: Release CI

on:
push:
Expand All @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -23,22 +23,18 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
- name: Install hatch
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint with Ruff
python -m pip install hatch
- name: Check lint and format
run: |
make lint
- name: Check format with Black
run: |
make format
hatch fmt --check
- name: Type-checking with Mypy
run: |
make test/mypy
- name: Test with pytest
hatch run types:check
- name: Run tests with pytest
run: |
make test/pytest
hatch run +py=${{ matrix.python-version }} all:test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
55 changes: 0 additions & 55 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

| | |
|---|---|
|Build|[![Main Branch Tests](https://github.com/manmartgarc/stochatreat/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/manmartgarc/stochatreat/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/manmartgarc/stochatreat/graph/badge.svg?token=llPoW2rWIN)](https://codecov.io/gh/manmartgarc/stochatreat)
|Build|[![Main Branch Tests](https://github.com/manmartgarc/stochatreat/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/manmartgarc/stochatreat/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/manmartgarc/stochatreat/graph/badge.svg?token=llPoW2rWIN)](https://codecov.io/gh/manmartgarc/stochatreat)
|PyPI| [![pypi](https://img.shields.io/pypi/v/stochatreat?logo=pypi)](https://pypi.org/project/stochatreat/) ![pypi-downloads](https://img.shields.io/pypi/dm/stochatreat?logo=pypi)
|conda-forge| [![Conda](https://img.shields.io/conda/v/conda-forge/stochatreat?logo=conda-forge)](https://anaconda.org/conda-forge/stochatreat) ![conda-downloads](https://img.shields.io/conda/dn/conda-forge/stochatreat?logo=conda-forge)
|Meta| [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code format - Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)
|Meta| [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)

---

Expand Down
81 changes: 55 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "stochatreat"
version = "0.0.16"
dynamic = ["version"]
description = 'Stratified random assignment using pandas'
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -23,48 +23,77 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
]
dependencies = ["pandas"]

[project.optional-dependencies]
dev = ["black", "build", "bump2version", "mypy", "ruff", "pytest", "pytest-cov"]

[project.urls]
Documentation = "https://github.com/manmartgarc/stochatreat/blob/main/README.md"
Issues = "https://github.com/manmartgarc/stochatreat/issues"
Source = "https://github.com/manmartgarc/stochatreat/"

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests"]
namespaces = false
[tool.hatch.version]
path = "src/stochatreat/__about__.py"

[tool.hatch.envs.default]
dependencies = [
"pytest",
"coverage[toml]>=6.5",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
]
cov = [
"test-cov",
"cov-report"
]

[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.types]
dependencies = ["mypy>=1.0.0"]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/stochatreat tests}"

[tool.coverage.run]
source_pkgs = ["stochatreat", "tests"]
branch = true
parallel = true
omit = [
"src/stochatreat/__about__.py",
]

[tool.coverage.paths]
stochatreat = ["src/stochatreat", "*/stochatreat/src/stochatreat"]
tests = ["tests", "*/stochatreat/tests"]

[tool.setuptools.package-data]
stochatreat = ["py.typed"]
[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHEKCING"
]

[tool.black]
[tool.ruff]
line-length = 79

[tool.ruff.lint]
ignore = [
"TRY003"
]

[tool.mypy]
python_version = 3.8
files = ["src", "tests"]
check_untyped_defs = true
show_error_codes = true
pretty = true
ignore_missing_imports = true

[tool.ruff]
line-length = 79
target-version = "py38"

[tool.pytest.ini_options]
addopts = [
"--cov=stochatreat",
"--cov-branch",
"--cov-report=term-missing",
"--durations=5",
]
2 changes: 1 addition & 1 deletion src/stochatreat/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.14"
__version__ = "0.0.17"
13 changes: 0 additions & 13 deletions src/stochatreat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 10 12:16:55 2019

===============================================================================
@author: Manuel Martinez
@project: stochatreat
===============================================================================
"""
from stochatreat.stochatreat import stochatreat # noqa: F401

__version__ = "0.0.14"
__author__ = "Manuel Martinez"
Loading
Loading