Skip to content
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

Update azure-template to remove extraneous requirements #12770

Closed
wants to merge 4 commits into from
Closed
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
50 changes: 5 additions & 45 deletions eng/common/scripts/artifact-metadata-parsing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,7 @@ function CreateReleases($pkgList, $releaseApiUrl, $releaseSha) {
"Authorization" = "token $($env:GH_TOKEN)"
}

Invoke-WebRequest-WithHandling -url $url -body $body -headers $headers -method "Post"
}
}

function Invoke-WebRequest-WithHandling($url, $method, $body = $null, $headers = $null) {
$attempts = 1

while ($attempts -le 3) {
try {
return Invoke-RestMethod -Method $method -Uri $url -Body $body -Headers $headers
}
catch {
$response = $_.Exception.Response

$statusCode = $response.StatusCode.value__
$statusDescription = $response.StatusDescription

if ($statusCode) {
Write-Host "API request attempt number $attempts to $url failed with statuscode $statusCode"
Write-Host $statusDescription

Write-Host "Rate Limit Details:"
Write-Host "Total: $($response.Headers.GetValues("X-RateLimit-Limit"))"
Write-Host "Remaining: $($response.Headers.GetValues("X-RateLimit-Remaining"))"
Write-Host "Reset Epoch: $($response.Headers.GetValues("X-RateLimit-Reset"))"
}
else {
Write-Host "API request attempt number $attempts to $url failed with no statuscode present, exception follows:"
Write-Host $_.Exception.Response
Write-Host $_.Exception
}

if ($attempts -ge 3) {
Write-Host "Abandoning Request $url after 3 attempts."
exit(1)
}

Start-Sleep -s 10
}

$attempts += 1
Invoke-RestMethod -Uri $url -Body $body -Headers $headers -Method "Post" -MaximumRetryCount 3 -RetryIntervalSec 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be done in azure-sdk-tools to avoid getting overriden?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure how these changes made it in, give that I reset to local master. :/ Re-working.

}
}

Expand Down Expand Up @@ -119,7 +79,7 @@ function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId) {
try {

$uri = "https://oss.sonatype.org/content/repositories/releases/$groupId/$pkgId/$pkgVersion/$pkgId-$pkgVersion.pom"
$pomContent = Invoke-RestMethod -MaximumRetryCount 3 -Method "GET" -uri $uri
$pomContent = Invoke-RestMethod -MaximumRetryCount 3 -RetryIntervalSec 10 -Method "GET" -uri $uri

if ($pomContent -ne $null -or $pomContent.Length -eq 0) {
return $true
Expand Down Expand Up @@ -382,7 +342,7 @@ function ParseCppArtifact($pkg, $workingDirectory) {
# Returns the pypi publish status of a package id and version.
function IsPythonPackageVersionPublished($pkgId, $pkgVersion) {
try {
$existingVersion = (Invoke-RestMethod -MaximumRetryCount 3 -Method "Get" -uri "https://pypi.org/pypi/$pkgId/$pkgVersion/json").info.version
$existingVersion = (Invoke-RestMethod -MaximumRetryCount 3 -RetryIntervalSec 10 -Method "Get" -uri "https://pypi.org/pypi/$pkgId/$pkgVersion/json").info.version

# if existingVersion exists, then it's already been published
return $True
Expand All @@ -406,7 +366,7 @@ function IsPythonPackageVersionPublished($pkgId, $pkgVersion) {
# Retrieves the list of all tags that exist on the target repository
function GetExistingTags($apiUrl) {
try {
return (Invoke-WebRequest -Method "GET" -Uri "$apiUrl/git/refs/tags" -MaximumRetryCount 3 -RetryIntervalSec 10) | % { $_.ref.Replace("refs/tags/", "") }
return (Invoke-RestMethod -Method "GET" -Uri "$apiUrl/git/refs/tags" -MaximumRetryCount 3 -RetryIntervalSec 10) | % { $_.ref.Replace("refs/tags/", "") }
}
catch {
Write-Host $_
Expand Down Expand Up @@ -531,7 +491,7 @@ function CheckArtifactShaAgainstTagsList($priorExistingTagList, $releaseSha, $ap
$unmatchedTags = @()

foreach ($tag in $priorExistingTagList) {
$tagSha = (Invoke-WebRequest-WithHandling -Method "Get" -Url "$apiUrl/git/refs/tags/$tag" -Headers $headers)."object".sha
$tagSha = (Invoke-RestMethod -Method "Get" -MaximumRetryCount 3 -RetryIntervalSec 10 -Uri "$apiUrl/git/refs/tags/$tag" -Headers $headers)."object".sha

if ($tagSha -eq $releaseSha) {
Write-Host "This package has already been released. The existing tag commit SHA $releaseSha matches the artifact SHA being processed. Skipping release step for this tag."
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/update-docs-metadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function GetMetaData($lang){
}
}

$metadataResponse = Invoke-WebRequest-WithHandling -url $metadataUri -method "GET" | ConvertFrom-Csv
$metadataResponse = Invoke-RestMethod -Uri $metadataUri -method "GET" -MaximumRetryCount 3 -RetryIntervalSec 10 | ConvertFrom-Csv

return $metadataResponse
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/template/azure-template/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release History

## 0.0.12 (Unreleased)
- Test a successful Release

## 0.0.7 (2020-07-02)
- Test a successful Release

Expand Down
2 changes: 1 addition & 1 deletion sdk/template/azure-template/azure/template/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# matches SEMVER
VERSION = "0.0.7"
VERSION = "0.0.12"
7 changes: 0 additions & 7 deletions sdk/template/azure-template/sdk_packaging.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
[packaging]
auto_update = false
package_name = "azure-template"
package_pprint_name = "Template Package"
is_stable = false
is_arm = false

# Package owners should uncomment and set this doc id.
# package_doc_id = "<your doc id>"