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

Setup release #3

Merged
merged 2 commits into from
Jan 19, 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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ mypy.ini
.gitignore
.gitlab-ci.yml
.python-version
README.md
.hooks
.lets
helm
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
name: Build & publish

# TODO: Setup release workflow
on:
push:
branches: [ "**" ]
tags:
- "v*"
# pull_request:
# branches: [main]

jobs:
deploy-client:
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/client-')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python with PDM ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}

- name: Upload package to pypi.org
run: pdm publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
run: pdm publish -u "__token__" -P ${{ secrets.PYPI_TOKEN }}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ WORKDIR /app
COPY ./pyproject.toml .
COPY ./pdm.lock .

# for pyproject.toml to extract version
COPY ./featureflags_client/__init__.py ./featureflags_client/__init__.py
# for pyproject.toml to read readme
COPY ./README.md .

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq-dev \
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ Client supports Python >=3.9.
Installation
------------

TODO:
To install package:

- ``pdm add evo-featureflags-protobuf``

To release package:

- ``VERSION=<tag> MESSAGE=<message> pdm run release"``

Development
-----------

Install dependencies:

- ``pdm install -d``

Pre-commit
Expand All @@ -26,8 +32,8 @@ Pre-commit

``./scripts/disable-hooks.sh``


TODO:

- add docs, automate docs build
- add tests
- add `tracer` / `stats_collector` for http manager
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ services:
- ./featureflags_client:/app/featureflags_client
- ./examples:/app/examples
- ./.ptpython:/app/.ptpython
- ./README.md:/app/README.md
# Uncomment to mount local build of `featureflags_protobuf`
- ./featureflags_protobuf:/app/featureflags_protobuf
#- ./featureflags_protobuf:/app/featureflags_protobuf

ishell:
<<: *base
Expand Down
1 change: 1 addition & 0 deletions featureflags_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.4.0"
5 changes: 3 additions & 2 deletions featureflags_client/grpc/managers/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
from asyncio import AbstractEventLoop
from typing import Callable, Dict, List, Optional

from featureflags_protobuf.service_grpc import FeatureFlagsStub
from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto

from featureflags_client.grpc.managers.base import AbstractManager
from featureflags_client.grpc.state import GrpcState
from featureflags_client.grpc.stats_collector import StatsCollector
from featureflags_client.grpc.tracer import Tracer
from featureflags_client.grpc.types import Variable
from featureflags_client.grpc.utils import intervals_gen
from featureflags_protobuf.service_grpc import FeatureFlagsStub
from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto

try:
import grpclib.client
Expand Down
5 changes: 3 additions & 2 deletions featureflags_client/grpc/managers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from datetime import datetime, timedelta
from typing import Callable, Dict, List, Optional

from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto
from featureflags_protobuf.service_pb2_grpc import FeatureFlagsStub

from featureflags_client.grpc.managers.base import AbstractManager
from featureflags_client.grpc.state import GrpcState
from featureflags_client.grpc.stats_collector import StatsCollector
from featureflags_client.grpc.tracer import Tracer
from featureflags_client.grpc.types import Variable
from featureflags_client.grpc.utils import intervals_gen
from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto
from featureflags_protobuf.service_pb2_grpc import FeatureFlagsStub

try:
import grpc
Expand Down
4 changes: 2 additions & 2 deletions featureflags_client/grpc/state.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, List, Optional

from featureflags_protobuf import service_pb2
from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto
from hiku.builder import Q, build
from hiku.export.protobuf import export
from hiku.query import Node as QueryNode

from featureflags_client.grpc.conditions import load_flags
from featureflags_client.grpc.types import Variable
from featureflags_protobuf import service_pb2
from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto


def get_grpc_graph_query(project_name: str) -> QueryNode:
Expand Down
3 changes: 1 addition & 2 deletions featureflags_client/grpc/stats_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from datetime import datetime, timedelta
from typing import DefaultDict, Dict, List

from google.protobuf.timestamp_pb2 import Timestamp as TimestampProto

from featureflags_protobuf.service_pb2 import FlagUsage as FlagUsageProto
from google.protobuf.timestamp_pb2 import Timestamp as TimestampProto


class StatsCollector:
Expand Down
16 changes: 8 additions & 8 deletions featureflags_client/tests/grpc/test_conditions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import faker
import pytest
from featureflags_protobuf.graph_pb2 import (
Check,
Condition,
Flag,
Ref,
Result,
Variable,
)
from google.protobuf.wrappers_pb2 import BoolValue

from featureflags_client.grpc.conditions import (
Expand All @@ -19,14 +27,6 @@
superset,
wildcard,
)
from featureflags_protobuf.graph_pb2 import (
Check,
Condition,
Flag,
Ref,
Result,
Variable,
)

f = faker.Faker()
undefined = object()
Expand Down
4 changes: 2 additions & 2 deletions featureflags_client/tests/grpc/test_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import faker
import pytest
from featureflags_protobuf.graph_pb2 import Check, Result, Variable
from featureflags_protobuf.service_pb2 import FlagUsage
from google.protobuf.timestamp_pb2 import Timestamp

from featureflags_client.grpc.client import FeatureFlagsClient
from featureflags_client.grpc.flags import Flags
from featureflags_client.grpc.managers.dummy import DummyManager
from featureflags_client.grpc.stats_collector import StatsCollector
from featureflags_protobuf.graph_pb2 import Check, Result, Variable
from featureflags_protobuf.service_pb2 import FlagUsage

f = faker.Faker()

Expand Down
2 changes: 1 addition & 1 deletion featureflags_client/tests/grpc/test_managers_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import faker
import pytest
from featureflags_protobuf import graph_pb2, service_pb2
from google.protobuf import wrappers_pb2
from grpclib.client import Channel

from featureflags_client.grpc.client import FeatureFlagsClient
from featureflags_client.grpc.managers.asyncio import AsyncIOManager
from featureflags_client.grpc.state import get_grpc_graph_query
from featureflags_client.grpc.types import Types, Variable
from featureflags_protobuf import graph_pb2, service_pb2

f = faker.Faker()

Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[project]
name = "evo-featureflags-client"
version = "0.4.0"
dynamic = ["version"]
description = "Feature flags client"
readme = "README.md"
authors = [
{ name = "d.zakharchuk", email = "[email protected]" },
{ name = "m.kindritskiy", email = "[email protected]" },
Expand All @@ -27,7 +28,12 @@ build-backend = "pdm.backend"

[tool.pdm]

[tool.pdm.version]
source = "file"
path = "featureflags_client/__init__.py"

[tool.pdm.scripts]
release = "./scripts/release.sh"
ishell = "ptpython --asyncio --dark-bg --history-file=.ptpython {args}"
test = "python -m pytest {args}"
docs = "sphinx-build -a -b html docs public"
Expand Down
23 changes: 23 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e
USAGE="Usage: VERSION=<> MESSAGE=<> pdm run release"

if [ -z "${VERSION}" ]; then
echo "$USAGE"
echo "VERSION is not set"
exit 1
fi
if [ -z "${MESSAGE}" ]; then
echo "$USAGE"
echo "MESSAGE is not set"
exit 1
fi

echo "Releasing ${VERSION} with message: ${MESSAGE}"

echo "__version__ = \"${VERSION}\"" > featureflags_client/__init__.py
git add featureflags_client/__init__.py
git commit -m "Release ${VERSION}"

git tag -a v${VERSION} -m "${MESSAGE}"
git push origin main --tags