Skip to content

Commit 9ba82e3

Browse files
authored
ci: switch to hatch (#297)
switch to hatch Signed-off-by: gruebel <[email protected]>
1 parent 47ae16c commit 9ba82e3

File tree

6 files changed

+53
-97
lines changed

6 files changed

+53
-97
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ jobs:
3434
python-version: ${{ matrix.python-version }}
3535
cache: "pip"
3636

37-
- name: Install dependencies
38-
run: pip install -r requirements.txt
37+
- name: Install hatch
38+
run: pip install hatch
3939

4040
- name: Test with pytest
41-
run: coverage run --omit="*/test*" -m pytest
41+
run: hatch run cov
4242

4343
- name: Run E2E tests with behave
44-
run: |
45-
cp test-harness/features/evaluation.feature tests/features/
46-
behave tests/features/
44+
run: hatch run e2e
4745

4846
- name: Upload coverage to Codecov
4947
uses: codecov/codecov-action@v3

.github/workflows/release.yml

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,14 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@v4
4747

48-
- name: Cache virtualenvironment
49-
uses: actions/cache@v4
50-
with:
51-
path: ~/.venv
52-
key: ${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}
53-
5448
- name: Upgrade pip
5549
run: pip install --upgrade pip
5650

57-
- name: Create and activate Virtualenv
58-
run: |
59-
[ ! -d ".venv" ] && python -m venv .venv
60-
. .venv/bin/activate
61-
62-
- name: Install dependencies
63-
run: pip install -r requirements.txt
64-
65-
- name: Install pypa/build
66-
run: >-
67-
python -m
68-
pip install
69-
build
70-
--user
51+
- name: Install hatch
52+
run: pip install hatch
7153

7254
- name: Build a binary wheel and a source tarball
73-
run: >-
74-
python -m
75-
build
76-
--sdist
77-
--wheel
78-
--outdir dist/
79-
.
55+
run: hatch build
8056

8157
- name: Publish a Python distribution to PyPI
8258
uses: pypa/gh-action-pypi-publish@release/v1

CONTRIBUTING.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ Python 3.8 and above are supported by the SDK.
1212

1313
### Installation and Dependencies
1414

15-
A [`Makefile`](./Makefile) has been included in the project which should make it straightforward to start the project locally. We utilize virtual environments (see [`venv`](https://docs.python.org/3/tutorial/venv.html)) in order to provide isolated development environments for the project. This reduces the risk of invalid or corrupt global packages. It also integrates nicely with Make, which will detect changes in the `requirements.txt` file and update the virtual environment if any occur.
15+
We use [Hatch](https://hatch.pypa.io/) to manage the project.
1616

17-
Run `make init` to initialize the project's virtual environment and install all dev dependencies.
17+
To install Hatch, just run `pip install hatch`.
18+
19+
You will also need to set up the `pre-commit` hooks.
20+
Run `pre-commit install` in the root directory of the repository.
21+
If you don't have `pre-commit` installed, you can install it with `pip install pre-commit`.
1822

1923
### Testing
2024

21-
Run tests with `make test`.
25+
Run tests with `hatch run test`.
2226

2327
We use `pytest` for our unit testing, making use of `parametrized` to inject cases at scale.
2428

@@ -55,7 +59,7 @@ git remote add fork https://github.com/YOUR_GITHUB_USERNAME/python-sdk.git
5559
Ensure your development environment is all set up by building and testing
5660

5761
```bash
58-
make
62+
hatch run test
5963
```
6064

6165
To start working on a new feature or bugfix, create a new branch and start working on it.

Makefile

Lines changed: 0 additions & 47 deletions
This file was deleted.

pyproject.toml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pyproject.toml
22
[build-system]
3-
requires = ["setuptools>=61.0.0", "wheel"]
4-
build-backend = "setuptools.build_meta"
3+
requires = ["hatchling"]
4+
build-backend = "hatchling.build"
55

66
[project]
77
name = "openfeature_sdk"
@@ -24,12 +24,45 @@ keywords = [
2424
dependencies = []
2525
requires-python = ">=3.8"
2626

27-
[project.optional-dependencies]
28-
dev = ["pip-tools", "pytest", "pre-commit"]
29-
3027
[project.urls]
3128
Homepage = "https://github.com/open-feature/python-sdk"
3229

30+
[tool.hatch]
31+
32+
[tool.hatch.envs.default]
33+
dependencies = [
34+
"behave",
35+
"coverage[toml]>=6.5",
36+
"pytest",
37+
]
38+
39+
[tool.hatch.envs.default.scripts]
40+
test = "pytest {args:tests}"
41+
test-cov = "coverage run -m pytest {args:tests}"
42+
cov-report = [
43+
"coverage xml",
44+
]
45+
cov = [
46+
"test-cov",
47+
"cov-report",
48+
]
49+
e2e = [
50+
"git submodule update --init",
51+
"cp test-harness/features/evaluation.feature tests/features/",
52+
"behave tests/features/",
53+
"rm tests/features/*.feature",
54+
]
55+
56+
[tool.hatch.build.targets.sdist]
57+
exclude = [
58+
".gitignore",
59+
"test-harness",
60+
"venv",
61+
]
62+
63+
[tool.hatch.build.targets.wheel]
64+
packages = ["openfeature"]
65+
3366
[tool.mypy]
3467
files = "openfeature"
3568
namespace_packages = true
@@ -89,6 +122,3 @@ max-statements = 30
89122
[tool.ruff.lint.pyupgrade]
90123
# Preserve types, even if a file imports `from __future__ import annotations`.
91124
keep-runtime-typing = true
92-
93-
[tool.setuptools.package-data]
94-
openfeature = ["py.typed"]

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)