-
Notifications
You must be signed in to change notification settings - Fork 20
Creation of pipeline to publish dts python package to pypi #43
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9a7569a
Creating of pipeline to publish dts python package to pypi
RyanLettieri 2431d2f
Upgrading version of durabletask-azuremanaged from 0.1b1 to 0.1
RyanLettieri 67fe8c1
Updating versioning on packages
RyanLettieri 58f0f36
Incrementing version to allign with pypi
RyanLettieri 4f7615a
Adressing majority of first round of feedback
RyanLettieri 46364b6
Updating pipeline to have linting
RyanLettieri 4c4e6bf
Updating versions in pyproject.toml
RyanLettieri 717ab88
Updating working dirs in yml
RyanLettieri e46d90a
Adding requirements.txt
RyanLettieri 30bce57
Moving durabletask tests into specific dir and more
RyanLettieri 59b21ce
Fixing more paths
RyanLettieri 29ddd2f
ATtemptign to ignore durabletask-azuremanaged folder
RyanLettieri 8716a9e
installing dts dependencies
RyanLettieri 406d83c
Changing path for requirements.txt
RyanLettieri a654c0d
Moving init.py
RyanLettieri fe7e102
Updating readme and some tests
RyanLettieri 9628875
Running all dts tests in publish pipeline
RyanLettieri 7337186
Removing PYTHONPATH and installing regular deps
RyanLettieri cb824d8
Adding timeout to dts orchestration e2e test
RyanLettieri 76307eb
Removing suspend and continue as new tests from dts
RyanLettieri 3c065ae
Removing raise event timeout tests
RyanLettieri faa3d91
Only runnign publish on tag push
RyanLettieri 89373e2
Changing dts action to run on tag creation
RyanLettieri aa1a8aa
Updating tag name
RyanLettieri 7cda76c
Adressing review feedback
RyanLettieri b53adda
Fixing run requirements in actions and adding exit-zero
RyanLettieri 88e86d1
Update .github/workflows/publish-dts-sdk.yml
berndverst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,58 @@ | ||
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
|
||
| name: Build Validation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| merge_group: | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest | ||
| pip install -r requirements.txt | ||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 . --count --show-source --statistics --exit-zero | ||
| - name: Pytest unit tests | ||
| run: | | ||
| pytest -m "not e2e" --verbose | ||
| # Sidecar for running e2e tests requires Go SDK | ||
| - name: Install Go SDK | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: 'stable' | ||
|
|
||
| # Install and run the durabletask-go sidecar for running e2e tests | ||
| - name: Pytest e2e tests | ||
| run: | | ||
| go install github.com/microsoft/durabletask-go@main | ||
| durabletask-go --port 4001 & | ||
| pytest -m "e2e" --verbose | ||
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
|
||
| name: Build Validation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| merge_group: | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install durabletask dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest | ||
| pip install -r requirements.txt | ||
| - name: Install durabletask-azuremanaged dependencies | ||
| working-directory: examples/dts | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 . --count --show-source --statistics --exit-zero | ||
| - name: Pytest unit tests | ||
| working-directory: tests/durabletask | ||
| run: | | ||
| pytest -m "not e2e and not dts" --verbose | ||
| # Sidecar for running e2e tests requires Go SDK | ||
| - name: Install Go SDK | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: 'stable' | ||
|
|
||
| # Install and run the durabletask-go sidecar for running e2e tests | ||
| - name: Pytest e2e tests | ||
| working-directory: tests/durabletask | ||
| run: | | ||
| go install github.com/microsoft/durabletask-go@main | ||
| durabletask-go --port 4001 & | ||
berndverst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pytest -m "e2e and not dts" --verbose | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: Publish Durable Task Scheduler to PyPI | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'azuremanaged-v*' # Only run for tags starting with "azuremanaged-v" | ||
|
|
||
| # on: | ||
RyanLettieri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # push: | ||
| # branches: [ "main" ] | ||
| # pull_request: | ||
| # branches: [ "main" ] | ||
|
|
||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python 3.12 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: 3.12 | ||
| - name: Install dependencies | ||
| working-directory: durabletask-azuremanaged | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install setuptools wheel tox | ||
| pip install flake8 | ||
| - name: Run flake8 Linter | ||
| working-directory: durabletask-azuremanaged | ||
| run: flake8 . | ||
|
|
||
|
|
||
| run-docker-tests: | ||
| needs: lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Pull Docker image | ||
| run: docker pull mcr.microsoft.com/dts/dts-emulator:v0.0.4 | ||
RyanLettieri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Run Docker container | ||
| run: | | ||
| docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:v0.0.4 | ||
| - name: Wait for container to be ready | ||
| run: sleep 10 # Adjust if your service needs more time to start | ||
|
|
||
| - name: Set environment variables | ||
| run: | | ||
| echo "TASKHUB=default" >> $GITHUB_ENV | ||
| echo "ENDPOINT=http://localhost:8080" >> $GITHUB_ENV | ||
| - name: Install durabletask dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest | ||
| pip install -r requirements.txt | ||
| - name: Install durabletask-azuremanaged dependencies | ||
| working-directory: examples/dts | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| - name: Run the tests | ||
| working-directory: tests/durabletask-azuremanaged | ||
| run: | | ||
| pytest -m "dts" --verbose | ||
| publish: | ||
| if: startsWith(github.ref, 'refs/tags/azuremanaged-v') # Only run if a matching tag is pushed | ||
| needs: run-docker-tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Extract version from tag | ||
| run: echo "VERSION=${GITHUB_REF#refs/tags/azuremanaged-v}" >> $GITHUB_ENV # Extract version from the tag | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" # Adjust Python version as needed | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build twine | ||
| - name: Build package from directory durabletask-azuremanaged | ||
RyanLettieri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| working-directory: durabletask-azuremanaged | ||
| run: | | ||
| python -m build | ||
| - name: Check package | ||
RyanLettieri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| working-directory: durabletask-azuremanaged | ||
| run: | | ||
| twine check dist/* | ||
| - name: Publish package to PyPI | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN_AZUREMANAGED }} # Store your PyPI API token in GitHub Secrets | ||
| working-directory: durabletask-azuremanaged | ||
| run: | | ||
| twine upload dist/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| autopep8 | ||
| grpcio>=1.60.0 # 1.60.0 is the version introducing protobuf 1.25.X support, newer versions are backwards compatible | ||
| protobuf | ||
| pytest | ||
RyanLettieri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pytest-cov | ||
| azure-identity | ||
| durabletask-azuremanaged | ||
| durabletask | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
69 changes: 69 additions & 0 deletions
69
tests/durabletask-azuremanaged/test_dts_activity_sequence.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """End-to-end sample that demonstrates how to configure an orchestrator | ||
| that calls an activity function in a sequence and prints the outputs.""" | ||
| import os | ||
|
|
||
| from durabletask import client, task | ||
| from durabletask.azuremanaged.client import DurableTaskSchedulerClient | ||
| from durabletask.azuremanaged.worker import DurableTaskSchedulerWorker | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| pytestmark = pytest.mark.dts | ||
|
|
||
| def hello(ctx: task.ActivityContext, name: str) -> str: | ||
| """Activity function that returns a greeting""" | ||
| return f'Hello {name}!' | ||
|
|
||
|
|
||
| def sequence(ctx: task.OrchestrationContext, _): | ||
| """Orchestrator function that calls the 'hello' activity function in a sequence""" | ||
| # call "hello" activity function in a sequence | ||
| result1 = yield ctx.call_activity(hello, input='Tokyo') | ||
| result2 = yield ctx.call_activity(hello, input='Seattle') | ||
| result3 = yield ctx.call_activity(hello, input='London') | ||
|
|
||
| # return an array of results | ||
| return [result1, result2, result3] | ||
|
|
||
|
|
||
| # Read the environment variable | ||
| taskhub_name = os.getenv("TASKHUB") | ||
|
|
||
| # Check if the variable exists | ||
| if taskhub_name: | ||
| print(f"The value of TASKHUB is: {taskhub_name}") | ||
| else: | ||
| print("TASKHUB is not set. Please set the TASKHUB environment variable to the name of the taskhub you wish to use") | ||
| print("If you are using windows powershell, run the following: $env:TASKHUB=\"<taskhubname>\"") | ||
| print("If you are using bash, run the following: export TASKHUB=\"<taskhubname>\"") | ||
| exit() | ||
|
|
||
| # Read the environment variable | ||
| endpoint = os.getenv("ENDPOINT") | ||
|
|
||
| # Check if the variable exists | ||
| if endpoint: | ||
| print(f"The value of ENDPOINT is: {endpoint}") | ||
| else: | ||
| print("ENDPOINT is not set. Please set the ENDPOINT environment variable to the endpoint of the scheduler") | ||
| print("If you are using windows powershell, run the following: $env:ENDPOINT=\"<schedulerEndpoint>\"") | ||
| print("If you are using bash, run the following: export ENDPOINT=\"<schedulerEndpoint>\"") | ||
| exit() | ||
|
|
||
| # configure and start the worker | ||
| with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True, | ||
| taskhub=taskhub_name, token_credential=None) as w: | ||
| w.add_orchestrator(sequence) | ||
| w.add_activity(hello) | ||
| w.start() | ||
|
|
||
| # Construct the client and run the orchestrations | ||
| c = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True, | ||
| taskhub=taskhub_name, token_credential=None) | ||
| instance_id = c.schedule_new_orchestration(sequence) | ||
| state = c.wait_for_orchestration_completion(instance_id, timeout=60) | ||
| if state and state.runtime_status == client.OrchestrationStatus.COMPLETED: | ||
| print(f'Orchestration completed! Result: {state.serialized_output}') | ||
| elif state: | ||
| print(f'Orchestration failed: {state.failure_details}') |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want this step to fail if there are linter issues, so let's not use
--exit-zeroThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that was there before - but let's actually change this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to a lot of lint errors that were being ignored. I'll create an additional PR afterwards that removes this flag and addresses the linting problems so I don't clutter this PR too much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, please do that! Just because existing linter errors exist doesn't mean we should leave them in place.