Skip to content

Commit dbaabad

Browse files
committed
ci: run integration tests against N, N-1, N-2 Dapr runtime versions
Signed-off-by: Ashok More <ashoksmore7@gmail.com>
1 parent 8367be5 commit dbaabad

1 file changed

Lines changed: 96 additions & 32 deletions

File tree

.github/workflows/run-tests.yaml

Lines changed: 96 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ on:
2626
types: [validate-examples]
2727
merge_group:
2828
jobs:
29-
validate:
29+
prepare:
3030
runs-on: ubuntu-latest
3131
env:
3232
CHECKOUT_REPO: ${{ github.repository }}
3333
CHECKOUT_REF: ${{ github.ref }}
34-
35-
strategy:
36-
fail-fast: false
37-
matrix:
38-
python_ver: ["3.10", "3.11", "3.12", "3.13", "3.14"]
34+
outputs:
35+
matrix: ${{ steps.set-matrix.outputs.matrix }}
3936
steps:
4037
- name: Parse repository_dispatch payload
4138
if: github.event_name == 'repository_dispatch'
@@ -45,40 +42,106 @@ jobs:
4542
echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV
4643
fi
4744
48-
- name: Check out code onto GOPATH
45+
- name: Check out code
4946
uses: actions/checkout@v6
5047
with:
5148
repository: ${{ env.CHECKOUT_REPO }}
5249
ref: ${{ env.CHECKOUT_REF }}
53-
- name: Determine latest Dapr Runtime version
50+
51+
- name: Compute compatibility test matrix
52+
id: set-matrix
5453
env:
5554
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5655
run: |
57-
MIN_RUNTIME_VERSION="1.18.0"
58-
RUNTIME_VERSION=$(curl -fsS -H "Authorization: Bearer $GITHUB_TOKEN" \
59-
"https://api.github.com/repos/dapr/dapr/releases?per_page=10" | \
60-
jq -r 'map(select(.prerelease == false)) | sort_by(.created_at) | reverse | .[0].tag_name | ltrimstr("v")')
61-
if [ -z "$RUNTIME_VERSION" ] || [ "$RUNTIME_VERSION" = "null" ]; then
62-
echo "Failed to resolve Dapr Runtime version" && exit 1
63-
fi
64-
if [ "$(printf '%s\n' "$MIN_RUNTIME_VERSION" "$RUNTIME_VERSION" | sort -V | head -n1)" != "$MIN_RUNTIME_VERSION" ]; then
65-
echo "Resolved runtime version $RUNTIME_VERSION is below minimum $MIN_RUNTIME_VERSION, using minimum instead"
66-
RUNTIME_VERSION="$MIN_RUNTIME_VERSION"
67-
fi
68-
echo "DAPR_RUNTIME_VER=$RUNTIME_VERSION" >> $GITHUB_ENV
69-
echo "Found $RUNTIME_VERSION"
70-
- name: Determine latest Dapr CLI version
71-
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
python3 << 'PY'
57+
import json
58+
import os
59+
import urllib.request
60+
61+
sdk_version = open('VERSION').read().strip()
62+
base_version = sdk_version.split('.dev')[0]
63+
major_text, minor_text, *_ = base_version.split('.')
64+
major = int(major_text)
65+
minor = int(minor_text)
66+
runtime_minors = [f'{major}.{minor - offset}' for offset in range(3)]
67+
68+
request = urllib.request.Request(
69+
'https://api.github.com/repos/dapr/dapr/releases?per_page=100',
70+
headers={'Authorization': f'Bearer {os.environ["GITHUB_TOKEN"]}'},
71+
)
72+
releases = json.load(urllib.request.urlopen(request, timeout=30))
73+
74+
def version_key(version: str) -> tuple[int, ...]:
75+
base_version, _, suffix = version.partition('-')
76+
parts = tuple(int(part) for part in base_version.split('.'))
77+
if suffix.startswith('rc.'):
78+
return parts + (int(suffix.removeprefix('rc.')),)
79+
return parts
80+
81+
def latest_patch(runtime_minor: str) -> str | None:
82+
prefix = f'{runtime_minor}.'
83+
for prerelease in (False, True):
84+
versions = [
85+
release['tag_name'].removeprefix('v')
86+
for release in releases
87+
if release.get('prerelease') == prerelease
88+
and release['tag_name'].removeprefix('v').startswith(prefix)
89+
]
90+
if versions:
91+
return sorted(versions, key=version_key)[-1]
92+
return None
93+
94+
python_versions = ['3.10', '3.11', '3.12', '3.13', '3.14']
95+
matrix_include = []
96+
for runtime_minor in runtime_minors:
97+
runtime_version = latest_patch(runtime_minor)
98+
if runtime_version is None:
99+
print(f'Warning: no Dapr runtime release found for {runtime_minor}, skipping')
100+
continue
101+
for python_version in python_versions:
102+
matrix_include.append(
103+
{
104+
'python_ver': python_version,
105+
'runtime_version': runtime_version,
106+
}
107+
)
108+
109+
if not matrix_include:
110+
raise SystemExit('No Dapr runtime releases found for compatibility matrix')
111+
112+
matrix = {'include': matrix_include}
113+
print(f'SDK version: {sdk_version}')
114+
print(f'Runtime minors: {runtime_minors}')
115+
print(f'Matrix ({len(matrix_include)} jobs): {json.dumps(matrix)}')
116+
117+
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output_file:
118+
output_file.write(f'matrix={json.dumps(matrix)}\n')
119+
PY
120+
121+
validate:
122+
needs: prepare
123+
runs-on: ubuntu-latest
124+
env:
125+
CHECKOUT_REPO: ${{ github.repository }}
126+
CHECKOUT_REF: ${{ github.ref }}
127+
128+
strategy:
129+
fail-fast: false
130+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
131+
steps:
132+
- name: Parse repository_dispatch payload
133+
if: github.event_name == 'repository_dispatch'
73134
run: |
74-
CLI_VERSION=$(curl -fsS -H "Authorization: Bearer $GITHUB_TOKEN" \
75-
"https://api.github.com/repos/dapr/cli/releases?per_page=10" | \
76-
jq -r 'map(select(.prerelease == false)) | sort_by(.created_at) | reverse | .[0].tag_name | ltrimstr("v")')
77-
if [ -z "$CLI_VERSION" ] || [ "$CLI_VERSION" = "null" ]; then
78-
echo "Failed to resolve Dapr CLI version" && exit 1
135+
if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then
136+
echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV
137+
echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV
79138
fi
80-
echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV
81-
echo "Found $CLI_VERSION"
139+
140+
- name: Check out code onto GOPATH
141+
uses: actions/checkout@v6
142+
with:
143+
repository: ${{ env.CHECKOUT_REPO }}
144+
ref: ${{ env.CHECKOUT_REF }}
82145
- name: Set up Python ${{ matrix.python_ver }}
83146
uses: actions/setup-python@v6
84147
with:
@@ -92,9 +155,10 @@ jobs:
92155
with:
93156
commit: ${{ github.event.inputs.daprcli_commit }}
94157
github-token: ${{ secrets.GITHUB_TOKEN }}
95-
- name: Set up Dapr runtime
158+
- name: Set up Dapr runtime ${{ matrix.runtime_version }}
96159
uses: dapr/.github/.github/actions/setup-dapr-runtime@main
97160
with:
161+
version: ${{ matrix.runtime_version }}
98162
commit: ${{ github.event.inputs.daprdapr_commit }}
99163
github-token: ${{ secrets.GITHUB_TOKEN }}
100164
- name: Set up Llama

0 commit comments

Comments
 (0)