Skip to content

Commit 6242f91

Browse files
committed
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python into header_tuples
* 'main' of https://github.com/Azure/azure-sdk-for-python: (21 commits) [Key Vault] Add 7.3-preview support for certificates (#20477) Use dummy values and correct code rendering in README (#20322) Use CredScan-suppressed dummy password in sample (#20468) Fix type annotation in azure.storage.blob (#20084) Adding static checks (#20457) release_iseus_status_auto_reply (#20441) Clarify LogsQueryClient query parameter description (#20467) Sync eng/common directory with azure-sdk-tools for PR 1953 (#20466) Skip eng common workflow enforcer for private repos (#20462) remove iter_text and iter_lines (#20460) [ServiceBus] Improve test stability and cpu usage (#20352) t2-Netapp-update-to-2021-06-01 (#20453) [AutoRelease] t2-keyvault-2021-08-26-55443 (#20423) Sync eng/common directory with azure-sdk-tools for PR 1943 (#20450) New dummy password in README (#20328) ensure test principal creation succeeds properly (#20446) Update question-answering readme links (#20439) Stip empty changelog sections before release (#20437) [AutoRelease] t2-healthcareapis-2021-08-26-27542 (#20422) [AutoRelease] t2-iothub-2021-08-25-25696 (#20409) ...
2 parents 6e539a1 + 94225f2 commit 6242f91

File tree

424 files changed

+73470
-14386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+73470
-14386
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ try {
289289
$AzureTestPrincipal
290290
} else {
291291
Log "TestApplicationId was not specified; creating a new service principal in subscription '$SubscriptionId'"
292-
$global:AzureTestPrincipal = New-AzADServicePrincipal -Role Owner -Scope "/subscriptions/$SubscriptionId"
292+
$suffix = (New-Guid).ToString('n').Substring(0, 4)
293+
$global:AzureTestPrincipal = New-AzADServicePrincipal -Role Owner -Scope "/subscriptions/$SubscriptionId" -DisplayName "test-resources-$($baseName)$suffix.microsoft.com"
293294
$global:AzureTestSubscription = $SubscriptionId
294295

295296
Log "Created service principal '$($AzureTestPrincipal.ApplicationId)'"
@@ -477,7 +478,13 @@ try {
477478
&$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters
478479
}
479480

480-
Log "Deploying template '$($templateFile.originalFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'"
481+
$msg = if ($templateFile.jsonFilePath -ne $templateFile.originalFilePath) {
482+
"Deployment template $($templateFile.jsonFilePath) from $($templateFile.originalFilePath) to resource group $($resourceGroup.ResourceGroupName)"
483+
} else {
484+
"Deployment template $($templateFile.jsonFilePath) to resource group $($resourceGroup.ResourceGroupName)"
485+
}
486+
Log $msg
487+
481488
$deployment = Retry {
482489
$lastDebugPreference = $DebugPreference
483490
try {
@@ -538,7 +545,7 @@ try {
538545
Write-Host 'File option is supported only on Windows'
539546
}
540547

541-
$outputFile = "$($templateFile.jsonFilePath).env"
548+
$outputFile = "$($templateFile.originalFilePath).env"
542549

543550
$environmentText = $deploymentOutputs | ConvertTo-Json;
544551
$bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText)

eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ steps:
2121
}
2222
}
2323
displayName: Prevent changes to eng/common outside of azure-sdk-tools repo
24-
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'))
24+
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'), not(endsWith(variables['Build.Repository.Name'], '-pr')))

eng/common/scripts/Prepare-Release.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ else
184184
exit 1
185185
}
186186

187+
$changelogIsValid = Confirm-ChangeLogEntry -ChangeLogLocation $packageProperties.ChangeLogPath -VersionString $newVersion -ForRelease $true
188+
189+
if (!$changelogIsValid)
190+
{
191+
Write-Host "The changelog [$($packageProperties.ChangeLogPath)] is not valid for release. Please make sure it is valid before queuing release build." -ForegroundColor Red
192+
}
193+
187194
git diff -s --exit-code $packageProperties.DirectoryPath
188195
if ($LASTEXITCODE -ne 0)
189196
{

eng/common/scripts/Update-ChangeLog.ps1

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,47 @@ if ($LatestsSorted[0] -ne $Version) {
106106

107107
if ($ReplaceLatestEntryTitle)
108108
{
109-
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $ChangeLogEntries[$LatestVersion].ReleaseContent
109+
# Remove empty sections from content
110+
$sanitizedContent = @()
111+
$sectionContent = @()
112+
$sectionContentCount = 0
113+
$latesVersionContent = $ChangeLogEntries[$LatestVersion].ReleaseContent
114+
115+
foreach ($line in $latesVersionContent)
116+
{
117+
if ($line.StartsWith("### ") -or $sectionContentCount -gt 0)
118+
{
119+
if ($line.StartsWith("#") -and $sectionContentCount -gt 1)
120+
{
121+
$sanitizedContent += $sectionContent
122+
$sectionContent = @()
123+
$sectionContentCount = 0
124+
}
125+
126+
if ($line.StartsWith("#") -and $sectionContentCount -eq 1)
127+
{
128+
$sectionContent = @()
129+
$sectionContentCount = 0
130+
}
131+
132+
$sectionContent += $line
133+
if (-not [System.String]::IsNullOrWhiteSpace($line))
134+
{
135+
$sectionContentCount++
136+
}
137+
}
138+
elseif ($sectionContent.Count -eq 0)
139+
{
140+
$sanitizedContent += $line
141+
}
142+
}
143+
144+
if ($sectionContentCount -gt 1)
145+
{
146+
$sanitizedContent += $sectionContent
147+
}
148+
149+
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $sanitizedContent
110150
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"
111151
$ChangeLogEntries.Remove($LatestVersion)
112152
if ($newChangeLogEntry) {

eng/tox/mypy_hard_failure_packages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"azure-servicebus",
1414
"azure-ai-textanalytics",
1515
"azure-ai-formrecognizer",
16+
"azure-ai-translation-document",
1617
"azure-ai-metricsadvisor",
1718
"azure-eventgrid",
1819
"azure-appconfiguration",

scripts/release_issue_status/main.py

Lines changed: 88 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
from datetime import date, datetime
66
import subprocess as sp
77
from azure.storage.blob import BlobClient
8+
import reply_generator as rg
9+
from update_issue_body import update_issue_body, find_readme_link
10+
import traceback
811

912
_NULL = ' '
1013
_FILE_OUT = 'release_issue_status.csv'
14+
_FILE_OUT_PYTHON = 'release_python_status.md'
1115
_PYTHON_SDK_ADMINISTRATORS = {'msyyc', 'RAY-316', 'BigCat20196'}
1216

13-
1417
def my_print(cmd):
1518
print('==' + cmd + ' ==\n')
1619

@@ -20,6 +23,20 @@ def print_check(cmd):
2023
sp.check_call(cmd, shell=True)
2124

2225

26+
def output_python_md(issue_status_python):
27+
with open(_FILE_OUT_PYTHON, 'w') as file_out:
28+
file_out.write('| issue | author | package | assignee | bot advice | created date of issue | delay from created date |\n')
29+
file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n')
30+
file_out.writelines([item.output_python() for item in sorted(issue_status_python, key=_key_select)])
31+
32+
33+
def output_csv(issue_status):
34+
with open(_FILE_OUT, 'w') as file_out:
35+
file_out.write('language,issue,author,package,created date,delay from created date,latest update time,'
36+
'delay from latest update,status,bot advice\n')
37+
file_out.writelines([item.output() for item in sorted(issue_status, key=_key_select)])
38+
39+
2340
class IssueStatus:
2441
link = _NULL
2542
author = _NULL
@@ -36,6 +53,7 @@ class IssueStatus:
3653
whether_author_comment = True
3754
issue_object = _NULL
3855
labels = _NULL
56+
assignee = _NULL
3957

4058
def output(self):
4159
return '{},{},{},{},{},{},{},{},{},{}\n'.format(self.language, self.link, self.author,
@@ -46,6 +64,13 @@ def output(self):
4664
self.delay_from_latest_update,
4765
self.status, self.bot_advice)
4866

67+
68+
def output_python(self):
69+
return '| [#{}]({}) | {} | {} | {} | {} | {} | {} |\n'.format(self.link.split('/')[-1], self.link, self.author,
70+
self.package, self.assignee, self.bot_advice,
71+
str(date.fromtimestamp(self.create_date)),
72+
self.delay_from_create_date)
73+
4974

5075
def _extract(str_list, key_word):
5176
for item in str_list:
@@ -86,8 +111,7 @@ def _extract_author_latest_comment(comments):
86111
def _whether_author_comment(comments):
87112
q = set(comment.user.login for comment in comments)
88113
diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
89-
90-
return len(diff) > 0
114+
return len(diff) > 0
91115

92116
def _latest_comment_time(comments, delay_from_create_date):
93117
q = [(comment.updated_at.timestamp(), comment.user.login)
@@ -96,13 +120,50 @@ def _latest_comment_time(comments, delay_from_create_date):
96120

97121
return delay_from_create_date if not q else int((time.time() - q[-1][0]) / 3600 / 24)
98122

123+
124+
def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
125+
print("==========new issue number: {}".format(item.issue_object.number))
126+
if 'auto-link' not in item.labels:
127+
try:
128+
package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
129+
print("pkname, readme", package_name, readme_link)
130+
item.package = package_name
131+
key = ('Python', item.package)
132+
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
133+
except Exception as e:
134+
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
135+
item.labels.append('attention')
136+
print(e)
137+
raise
138+
item.labels.append('auto-link')
139+
item.issue_object.set_labels(*item.labels)
140+
else:
141+
try:
142+
readme_link = find_readme_link(sdk_repo, item.issue_object.number)
143+
except Exception as e:
144+
print('Issue: {} updates body failed'.format(item.issue_object.number))
145+
item.bot_advice = 'failed to find Readme link, Please check !!'
146+
item.labels.append('attention')
147+
raise
148+
try:
149+
reply = rg.begin_reply_generate(item=item, rest_repo=rest_repo, readme_link=readme_link)
150+
except Exception as e:
151+
item.bot_advice = 'auto reply failed, Please intervene manually !!'
152+
print('Error from auto reply ========================')
153+
print('Issue:{}'.format(item.issue_object.number))
154+
print(traceback.format_exc())
155+
print('==============================================')
156+
157+
99158
def main():
100159
# get latest issue status
101160
g = Github(os.getenv('TOKEN')) # please fill user_token
102-
repo = g.get_repo('Azure/sdk-release-request')
103-
label1 = repo.get_label('ManagementPlane')
104-
open_issues = repo.get_issues(state='open', labels=[label1])
161+
sdk_repo = g.get_repo('Azure/sdk-release-request')
162+
rest_repo = g.get_repo('Azure/azure-rest-api-specs')
163+
label1 = sdk_repo.get_label('ManagementPlane')
164+
open_issues = sdk_repo.get_issues(state='open', labels=[label1])
105165
issue_status = []
166+
issue_status_python = []
106167
duplicated_issue = dict()
107168
start_time = time.time()
108169
for item in open_issues:
@@ -124,7 +185,9 @@ def main():
124185
issue.issue_object = item
125186
issue.labels = [label.name for label in item.labels]
126187
issue.days_from_latest_commit = _latest_comment_time(item.get_comments(), issue.delay_from_create_date)
127-
188+
if item.assignee:
189+
issue.assignee = item.assignee.login
190+
128191
issue_status.append(issue)
129192
key = (issue.language, issue.package)
130193
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
@@ -135,18 +198,23 @@ def main():
135198
# rule2: if latest comment is from author, need response asap
136199
# rule3: if comment num is 0, it is new issue, better to deal with it asap
137200
# rule4: if delay from latest update is over 7 days, better to deal with it soon.
138-
# rule5: if delay from created date is over 30 days and owner never reply, close it.
139-
# rule6: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
201+
# rule5: if delay from created date is over 30 days, better to close.
202+
# rule6: if delay from created date is over 30 days and owner never reply, close it.
203+
# rule7: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
140204
for item in issue_status:
141205
if item.status == 'release':
142206
item.bot_advice = 'better to release asap.'
143-
elif item.author == item.author_latest_comment:
144-
item.bot_advice = 'new comment for author.'
145-
elif item.comment_num == 0:
207+
elif item.comment_num == 0 and 'Python' in item.labels:
146208
item.bot_advice = 'new issue and better to confirm quickly.'
209+
try:
210+
auto_reply(item, sdk_repo, rest_repo, duplicated_issue)
211+
except Exception as e:
212+
continue
213+
elif not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
214+
item.bot_advice = 'new comment for author.'
147215
elif item.delay_from_latest_update >= 7:
148216
item.bot_advice = 'delay for a long time and better to handle now.'
149-
217+
150218
if item.days_from_latest_commit >= 30 and item.language == 'Python' and '30days attention' not in item.labels:
151219
item.labels.append('30days attention')
152220
item.issue_object.set_labels(*item.labels)
@@ -157,17 +225,17 @@ def main():
157225
' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
158226
item.labels.append('15days attention')
159227
item.issue_object.set_labels(*item.labels)
160-
161-
228+
162229
# judge whether there is duplicated issue for same package
163230
if item.package != _NULL and duplicated_issue.get((item.language, item.package)) > 1:
164231
item.bot_advice = f'Warning:There is duplicated issue for {item.package}. ' + item.bot_advice
232+
233+
if item.language == 'Python':
234+
issue_status_python.append(item)
165235

166236
# output result
167-
with open(_FILE_OUT, 'w') as file_out:
168-
file_out.write('language,issue,author,package,created date,delay from created date,latest update time,'
169-
'delay from latest update,status,bot advice\n')
170-
file_out.writelines([item.output() for item in sorted(issue_status, key=_key_select)])
237+
output_python_md(issue_status_python)
238+
output_csv(issue_status)
171239

172240
# commit to github
173241
print_check('git add .')
@@ -179,7 +247,7 @@ def main():
179247
blob_name=_FILE_OUT)
180248
with open(_FILE_OUT, 'rb') as data:
181249
blob.upload_blob(data, overwrite=True)
182-
250+
183251

184252
if __name__ == '__main__':
185253
main()

0 commit comments

Comments
 (0)