Skip to content

build: fix release pipeline #127

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 9 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"""
FOLDER: cosmosdb_samples_containerproxy
DESCRIPTION:
These samples demonstrate how to obtain a ContainerProxy from a Cosmos DB Input function app binding.
These samples demonstrate how to obtain a ContainerProxy from a Cosmos DB Input
function app binding.
USAGE:
Set the environment variables with your own values before running the
sample:
1) CosmosDBConnection - the connection string to your Cosmos DB instance

Set database_name and container_name to the database name the and container name you want to use
as inputs to the function (required).
Set database_name and container_name to the database name the and container
name you want to use as inputs to the function (required).
"""


Expand All @@ -31,7 +32,8 @@
database_name="db_name",
container_name="container_name")
def get_docs(req: func.HttpRequest, container: cosmos.ContainerProxy):
docs = container.query_items(query="SELECT * FROM c", enable_cross_partition_query=True)
docs = container.query_items(query="SELECT * FROM c",
enable_cross_partition_query=True)
for d in docs:
logging.info(f"Found document: {d}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"""
FOLDER: cosmosdb_samples_cosmosclient
DESCRIPTION:
These samples demonstrate how to obtain a CosmosClient from a Cosmos DB Input function app binding.
These samples demonstrate how to obtain a CosmosClient from a Cosmos DB Input
function app binding.
USAGE:
Set the environment variables with your own values before running the
sample:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"""
FOLDER: cosmosdb_samples_databaseproxy
DESCRIPTION:
These samples demonstrate how to obtain a DatabaseProxy from a Cosmos DB Input function app binding.
These samples demonstrate how to obtain a DatabaseProxy from a Cosmos DB Input
function app binding.
USAGE:
Set the environment variables with your own values before running the
sample:
1) CosmosDBConnection - the connection string to your Cosmos DB instance
Set database_name to the database you want to use as an input to the function (required).
Set database_name to the database you want to use as an input to
the function (required).
"""


Expand Down
4 changes: 0 additions & 4 deletions eng/ci/extension-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ extends:
name: 1es-pool-azfunc
image: 1es-windows-2022
os: windows
sdl:
codeSignValidation:
enabled: true
break: true

stages:
- stage: Release
Expand Down
2 changes: 2 additions & 0 deletions eng/ci/official-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ extends:
dependsOn: Build
jobs:
- template: /eng/templates/official/jobs/unit-tests.yml@self
parameters:
PoolName: 1es-pool-azfunc
2 changes: 2 additions & 0 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ extends:
dependsOn: Build
jobs:
- template: /eng/templates/official/jobs/unit-tests.yml@self
parameters:
PoolName: 1es-pool-azfunc-public
60 changes: 25 additions & 35 deletions eng/templates/official/jobs/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
os: linux
steps:
- powershell: |
$githubUser = "$(GithubUser)"
$githubToken = "$(GithubPat)"
$githubToken = "$(GithubPat)"
$newLibraryVersion = "$(NewLibraryVersion)"
$extensionName= "$(ExtensionName)"
Expand All @@ -18,6 +20,9 @@ jobs:
git config --global user.name "AzureFunctionsPython"
git config --global user.email "[email protected]"

# Create GitHub credential
$credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${githubUser}:${githubToken}"))

# Heading to Artifact Repository
Write-Host "Operating based on $stagingDirectory/azure-functions-python-extensions"
git checkout -b "$extensionName/release/$newLibraryVersion"
Expand All @@ -31,6 +36,21 @@ jobs:
# Create release branch release/X.Y.Z
Write-Host "Creating release branch release/$newLibraryVersion"
git push --repo="https://[email protected]/Azure/azure-functions-python-extensions.git"

# Create PR
Write-Host "Creating PR draft in GitHub"
$body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion]";draft=$true;maintainer_can_modify=$true;title="build: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress)
$response = Invoke-WebRequest -Headers @{"Cache-Control"="no-cache";"Content-Type"="application/json";"Authorization"="Basic $credential";"Accept"="application/vnd.github.v3+json"} -Method Post -Body "$body" -Uri "https://api.github.com/repos/Azure/azure-functions-python-extensions/pulls"

# Return Value
if ($response.StatusCode -ne 201) {
Write-Host "Failed to create PR in Azure Functions Python Extensions"
exit -1
}

$draftUrl = $response | ConvertFrom-Json | Select -expand url
Write-Host "PR draft created in $draftUrl"

} else {
Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
exit -1
Expand Down Expand Up @@ -79,6 +99,7 @@ jobs:

# Push tag to remote
git push origin $extensionName/$newLibraryVersion

} else {
Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
exit -1
Expand Down Expand Up @@ -153,17 +174,17 @@ jobs:

# Modify Extension $extensionName Version in pyproject.toml
Write-Host "Replacing Extension $extensionName version in worker's pyproject.toml"
((Get-Content pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline pyproject.toml
((Get-Content workers/pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline workers/pyproject.toml

# Commit Python Version
Write-Host "Pushing $newBranch to azure-functions-python-worker repo"
git add pyproject.toml
git add workers/pyproject.toml
git commit -m "build: update $extensionName version to $newLibraryVersion"
git push origin $newBranch

# Create PR
Write-Host "Creating PR draft in GitHub"
$body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion](https://github.com/Azure/azure-functions-python-extensions/releases/tag/$extensionName/$newLibraryVersion)";draft=$true;maintainer_can_modify=$true;title="buikld: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress)
$body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion](https://github.com/Azure/azure-functions-python-extensions/releases/tag/$extensionName/$newLibraryVersion)";draft=$true;maintainer_can_modify=$true;title="build: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress)
$response = Invoke-WebRequest -Headers @{"Cache-Control"="no-cache";"Content-Type"="application/json";"Authorization"="Basic $credential";"Accept"="application/vnd.github.v3+json"} -Method Post -Body "$body" -Uri "https://api.github.com/repos/Azure/azure-functions-python-worker/pulls"

# Return Value
Expand Down Expand Up @@ -238,34 +259,3 @@ jobs:
exit -1
}
displayName: 'Publish package to pypi.org'

- job: "MergeBack"
dependsOn: ['PyPIPackage']
displayName: 'Merge Back'
steps:
- powershell: |
$githubToken = "$(GithubPat)"
$newLibraryVersion = "$(newLibraryVersion)"
$extensionName= "$(ExtensionName)"
$extensionDirectory = "$(ExtensionDirectory)"

if($newLibraryVersion -match '(\d)+.(\d)+.(\d)+') {
# Create GitHub credential
git config --global user.name "AzureFunctionsPython"
git config --global user.email "[email protected]"

# Clone Repository
git clone https://[email protected]/Azure/azure-functions-python-extensions
Write-Host "Cloned azure-functions-python-extensions into local"
Set-Location "azure-functions-python-extensions"

# Merge back to dev
Write-Host "Merging $extensionName/release/$newLibraryVersion back to dev"
git checkout dev
git merge "origin/$extensionName/release/$newLibraryVersion"
git push origin dev
} else {
Write-Host "newLibraryVersion $newLibraryVersion is malformed (example: 1.1.8)"
exit -1
}
displayName: 'Merge release/x.y.z back to dev'
54 changes: 33 additions & 21 deletions eng/templates/official/jobs/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
parameters:
- name: PoolName
type: string
default: ''
- name: python_versions
type: object
default:
Expand Down Expand Up @@ -57,27 +60,36 @@ jobs:
trigger: $(trigger__blobServiceUri)
displayName: "Run Blob Extension Tests for Python $(PYTHON_VERSION)"

# - job: "CosmosDBTests"
# displayName: "CosmosDB Extension Tests"
# dependsOn: []
# strategy:
# matrix: ${{ parameters.python_versions }}
# condition: always()
# steps:
# - task: UsePythonVersion@0
# inputs:
# versionSpec: $(PYTHON_VERSION)
# - bash: |
# python -m pip install --upgrade pip
# cd azurefunctions-extensions-bindings-cosmosdb
# python -m pip install -U -e .[dev]
# displayName: 'Install CosmosDB Dependencies'
# - bash: |
# python -m pytest -q --instafail azurefunctions-extensions-bindings-cosmosdb/tests/
# env:
# CosmosDBConnection: $(CosmosDBConnection)
# input__accountEndpoint: $(input__accountEndpoint)
# displayName: "Running Cosmos DB $(PYTHON_VERSION) Python Extension Tests"
- job: "CosmosDBTests"
displayName: "CosmosDB Extension Tests"
dependsOn: []
pool:
name: ${{ parameters.PoolName }}
image: 1es-ubuntu-22.04
os: linux
strategy:
matrix: ${{ parameters.python_versions }}
condition: always()
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: $(PYTHON_VERSION)
- bash: |
python -m pip install --upgrade pip
cd azurefunctions-extensions-bindings-cosmosdb
python -m pip install -U -e .[dev]
displayName: 'Install CosmosDB Dependencies'
- bash: |
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
docker run --detach --publish 8081:8081 --publish 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
docker ps
displayName: "Start CosmosDB Emulator"
- bash: |
python -m pytest -q --instafail azurefunctions-extensions-bindings-cosmosdb/tests/
env:
CosmosDBConnection: $(CosmosDBConnection)
input__accountEndpoint: $(input__accountEndpoint)
displayName: "Running Cosmos DB $(PYTHON_VERSION) Python Extension Tests"

- job: "EventHubTests"
displayName: "EventHub Extension Tests"
Expand Down