Skip to content

Commit

Permalink
chore: continue migrating to hatch
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Bond <federicobond@gmail.com>
  • Loading branch information
federicobond committed Jan 20, 2024
1 parent 5936527 commit b5aa8a1
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 27 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
package:
- "hooks/openfeature-hooks-opentelemetry"
- "providers/openfeature-provider-flagd"

steps:
- uses: actions/checkout@v4
Expand All @@ -38,20 +41,19 @@ jobs:
with:
github_token: ${{ github.token }}

- name: Install dependencies
run: make venv

- name: Generate flagd protobuf files
run: make grpc
- name: Install hatch
run: pip install hatch

- name: Test with pytest
run: make testcov
run: hatch run cov
working-directory: ${{ matrix.package }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@e0fbd592d323cb2991fb586fdd260734fcb41fcb
uses: codecov/codecov-action@v3
with:
flags: unittests # optional
name: coverage # optional
directory: ${{ matrix.package }}
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

Expand Down
43 changes: 34 additions & 9 deletions hooks/openfeature-hooks-opentelemetry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# pyproject.toml
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "openfeature-hooks-opentelemetry"
version = "0.1.0"
description = "OpenTelemetry hooks for the OpenFeature Python SDK"
readme = "readme.md"
readme = "README.md"
authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }]
license = { file = "LICENSE" }
classifiers = [
Expand All @@ -16,13 +16,38 @@ classifiers = [
"Programming Language :: Python :: 3",
]
keywords = []
dependencies = []
requires-python = ">=3.8"

[project.optional-dependencies]
tests = [
'pytest',
dependencies = [
"openfeature-sdk>=0.4.0",
"opentelemetry-api",
]
requires-python = ">=3.8"

[project.urls]
Homepage = "https://github.com/open-feature/python-sdk-contrib"

[tool.hatch]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
]

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

[tool.hatch.build.targets.sdist]
exclude = [
".gitignore",
]

[tool.hatch.build.targets.wheel]
packages = ["src/openfeature"]
49 changes: 38 additions & 11 deletions providers/openfeature-provider-flagd/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# pyproject.toml
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "openfeature-provider-flagd"
version = "0.1.0"
description = "OpenFeature provider for the flagd flag evaluation engine"
readme = "readme.md"
readme = "README.md"
authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }]
license = { file = "LICENSE" }
classifiers = [
Expand All @@ -16,16 +16,43 @@ classifiers = [
"Programming Language :: Python :: 3",
]
keywords = []
dependencies = []
requires-python = ">=3.8"

[project.optional-dependencies]
tests = [
'pytest',
dependencies = [
"openfeature-sdk>=0.4.0",
"grpcio>=1.60.0",
"protobuf>=4.25.2",
]
requires-python = ">=3.8"

[project.urls]
Homepage = "https://github.com/open-feature/python-sdk-contrib"

[tool.setuptools.packages.find]
exclude = ["schemas"]
[tool.hatch]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
]
post-install-commands = [
"./scripts/gen_protos.sh"
]

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

[tool.hatch.build.targets.sdist]
exclude = [
".gitignore",
"schemas",
]

[tool.hatch.build.targets.wheel]
packages = ["src/openfeature"]
10 changes: 10 additions & 0 deletions providers/openfeature-provider-flagd/scripts/gen_protos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

buf generate buf.build/open-feature/flagd --template schemas/protobuf/buf.gen.python.yaml --output schemas
rm -rf openfeature/contrib/provider/flagd/proto
sed -i.bak 's/^from schema.v1 import/from . import/' proto/python/schema/v1/*.py
rm proto/python/schema/v1/*.bak
mv proto/python src/openfeature/contrib/provider/flagd/proto
rmdir proto

0 comments on commit b5aa8a1

Please sign in to comment.