From 30e3a423e9d6ac1c0d6e9ea7b183d01d11c7363f Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Tue, 7 Nov 2023 17:45:33 +0100 Subject: [PATCH] fix package naming and create test-release pipeline --- .github/workflows/release.yml | 12 ++-- .github/workflows/test-release.yml | 32 +++++++++ .gitlab-ci.yml | 71 ------------------- README.md | 6 +- flowable/__init__.py | 0 .../external_worker_client}/__init__.py | 8 +-- .../external_worker_client}/cloud_token.py | 0 .../engine_rest_variable.py | 0 .../external_worker_acquire_job_response.py | 4 +- .../external_worker_job_response.py | 0 .../flowable_rest_exception.py | 0 .../external_worker_client}/list_result.py | 0 .../request_converter.py | 2 +- .../response_converter.py | 8 +-- .../external_worker_client}/restclient.py | 14 ++-- .../external_worker_client}/utils.py | 0 .../external_worker_client}/worker_result.py | 4 +- setup.py | 14 +++- tests/test_init.py | 2 +- tests/test_restclient.py | 4 +- 20 files changed, 77 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/test-release.yml delete mode 100644 .gitlab-ci.yml create mode 100644 flowable/__init__.py rename {flowableexternalworker => flowable/external_worker_client}/__init__.py (88%) rename {flowableexternalworker => flowable/external_worker_client}/cloud_token.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/engine_rest_variable.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/external_worker_acquire_job_response.py (55%) rename {flowableexternalworker => flowable/external_worker_client}/external_worker_job_response.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/flowable_rest_exception.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/list_result.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/request_converter.py (70%) rename {flowableexternalworker => flowable/external_worker_client}/response_converter.py (84%) rename {flowableexternalworker => flowable/external_worker_client}/restclient.py (89%) rename {flowableexternalworker => flowable/external_worker_client}/utils.py (100%) rename {flowableexternalworker => flowable/external_worker_client}/worker_result.py (94%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65821f9..05e20c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,11 +2,12 @@ name: Publish Package to PyPi on: release: types: [published] + jobs: build: runs-on: ubuntu-latest + environment: release permissions: - contents: read id-token: write steps: - uses: actions/checkout@v4 @@ -21,6 +22,9 @@ jobs: - run: source venv/bin/activate - run: pip install setuptools - run: python setup.py sdist - - run: pip wheel . -w dist - - run: python -m pip install --upgrade twine - - run: twine upload dist/* + - run: pip wheel --no-deps . -w dist + - name: Publish package distributions to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ + verbose: true diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml new file mode 100644 index 0000000..3bb7e15 --- /dev/null +++ b/.github/workflows/test-release.yml @@ -0,0 +1,32 @@ +name: Publish Package to Test PyPi + +on: + release: + types: [released] + +jobs: + build: + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12.0 + uses: actions/setup-python@v4 + with: + python-version: 3.12.0 + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - run: pip install virtualenv + - run: virtualenv venv + - run: source venv/bin/activate + - run: pip install setuptools + - run: python setup.py sdist + - run: pip wheel --no-deps . -w dist + - name: Publish package distributions to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + packages-dir: dist/ + verbose: true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ed938b2..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,71 +0,0 @@ -image: python:latest - -# Change pip's cache directory to be inside the project directory since we can -# only cache local items. -variables: - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - -# Pip's cache doesn't store the python packages -# https://pip.pypa.io/en/stable/topics/caching/ -# -# If you want to also cache the installed packages, you have to install -# them in a virtualenv and cache it as well. -cache: - paths: - - .cache/pip - -stages: - - test - - build - - deploy - -before_script: - - python --version ; pip --version # For debugging - - pip install virtualenv - - virtualenv venv - - source venv/bin/activate - - pip install setuptools - -test: - stage: test - script: - - python setup.py pytest - -build: - stage: build - script: - - python setup.py sdist - - pip wheel . -w dist - artifacts: - paths: - - "dist/flowableexternalworker-*" - -deploy-snapshot: - stage: deploy - when: manual - only: - - main - dependencies: - - build - needs: - - build - script: - - export TWINE_REPOSITORY_URL=$TWINE_REPOSITORY_URL_SNAPSHOT - - python -m pip install --upgrade twine - - ls dist/* - - twine upload -r local dist/* - -deploy-release: - stage: deploy - when: manual - only: - - main - dependencies: - - build - needs: - - build - script: - - export TWINE_REPOSITORY_URL=$TWINE_REPOSITORY_URL_RELEASE - - python -m pip install --upgrade twine - - ls dist/* - - twine upload -r local dist/* diff --git a/README.md b/README.md index 374fbb1..1245c9c 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ The usage with Flowable Cloud is simpler, since everything is pre-configured. However, it's required to either use the user credentials or to pre-configure a personal access token. ```python -from flowableexternalworker import ExternalWorkerClient -from flowableexternalworker.cloud_token import FlowableCloudToken +from flowable.external_worker_client import ExternalWorkerClient +from flowable.external_worker_client.cloud_token import FlowableCloudToken client = ExternalWorkerClient(auth=FlowableCloudToken("")) @@ -46,7 +46,7 @@ subscription = client.subscribe('myTopic', my_callback) The following is an example how you can connect to a Flowable instance running at `http://host.docker.internal:8090` and process all messages retrieved on the topic `myTopic`: ```python -from flowableexternalworker import ExternalWorkerClient +from flowable.external_worker_client import ExternalWorkerClient from requests.auth import HTTPBasicAuth client = ExternalWorkerClient('http://localhost:8090/flowable-work', auth=HTTPBasicAuth("admin", "test")) diff --git a/flowable/__init__.py b/flowable/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/flowableexternalworker/__init__.py b/flowable/external_worker_client/__init__.py similarity index 88% rename from flowableexternalworker/__init__.py rename to flowable/external_worker_client/__init__.py index c42a83d..f4ea696 100644 --- a/flowableexternalworker/__init__.py +++ b/flowable/external_worker_client/__init__.py @@ -7,10 +7,10 @@ from requests import Session from requests.auth import AuthBase -from flowableexternalworker.engine_rest_variable import EngineRestVariable -from flowableexternalworker.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse -from flowableexternalworker.restclient import FlowableExternalWorkerRestClient -from flowableexternalworker.worker_result import WorkerResultSuccess, WorkerResultFailure, WorkerResultBpmnError, WorkerResultCmmnTerminate, WorkResult +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse +from flowable.external_worker_client.restclient import FlowableExternalWorkerRestClient +from flowable.external_worker_client.worker_result import WorkerResultSuccess, WorkerResultFailure, WorkerResultBpmnError, WorkerResultCmmnTerminate, WorkResult class WorkerResultBuilder(object): diff --git a/flowableexternalworker/cloud_token.py b/flowable/external_worker_client/cloud_token.py similarity index 100% rename from flowableexternalworker/cloud_token.py rename to flowable/external_worker_client/cloud_token.py diff --git a/flowableexternalworker/engine_rest_variable.py b/flowable/external_worker_client/engine_rest_variable.py similarity index 100% rename from flowableexternalworker/engine_rest_variable.py rename to flowable/external_worker_client/engine_rest_variable.py diff --git a/flowableexternalworker/external_worker_acquire_job_response.py b/flowable/external_worker_client/external_worker_acquire_job_response.py similarity index 55% rename from flowableexternalworker/external_worker_acquire_job_response.py rename to flowable/external_worker_client/external_worker_acquire_job_response.py index 328a48c..cb7fc04 100644 --- a/flowableexternalworker/external_worker_acquire_job_response.py +++ b/flowable/external_worker_client/external_worker_acquire_job_response.py @@ -1,5 +1,5 @@ -from flowableexternalworker.engine_rest_variable import EngineRestVariable -from flowableexternalworker.external_worker_job_response import ExternalWorkerJobResponse +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client.external_worker_job_response import ExternalWorkerJobResponse class ExternalWorkerAcquireJobResponse(ExternalWorkerJobResponse): diff --git a/flowableexternalworker/external_worker_job_response.py b/flowable/external_worker_client/external_worker_job_response.py similarity index 100% rename from flowableexternalworker/external_worker_job_response.py rename to flowable/external_worker_client/external_worker_job_response.py diff --git a/flowableexternalworker/flowable_rest_exception.py b/flowable/external_worker_client/flowable_rest_exception.py similarity index 100% rename from flowableexternalworker/flowable_rest_exception.py rename to flowable/external_worker_client/flowable_rest_exception.py diff --git a/flowableexternalworker/list_result.py b/flowable/external_worker_client/list_result.py similarity index 100% rename from flowableexternalworker/list_result.py rename to flowable/external_worker_client/list_result.py diff --git a/flowableexternalworker/request_converter.py b/flowable/external_worker_client/request_converter.py similarity index 70% rename from flowableexternalworker/request_converter.py rename to flowable/external_worker_client/request_converter.py index 7bd7cfa..5ba7462 100644 --- a/flowableexternalworker/request_converter.py +++ b/flowable/external_worker_client/request_converter.py @@ -1,4 +1,4 @@ -from flowableexternalworker.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable def convert_from_engine_rest_variable(o: EngineRestVariable) -> object: diff --git a/flowableexternalworker/response_converter.py b/flowable/external_worker_client/response_converter.py similarity index 84% rename from flowableexternalworker/response_converter.py rename to flowable/external_worker_client/response_converter.py index 7c5db65..f4e9247 100644 --- a/flowableexternalworker/response_converter.py +++ b/flowable/external_worker_client/response_converter.py @@ -1,7 +1,7 @@ -from flowableexternalworker.engine_rest_variable import EngineRestVariable -from flowableexternalworker.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse -from flowableexternalworker.external_worker_job_response import ExternalWorkerJobResponse -from flowableexternalworker.utils import parse_date_time +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse +from flowable.external_worker_client.external_worker_job_response import ExternalWorkerJobResponse +from flowable.external_worker_client.utils import parse_date_time def convert_to_external_worker_job_response(o) -> ExternalWorkerJobResponse: diff --git a/flowableexternalworker/restclient.py b/flowable/external_worker_client/restclient.py similarity index 89% rename from flowableexternalworker/restclient.py rename to flowable/external_worker_client/restclient.py index 69640cf..8ea9480 100644 --- a/flowableexternalworker/restclient.py +++ b/flowable/external_worker_client/restclient.py @@ -4,13 +4,13 @@ from requests import Session from requests.auth import AuthBase -from flowableexternalworker import response_converter -from flowableexternalworker.engine_rest_variable import EngineRestVariable -from flowableexternalworker.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse -from flowableexternalworker.external_worker_job_response import ExternalWorkerJobResponse -from flowableexternalworker.flowable_rest_exception import FlowableRestException -from flowableexternalworker.list_result import ListResult -from flowableexternalworker.request_converter import convert_from_engine_rest_variable +from flowable.external_worker_client import response_converter +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client.external_worker_acquire_job_response import ExternalWorkerAcquireJobResponse +from flowable.external_worker_client.external_worker_job_response import ExternalWorkerJobResponse +from flowable.external_worker_client.flowable_rest_exception import FlowableRestException +from flowable.external_worker_client.list_result import ListResult +from flowable.external_worker_client.request_converter import convert_from_engine_rest_variable JOB_API = '/external-job-api' diff --git a/flowableexternalworker/utils.py b/flowable/external_worker_client/utils.py similarity index 100% rename from flowableexternalworker/utils.py rename to flowable/external_worker_client/utils.py diff --git a/flowableexternalworker/worker_result.py b/flowable/external_worker_client/worker_result.py similarity index 94% rename from flowableexternalworker/worker_result.py rename to flowable/external_worker_client/worker_result.py index 0a34c81..512575f 100644 --- a/flowableexternalworker/worker_result.py +++ b/flowable/external_worker_client/worker_result.py @@ -1,8 +1,8 @@ from __future__ import annotations from abc import abstractmethod -from flowableexternalworker import ExternalWorkerAcquireJobResponse, EngineRestVariable -from flowableexternalworker.restclient import FlowableExternalWorkerRestClient +from flowable.external_worker_client import ExternalWorkerAcquireJobResponse, EngineRestVariable +from flowable.external_worker_client.restclient import FlowableExternalWorkerRestClient class WorkResult(object): diff --git a/setup.py b/setup.py index fa24023..ffc9948 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,21 @@ from setuptools import find_packages, setup +# read the contents of your README file +from pathlib import Path + +this_directory = Path(__file__).parent +long_description = (this_directory / "README.md").read_text() + setup( name='flowable.external-worker-client', - packages=find_packages(include=['flowable.external-worker-client']), - version='1.0.dev1', + packages=['flowable', 'flowable.external_worker_client'], + version='1.0.rc1', description='Flowable External Worker Library to connect Python code to Flowable using an external worker.', + long_description=long_description, + long_description_content_type='text/markdown', author='Flowable', license='', - install_requires=['requests'], + install_requires=['requests>=2.27.0'], setup_requires=['pytest-runner'], tests_require=['pytest', 'vcrpy'], test_suite='tests', diff --git a/tests/test_init.py b/tests/test_init.py index 51634e8..de9d148 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -1,7 +1,7 @@ import time from datetime import timedelta -from flowableexternalworker import ExternalWorkerClient, WorkerResultBuilder, ExternalWorkerAcquireJobResponse, CallbackHandlerType +from flowable.external_worker_client import ExternalWorkerClient, WorkerResultBuilder, ExternalWorkerAcquireJobResponse, CallbackHandlerType from tests.basic_test import BasicTest, base_url, auth from tests.bpmn_utils import start_process, executed_activity_ids, terminate_process, get_process_variable from tests.cmmn_utils import start_case, get_case_variable diff --git a/tests/test_restclient.py b/tests/test_restclient.py index 2c44b81..b3984d1 100644 --- a/tests/test_restclient.py +++ b/tests/test_restclient.py @@ -5,8 +5,8 @@ from requests import Session from requests.auth import HTTPBasicAuth -from flowableexternalworker import restclient -from flowableexternalworker.engine_rest_variable import EngineRestVariable +from flowable.external_worker_client import restclient +from flowable.external_worker_client.engine_rest_variable import EngineRestVariable from tests.basic_test import base_url, auth, BasicTest from tests.bpmn_utils import deploy_process, delete_deployment, start_process, terminate_process, get_process_definition_id, get_process_variable, \ executed_activity_ids