Skip to content

Commit 69ade8e

Browse files
authored
build: add test only using worker dependencies (#1818)
* Release fixes from 4.41.1 * fix dir * run for all versions, isntall invoke * add requests * fix worker installation * debug * change in approach * fix pool * fix? * docker image fix * docker image fix * test that packaging would have failed * final fixes + testing that dep check fails * flake * simplify dep check * oops * fix
1 parent 0a68393 commit 69ade8e

File tree

6 files changed

+116
-28
lines changed

6 files changed

+116
-28
lines changed

eng/ci/public-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ extends:
6060
PROJECT_DIRECTORY: 'workers'
6161
# Skip the build stage for SDK and Extensions release branches. This stage will fail because pyproject.toml contains the updated (and unreleased) library version
6262
condition: and(eq(variables.isSdkRelease, false), eq(variables.isExtensionsRelease, false), eq(variables['USETESTPYTHONSDK'], false), eq(variables['USETESTPYTHONEXTENSIONS'], false))
63+
- stage: CheckPythonWorkerDependencies
64+
dependsOn: BuildPythonWorker
65+
jobs:
66+
- template: /eng/templates/jobs/ci-dependency-check.yml@self
67+
parameters:
68+
PoolName: 1es-pool-azfunc-public
6369
- stage: RunWorkerUnitTests
6470
dependsOn: BuildPythonWorker
6571
jobs:
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
jobs:
2+
- job: "TestPython"
3+
displayName: "Run Dependency Checks"
4+
5+
pool:
6+
name: ${{ parameters.PoolName }}
7+
image: 1es-ubuntu-22.04
8+
os: linux
9+
10+
strategy:
11+
matrix:
12+
Python39:
13+
PYTHON_VERSION: '3.9'
14+
Python310:
15+
PYTHON_VERSION: '3.10'
16+
Python311:
17+
PYTHON_VERSION: '3.11'
18+
Python312:
19+
PYTHON_VERSION: '3.12'
20+
Python313:
21+
PYTHON_VERSION: '3.13'
22+
Python314:
23+
PYTHON_VERSION: '3.14'
24+
steps:
25+
- task: UsePythonVersion@0
26+
inputs:
27+
versionSpec: $(PYTHON_VERSION)
28+
- powershell: |
29+
$PY_VER = "$(PYTHON_VERSION)"
30+
Write-Host "Python version: $PY_VER"
31+
32+
# Extract minor version as integers
33+
$versionParts = $PY_VER.Split('.')
34+
$PY_MINOR = [int]$versionParts[1]
35+
Write-Host "Minor version: $PY_MINOR"
36+
Write-Host "##vso[task.setvariable variable=minorVersion;]$PY_MINOR"
37+
38+
# Set build-related variables based on Python minor version
39+
if( $PY_MINOR -ge 13 )
40+
{
41+
Write-Host "##vso[task.setvariable variable=proxyWorker;]true"
42+
}
43+
else
44+
{
45+
Write-Host "##vso[task.setvariable variable=proxyWorker;]false"
46+
}
47+
displayName: 'Set necessary variables'
48+
- bash: |
49+
echo "Checking azure_functions_worker (Python < 3.13)..."
50+
cd workers
51+
pip install . invoke
52+
cd tests
53+
python -m invoke -c test_setup build-protos
54+
cd ..
55+
python -c "import pkgutil, importlib; [importlib.import_module(f'azure_functions_worker.{name}') for _, name, _ in pkgutil.walk_packages(['azure_functions_worker'])]"
56+
displayName: 'Python Azure Functions Worker: check for missing dependencies'
57+
condition: eq(variables['proxyWorker'], false)
58+
- bash: |
59+
echo "Checking proxy_worker (Python >= 3.13)..."
60+
cd workers
61+
pip install . invoke
62+
cd tests
63+
python -m invoke -c test_setup build-protos
64+
cd ..
65+
python -c "import pkgutil, importlib; [importlib.import_module(f'proxy_worker.{name}') for _, name, _ in pkgutil.walk_packages(['proxy_worker'])]"
66+
displayName: 'Python Proxy Worker: check for missing dependencies'
67+
condition: eq(variables['proxyWorker'], true)
68+
- bash: |
69+
echo "Checking V1 Library Worker (Python >= 3.13)..."
70+
cd runtimes/v1
71+
pip install .
72+
python -c "import pkgutil, importlib; [importlib.import_module(f'azure_functions_runtime_v1.{name}') for _, name, _ in pkgutil.walk_packages(['azure_functions_runtime_v1'])]"
73+
displayName: 'Python Library V1: check for missing dependencies'
74+
condition: eq(variables['proxyWorker'], true)
75+
- bash: |
76+
echo "Checking V2 Library Worker (Python >= 3.13)..."
77+
cd runtimes/v2
78+
pip install .
79+
python -c "import pkgutil, importlib; [importlib.import_module(f'azure_functions_runtime.{name}') for _, name, _ in pkgutil.walk_packages(['azure_functions_runtime'])]"
80+
displayName: 'Python Library V2: check for missing dependencies'
81+
condition: eq(variables['proxyWorker'], true)

eng/templates/official/jobs/ci-docker-consumption-tests.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,27 @@ jobs:
1515
Python39:
1616
PYTHON_VERSION: '3.9'
1717
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)
18-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString39)
19-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString39)
20-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString39)
2118
SQL_CONNECTION: $(LinuxSqlConnectionString39)
2219
EVENTGRID_URI: $(LinuxEventGridTopicUriString39)
2320
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString39)
2421
Python310:
2522
PYTHON_VERSION: '3.10'
2623
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
27-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString310)
28-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString310)
29-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString310)
3024
SQL_CONNECTION: $(LinuxSqlConnectionString310)
3125
EVENTGRID_URI: $(LinuxEventGridTopicUriString310)
3226
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString310)
3327
Python311:
3428
PYTHON_VERSION: '3.11'
3529
STORAGE_CONNECTION: $(LinuxStorageConnectionString311)
36-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString311)
37-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString311)
38-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString311)
3930
SQL_CONNECTION: $(LinuxSqlConnectionString311)
4031
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
4132
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
33+
Python312:
34+
PYTHON_VERSION: '3.12'
35+
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
36+
SQL_CONNECTION: $(LinuxSqlConnectionString312)
37+
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
38+
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)
4239

4340
steps:
4441
- task: UsePythonVersion@0
@@ -56,9 +53,7 @@ jobs:
5653
env:
5754
CONSUMPTION_DOCKER_TEST: "true"
5855
AzureWebJobsStorage: $(STORAGE_CONNECTION)
59-
AzureWebJobsCosmosDBConnectionString: $(COSMOSDB_CONNECTION)
60-
AzureWebJobsEventHubConnectionString: $(EVENTHUB_CONNECTION)
61-
AzureWebJobsServiceBusConnectionString: $(SERVICEBUS_CONNECTION)
56+
STORAGE_CONNECTION: $(STORAGE_CONNECTION)
6257
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
6358
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
6459
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)

eng/templates/official/jobs/ci-docker-dedicated-tests.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,27 @@ jobs:
1515
Python39:
1616
PYTHON_VERSION: '3.9'
1717
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)
18-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString39)
19-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString39)
20-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString39)
2118
SQL_CONNECTION: $(LinuxSqlConnectionString39)
2219
EVENTGRID_URI: $(LinuxEventGridTopicUriString39)
2320
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString39)
2421
Python310:
2522
PYTHON_VERSION: '3.10'
2623
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
27-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString310)
28-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString310)
29-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString310)
3024
SQL_CONNECTION: $(LinuxSqlConnectionString310)
3125
EVENTGRID_URI: $(LinuxEventGridTopicUriString310)
3226
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString310)
3327
Python311:
3428
PYTHON_VERSION: '3.11'
3529
STORAGE_CONNECTION: $(LinuxStorageConnectionString311)
36-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString311)
37-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString311)
38-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString311)
3930
SQL_CONNECTION: $(LinuxSqlConnectionString311)
4031
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
4132
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
33+
Python312:
34+
PYTHON_VERSION: '3.12'
35+
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
36+
SQL_CONNECTION: $(LinuxSqlConnectionString312)
37+
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
38+
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)
4239

4340
steps:
4441
- task: UsePythonVersion@0
@@ -56,9 +53,7 @@ jobs:
5653
env:
5754
DEDICATED_DOCKER_TEST: "true"
5855
AzureWebJobsStorage: $(STORAGE_CONNECTION)
59-
AzureWebJobsCosmosDBConnectionString: $(COSMOSDB_CONNECTION)
60-
AzureWebJobsEventHubConnectionString: $(EVENTHUB_CONNECTION)
61-
AzureWebJobsServiceBusConnectionString: $(SERVICEBUS_CONNECTION)
56+
STORAGE_CONNECTION: $(STORAGE_CONNECTION)
6257
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
6358
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
6459
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)

eng/templates/official/jobs/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
124124
# Modify release_notes.md
125125
Write-Host "Adding a new entry in release_notes.md"
126-
Add-Content -Path release_notes.md -Value "`n- Update Python Worker Version to [$newWorkerVersion](https://github.com/Azure/azure-functions-python-worker/releases/tag/$newWorkerVersion)"
126+
Add-Content -Path release_notes.md -Value "- Update Python Worker Version to [$newWorkerVersion](https://github.com/Azure/azure-functions-python-worker/releases/tag/$newWorkerVersion)"
127127
128128
129129
# Commit Python Version

workers/tests/utils/testutils_docker.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ class WebHostDockerContainerBase(unittest.TestCase):
6868
def find_latest_image(image_repo: str,
6969
image_url: str) -> str:
7070

71-
regex = re.compile(_HOST_VERSION + r'.\d+.\d+-python' + _python_version)
71+
# New regex to match version format: 4.1042.100-4-python3.11
72+
regex = re.compile(_HOST_VERSION
73+
+ r'\.10\d+\.\d+(-\d+)?-python'
74+
+ _python_version + r'(-appservice)?$')
7275

7376
response = requests.get(image_url, allow_redirects=True)
7477
if not response.ok:
@@ -88,8 +91,16 @@ def find_latest_image(image_repo: str,
8891

8992
# sorting all the python versions based on the runtime version and
9093
# getting the latest released runtime version for python.
91-
latest_version = sorted(python_versions, key=lambda x: float(
92-
x.split(_HOST_VERSION + '.')[-1].split("-python")[0]))[-1]
94+
# Parse version format: 4.1042.100-4-python3.11
95+
def parse_version(tag):
96+
# "4.1042.100-4"
97+
version_part = tag.split('-python')[0]
98+
# ["4", "1042", "100", "4"]
99+
parts = version_part.replace('-', '.').split('.')
100+
# (4, 1042, 100, 4)
101+
return tuple(int(p) for p in parts)
102+
103+
latest_version = sorted(python_versions, key=parse_version)[-1]
93104

94105
image_tag = f'{image_repo}:{latest_version}'
95106
return image_tag

0 commit comments

Comments
 (0)