Download PDN with Managed Identity (#4287)

* Use managed identity to download PDN

* fix indentation in yaml

* Specify auth mode and place PDN zip in working directory

* Fix pdn path

* Fix broken escape sequence

* Move condition to if statement, use artifact staging dir

* Use condition instead of if statement

* Fix console arg quoting
This commit is contained in:
Cameron Aavik 2024-07-02 05:47:19 +10:00 коммит произвёл GitHub
Родитель 092b6ddef7
Коммит b16e62227b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 26 добавлений и 17 удалений

Просмотреть файл

@ -50,14 +50,18 @@ jobs:
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- name: internalParam
value: "--internal"
- name: DownloadPdnParameter
value: --download-pdn
- ${{ if and(eq(parameters.osName, 'windows'), ne(parameters.architecture, 'x86')) }}:
- name: PdnPathParameter
value: '--pdn-path "$(Build.ArtifactStagingDirectory)\\PDN.zip"'
- ${{ else }}:
- name: PdnPathParameter
value: ''
- group: DotNet-HelixApi-Access
- group: dotnet-benchview
- ${{ if not(and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'))) }}:
- name: internalParam
value: ''
- name: DownloadPdnParameter
- name: PdnPathParameter
value: ''
workspace:
clean: all
@ -78,7 +82,16 @@ jobs:
steps:
- checkout: self
clean: true
- script: $(Python) scripts/run_performance_job.py --performance-repo-ci --is-scenario --queue ${{ parameters.queue }} --channel $(_Channel) --architecture ${{ parameters.architecture }} --run-kind ${{ parameters.kind }} --affinity ${{ parameters.affinity }} $(runEnvVarsParam) --os-group ${{ parameters.osName }} $(runtimeFlavorParam) $(hybridGlobalizationParam) $(DownloadPdnParameter) --os-version ${{ parameters.osVersion }} $(_DotnetVersionParam) $(internalParam) --project-file $(Build.SourcesDirectory)/eng/performance/${{ parameters.projectFile }}
- task: AzureCLI@2
condition: ne(variables.PdnPathParameter, '')
displayName: 'Download PDN'
inputs:
azureSubscription: '.NET Performance (790c4451-dad9-4fda-af8b-10bd9ca328fa)'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az storage blob download --auth-mode login --account-name pvscmdupload --container-name assets --name paint.net.5.0.3.portable.${{ parameters.architecture }}.zip --file $(Build.ArtifactStagingDirectory)/PDN.zip
- script: $(Python) scripts/run_performance_job.py --performance-repo-ci --is-scenario --queue ${{ parameters.queue }} --channel $(_Channel) --architecture ${{ parameters.architecture }} --run-kind ${{ parameters.kind }} --affinity ${{ parameters.affinity }} $(runEnvVarsParam) --os-group ${{ parameters.osName }} $(runtimeFlavorParam) $(hybridGlobalizationParam) $(PdnPathParameter) --os-version ${{ parameters.osVersion }} $(_DotnetVersionParam) $(internalParam) --project-file $(Build.SourcesDirectory)/eng/performance/${{ parameters.projectFile }}
displayName: Run run_performance_job.py
env:
HelixAccessToken: '$(HelixApiAccessToken)'

Просмотреть файл

@ -99,7 +99,7 @@ class RunPerformanceJobArgs:
use_local_commit_time: bool = False
javascript_engine_path: Optional[str] = None
maui_version: Optional[str] = None
download_pdn: bool = False
pdn_path: Optional[str] = None
os_version: Optional[str] = None
dotnet_version_link: Optional[str] = None
target_csproj: Optional[str] = None
@ -729,18 +729,14 @@ def run_performance_job(args: RunPerformanceJobArgs):
os.path.join(args.performance_repo_dir, "src", "tools", "PerfLabGenericEventSourceLTTngProvider", "build.sh"),
"-o", os.path.join(payload_dir, "PerfLabGenericEventSourceForwarder")]).run()
# download PDN
if args.os_group == "windows" and args.architecture != "x86" and args.download_pdn:
print("Downloading PDN")
escaped_upload_token = str(os.environ.get("PerfCommandUploadTokenLinux")).replace("%25", "%")
pdn_url = f"https://pvscmdupload.blob.core.windows.net/assets/paint.net.5.0.3.portable.{args.architecture}.zip{escaped_upload_token}"
# copy PDN
if args.os_group == "windows" and args.architecture != "x86" and args.pdn_path is not None:
print("Copying PDN")
pdn_dest = os.path.join(payload_dir, "PDN")
os.makedirs(pdn_dest, exist_ok=True)
pdn_file_path = os.path.join(pdn_dest, "PDN.zip")
with urllib.request.urlopen(pdn_url) as response, open(pdn_file_path, "wb") as f:
data = response.read()
f.write(data)
print(f"PDN downloaded to {pdn_file_path}")
os.makedirs(pdn_dest, exist_ok=True)
shutil.copyfile(args.pdn_path, pdn_file_path)
print(f"PDN copied to {pdn_file_path}")
# create a copy of the environment since we want these to only be set during the following invocation
environ_copy = os.environ.copy()
@ -932,8 +928,7 @@ def main(argv: List[str]):
"--ios-strip-symbols": "ios_strip_symbols",
"--hybrid-globalization": "hybrid_globalization",
"--send-to-helix": "send_to_helix",
"--performance-repo-ci": "performance_repo_ci",
"--download-pdn": "download_pdn"
"--performance-repo-ci": "performance_repo_ci"
}
if key in bool_args:
@ -976,6 +971,7 @@ def main(argv: List[str]):
"--os-version": "os_version",
"--dotnet-version-link": "dotnet_version_link",
"--target-csproj": "target_csproj",
"--pdn-path": "pdn_path",
}
if key in simple_arg_map: