Skip to content
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
17 changes: 11 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"

- uses: bufbuild/buf-action@v1
with:
github_token: ${{ github.token }}
setup_only: true

- name: Install hatch
run: pip install hatch

- name: Building first to generate files
run: hatch build
working-directory: ${{ matrix.package }}

- name: Type checking
# TODO: migrate other packages to use their own 'mypy' setup
if: matrix.python-version == '3.11' && matrix.package == 'providers/openfeature-provider-flagd'
working-directory: ${{ matrix.package }}
run: hatch run mypy:run

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

- if: matrix.python-version == '3.11'
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "schemas"]
path = providers/openfeature-provider-flagd/schemas
path = providers/openfeature-provider-flagd/openfeature/schemas
url = https://github.com/open-feature/schemas
[submodule "providers/openfeature-provider-flagd/test-harness"]
path = providers/openfeature-provider-flagd/test-harness
path = providers/openfeature-provider-flagd/openfeature/test-harness
url = [email protected]:open-feature/flagd-testbed.git
[submodule "providers/openfeature-provider-flagd/spec"]
path = providers/openfeature-provider-flagd/spec
path = providers/openfeature-provider-flagd/openfeature/spec
url = https://github.com/open-feature/spec
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ repos:
- mmh3
- semver
- panzi-json-logic
exclude: proto|tests
exclude: providers/openfeature-provider-flagd|tests
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@ To install Hatch, just run `pip install hatch`.

You will also need to setup the `pre-commit` hooks. Run `pre-commit install` in the root directory of the repository. If you don't have `pre-commit` installed, you can install it with `pip install pre-commit`.

> **Note**
> Currently our protobuf files will be generated during `hatch build`
> Please run this command once, to generate all necessary files.

### Testing

Run tests by entering the package directory and running `hatch run test`.
Run tests by entering the package directory and running `hatch test`.

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

### Integration tests

These are planned once the SDK has been stabilized and a Flagd provider implemented. At that point, we will utilize the [gherkin integration tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) to validate against a live, seeded Flagd instance.

### Type checking

Run `mypy` by entering the package directory and running `hatch run mypy:run`.

## Pull Request

All contributions to the OpenFeature project are welcome via GitHub pull requests.
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
files = hooks,providers
files = hooks,providers/openfeature-provider-ofrep
exclude = proto|tests
untyped_calls_exclude = flagd.proto

Expand Down
1 change: 1 addition & 0 deletions providers/openfeature-provider-flagd/openfeature/schemas
Submodule schemas added at 76d611
78 changes: 69 additions & 9 deletions providers/openfeature-provider-flagd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
]
keywords = []
dependencies = [
"openfeature-sdk>=0.4.0",
"openfeature-sdk>=0.6.0",
"grpcio>=1.60.0",
"protobuf>=4.25.2",
"mmh3>=4.1.0",
Expand All @@ -32,7 +32,7 @@ Homepage = "https://github.com/open-feature/python-sdk-contrib"

[tool.hatch]

[tool.hatch.envs.default]
[tool.hatch.envs.hatch-test]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -41,26 +41,60 @@ dependencies = [
"asserts",
"grpcio-health-checking==1.60.0",
]
post-install-commands = [
"./scripts/gen_protos.sh"
pre-install-commands = [
"hatch build",
]

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

[tool.hatch.envs.mypy]
dependencies = [
"mypy[faster-cache]>=1.13.0",
"types-protobuf",
"types-pyyaml",
]
pre-install-commands = [
"hatch build",
]

[tool.hatch.envs.mypy.scripts]
run = "mypy"

[tool.hatch.build.hooks.protobuf]
generate_pyi = false
dependencies = [
"hatch-protobuf",
"mypy-protobuf~=3.0",
]
proto_paths = [
".",
]
output_path = "src/"

[[tool.hatch.build.hooks.protobuf.generators]]
name = "mypy"
outputs = ["{proto_path}/{proto_name}_pb2.pyi"]

[[tool.hatch.build.hooks.protobuf.generators]]
name = "mypy_grpc"
outputs = ["{proto_path}/{proto_name}_pb2_grpc.pyi"]

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

[tool.hatch.build.targets.wheel]
Expand All @@ -69,6 +103,32 @@ packages = ["src/openfeature"]
[tool.coverage.run]
omit = [
# exclude generated files
"src/openfeature/contrib/provider/flagd/proto/*",
"src/openfeature/schemas/*",
"tests/**",
]

[tool.mypy]
mypy_path = "src"
files = "src"

python_version = "3.8" # should be identical to the minimum supported version
namespace_packages = true
explicit_package_bases = true
local_partial_types = true
pretty = true

strict = true
disallow_any_generics = false

[[tool.mypy.overrides]]
module = [
"grpc.*",
"json_logic.*",
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
"openfeature.schemas.*"
]
warn_unused_ignores = false
1 change: 0 additions & 1 deletion providers/openfeature-provider-flagd/schemas
Submodule schemas deleted from d897c2
10 changes: 0 additions & 10 deletions providers/openfeature-provider-flagd/scripts/gen_protos.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

schemas

This file was deleted.

Loading
Loading