Skip to content

Commit 5952d5e

Browse files
authored
build: fix release pipeline (#127)
* fix release pipeline * typo * fix cosmos tests * indentation * indentation * only for cosmos tests * add as var * lint
1 parent be0dc1a commit 5952d5e

File tree

8 files changed

+74
-67
lines changed

8 files changed

+74
-67
lines changed

azurefunctions-extensions-bindings-cosmosdb/samples/cosmosdb_samples_containerproxy/function_app.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
"""
1515
FOLDER: cosmosdb_samples_containerproxy
1616
DESCRIPTION:
17-
These samples demonstrate how to obtain a ContainerProxy from a Cosmos DB Input function app binding.
17+
These samples demonstrate how to obtain a ContainerProxy from a Cosmos DB Input
18+
function app binding.
1819
USAGE:
1920
Set the environment variables with your own values before running the
2021
sample:
2122
1) CosmosDBConnection - the connection string to your Cosmos DB instance
2223
23-
Set database_name and container_name to the database name the and container name you want to use
24-
as inputs to the function (required).
24+
Set database_name and container_name to the database name the and container
25+
name you want to use as inputs to the function (required).
2526
"""
2627

2728

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

azurefunctions-extensions-bindings-cosmosdb/samples/cosmosdb_samples_cosmosclient/function_app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"""
1010
FOLDER: cosmosdb_samples_cosmosclient
1111
DESCRIPTION:
12-
These samples demonstrate how to obtain a CosmosClient from a Cosmos DB Input function app binding.
12+
These samples demonstrate how to obtain a CosmosClient from a Cosmos DB Input
13+
function app binding.
1314
USAGE:
1415
Set the environment variables with your own values before running the
1516
sample:

azurefunctions-extensions-bindings-cosmosdb/samples/cosmosdb_samples_databaseproxy/function_app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
"""
1010
FOLDER: cosmosdb_samples_databaseproxy
1111
DESCRIPTION:
12-
These samples demonstrate how to obtain a DatabaseProxy from a Cosmos DB Input function app binding.
12+
These samples demonstrate how to obtain a DatabaseProxy from a Cosmos DB Input
13+
function app binding.
1314
USAGE:
1415
Set the environment variables with your own values before running the
1516
sample:
1617
1) CosmosDBConnection - the connection string to your Cosmos DB instance
1718
18-
Set database_name to the database you want to use as an input to the function (required).
19+
Set database_name to the database you want to use as an input to
20+
the function (required).
1921
"""
2022

2123

eng/ci/extension-release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ extends:
2222
name: 1es-pool-azfunc
2323
image: 1es-windows-2022
2424
os: windows
25-
sdl:
26-
codeSignValidation:
27-
enabled: true
28-
break: true
2925

3026
stages:
3127
- stage: Release

eng/ci/official-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ extends:
4747
dependsOn: Build
4848
jobs:
4949
- template: /eng/templates/official/jobs/unit-tests.yml@self
50+
parameters:
51+
PoolName: 1es-pool-azfunc

eng/ci/public-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ extends:
4747
dependsOn: Build
4848
jobs:
4949
- template: /eng/templates/official/jobs/unit-tests.yml@self
50+
parameters:
51+
PoolName: 1es-pool-azfunc-public

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

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
os: linux
99
steps:
1010
- powershell: |
11+
$githubUser = "$(GithubUser)"
12+
$githubToken = "$(GithubPat)"
1113
$githubToken = "$(GithubPat)"
1214
$newLibraryVersion = "$(NewLibraryVersion)"
1315
$extensionName= "$(ExtensionName)"
@@ -18,6 +20,9 @@ jobs:
1820
git config --global user.name "AzureFunctionsPython"
1921
git config --global user.email "[email protected]"
2022
23+
# Create GitHub credential
24+
$credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${githubUser}:${githubToken}"))
25+
2126
# Heading to Artifact Repository
2227
Write-Host "Operating based on $stagingDirectory/azure-functions-python-extensions"
2328
git checkout -b "$extensionName/release/$newLibraryVersion"
@@ -31,6 +36,21 @@ jobs:
3136
# Create release branch release/X.Y.Z
3237
Write-Host "Creating release branch release/$newLibraryVersion"
3338
git push --repo="https://[email protected]/Azure/azure-functions-python-extensions.git"
39+
40+
# Create PR
41+
Write-Host "Creating PR draft in GitHub"
42+
$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)
43+
$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"
44+
45+
# Return Value
46+
if ($response.StatusCode -ne 201) {
47+
Write-Host "Failed to create PR in Azure Functions Python Extensions"
48+
exit -1
49+
}
50+
51+
$draftUrl = $response | ConvertFrom-Json | Select -expand url
52+
Write-Host "PR draft created in $draftUrl"
53+
3454
} else {
3555
Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
3656
exit -1
@@ -79,6 +99,7 @@ jobs:
7999
80100
# Push tag to remote
81101
git push origin $extensionName/$newLibraryVersion
102+
82103
} else {
83104
Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
84105
exit -1
@@ -153,17 +174,17 @@ jobs:
153174
154175
# Modify Extension $extensionName Version in pyproject.toml
155176
Write-Host "Replacing Extension $extensionName version in worker's pyproject.toml"
156-
((Get-Content pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline pyproject.toml
157-
177+
((Get-Content workers/pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline workers/pyproject.toml
178+
158179
# Commit Python Version
159180
Write-Host "Pushing $newBranch to azure-functions-python-worker repo"
160-
git add pyproject.toml
181+
git add workers/pyproject.toml
161182
git commit -m "build: update $extensionName version to $newLibraryVersion"
162183
git push origin $newBranch
163184
164185
# Create PR
165186
Write-Host "Creating PR draft in GitHub"
166-
$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)
187+
$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)
167188
$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"
168189
169190
# Return Value
@@ -238,34 +259,3 @@ jobs:
238259
exit -1
239260
}
240261
displayName: 'Publish package to pypi.org'
241-
242-
- job: "MergeBack"
243-
dependsOn: ['PyPIPackage']
244-
displayName: 'Merge Back'
245-
steps:
246-
- powershell: |
247-
$githubToken = "$(GithubPat)"
248-
$newLibraryVersion = "$(newLibraryVersion)"
249-
$extensionName= "$(ExtensionName)"
250-
$extensionDirectory = "$(ExtensionDirectory)"
251-
252-
if($newLibraryVersion -match '(\d)+.(\d)+.(\d)+') {
253-
# Create GitHub credential
254-
git config --global user.name "AzureFunctionsPython"
255-
git config --global user.email "[email protected]"
256-
257-
# Clone Repository
258-
git clone https://[email protected]/Azure/azure-functions-python-extensions
259-
Write-Host "Cloned azure-functions-python-extensions into local"
260-
Set-Location "azure-functions-python-extensions"
261-
262-
# Merge back to dev
263-
Write-Host "Merging $extensionName/release/$newLibraryVersion back to dev"
264-
git checkout dev
265-
git merge "origin/$extensionName/release/$newLibraryVersion"
266-
git push origin dev
267-
} else {
268-
Write-Host "newLibraryVersion $newLibraryVersion is malformed (example: 1.1.8)"
269-
exit -1
270-
}
271-
displayName: 'Merge release/x.y.z back to dev'

eng/templates/official/jobs/unit-tests.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
parameters:
2+
- name: PoolName
3+
type: string
4+
default: ''
25
- name: python_versions
36
type: object
47
default:
@@ -57,27 +60,36 @@ jobs:
5760
trigger: $(trigger__blobServiceUri)
5861
displayName: "Run Blob Extension Tests for Python $(PYTHON_VERSION)"
5962
60-
# - job: "CosmosDBTests"
61-
# displayName: "CosmosDB Extension Tests"
62-
# dependsOn: []
63-
# strategy:
64-
# matrix: ${{ parameters.python_versions }}
65-
# condition: always()
66-
# steps:
67-
# - task: UsePythonVersion@0
68-
# inputs:
69-
# versionSpec: $(PYTHON_VERSION)
70-
# - bash: |
71-
# python -m pip install --upgrade pip
72-
# cd azurefunctions-extensions-bindings-cosmosdb
73-
# python -m pip install -U -e .[dev]
74-
# displayName: 'Install CosmosDB Dependencies'
75-
# - bash: |
76-
# python -m pytest -q --instafail azurefunctions-extensions-bindings-cosmosdb/tests/
77-
# env:
78-
# CosmosDBConnection: $(CosmosDBConnection)
79-
# input__accountEndpoint: $(input__accountEndpoint)
80-
# displayName: "Running Cosmos DB $(PYTHON_VERSION) Python Extension Tests"
63+
- job: "CosmosDBTests"
64+
displayName: "CosmosDB Extension Tests"
65+
dependsOn: []
66+
pool:
67+
name: ${{ parameters.PoolName }}
68+
image: 1es-ubuntu-22.04
69+
os: linux
70+
strategy:
71+
matrix: ${{ parameters.python_versions }}
72+
condition: always()
73+
steps:
74+
- task: UsePythonVersion@0
75+
inputs:
76+
versionSpec: $(PYTHON_VERSION)
77+
- bash: |
78+
python -m pip install --upgrade pip
79+
cd azurefunctions-extensions-bindings-cosmosdb
80+
python -m pip install -U -e .[dev]
81+
displayName: 'Install CosmosDB Dependencies'
82+
- bash: |
83+
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
84+
docker run --detach --publish 8081:8081 --publish 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
85+
docker ps
86+
displayName: "Start CosmosDB Emulator"
87+
- bash: |
88+
python -m pytest -q --instafail azurefunctions-extensions-bindings-cosmosdb/tests/
89+
env:
90+
CosmosDBConnection: $(CosmosDBConnection)
91+
input__accountEndpoint: $(input__accountEndpoint)
92+
displayName: "Running Cosmos DB $(PYTHON_VERSION) Python Extension Tests"
8193
8294
- job: "EventHubTests"
8395
displayName: "EventHub Extension Tests"

0 commit comments

Comments
 (0)