-
Notifications
You must be signed in to change notification settings - Fork 22
132 lines (120 loc) · 4.7 KB
/
python.yaml
File metadata and controls
132 lines (120 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Python Features Testing
on:
workflow_call:
inputs:
python-repo-path:
type: string
default: 'temporalio/sdk-python'
version:
required: true
type: string
# When true, the version refers to a repo tag/ref. When false, PyPi package version.
version-is-repo-ref:
required: true
type: boolean
features-repo-path:
type: string
default: 'temporalio/features'
features-repo-ref:
type: string
default: 'main'
# If set, download the docker image for server from the provided artifact name
docker-image-artifact-name:
type: string
required: false
permissions:
contents: read
actions: read
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./features
steps:
- name: Print git info
run: 'echo head_ref: "$GITHUB_HEAD_REF", ref: "$GITHUB_REF", python sdk version: ${{ inputs.version }}'
working-directory: '.'
- name: Download docker artifacts
if: ${{ inputs.docker-image-artifact-name }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.docker-image-artifact-name }}
path: /tmp/server-docker
- name: Load server Docker image
if: ${{ inputs.docker-image-artifact-name }}
run: docker load --input /tmp/server-docker/temporal-autosetup.tar
working-directory: '.'
- name: Override IMAGE_TAG environment variable
if: ${{ inputs.docker-image-artifact-name }}
run: |
image_tag=latest
# image_tag won't exist on older builds (like 1.22.0), so default to latest
if [ -f /tmp/server-docker/image_tag ]; then
image_tag=$(cat /tmp/server-docker/image_tag)
fi
echo "IMAGE_TAG=${image_tag}" >> $GITHUB_ENV
working-directory: '.'
- name: Checkout SDK features repo
uses: actions/checkout@v4
with:
path: features
repository: ${{ inputs.features-repo-path }}
ref: ${{ inputs.features-repo-ref }}
- name: Checkout Python SDK repo
if: ${{ inputs.version-is-repo-ref }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.python-repo-path }}
submodules: recursive
path: sdk-python
ref: ${{ inputs.version }}
- uses: actions/setup-go@v5
with:
go-version: '^1.21'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: astral-sh/setup-uv@v5
# Build SDK ==================================================
- name: Install Protoc
if: ${{ inputs.version-is-repo-ref }}
uses: arduino/setup-protoc@v3
with:
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
if: ${{ inputs.version-is-repo-ref }}
with:
workspaces: sdk-python/temporalio/bridge
- uses: astral-sh/setup-uv@v5
- run: uv sync
if: ${{ inputs.version-is-repo-ref }}
working-directory: sdk-python
- run: uv build
if: ${{ inputs.version-is-repo-ref }}
working-directory: sdk-python
# ============================================================
- name: Start containerized server and dependencies
if: inputs.docker-image-artifact-name
run: |
docker compose \
-f ./dockerfiles/docker-compose.for-server-image.yaml \
-f /tmp/server-docker/docker-compose.yml \
up -d temporal-server cassandra elasticsearch
- name: Run SDK-features tests directly
if: inputs.docker-image-artifact-name == ''
run: go run . run --lang python ${{ inputs.docker-image-artifact-name && '--server localhost:7233 --namespace default' || ''}} --version "${{ inputs.version-is-repo-ref && '$(realpath ../sdk-python)' || inputs.version }}"
# Running the tests in their own step keeps the logs readable
- name: Run containerized SDK-features tests
if: inputs.docker-image-artifact-name
run: |
docker compose \
-f ./dockerfiles/docker-compose.for-server-image.yaml \
-f /tmp/server-docker/docker-compose.yml \
up --no-log-prefix --exit-code-from features-tests-py features-tests-py
- name: Tear down docker compose
if: inputs.docker-image-artifact-name && (success() || failure())
run: docker compose -f ./dockerfiles/docker-compose.for-server-image.yaml -f /tmp/server-docker/docker-compose.yml down -v