Skip to content

Commit ada2778

Browse files
VeryEarlyNoriZCdolauli
authored
[Eng] Added necessary tools/pipelines update to migrate main to future (#27104)
* polish parameter for buildmodules.ps1 * polish * refine build and prepare autorest * remove unused changes * update csproj mapping to add folder generated/, and trim keys * Update CIFilter to remove src/ from mapping keys * add test-module.ps1 in gen2main * add check-dependencies.ps1 in gen2main * add psd1 in gen2main * update az.autorest.props to apply new folder structure * fix submodule name * fix trimmed submodule name * fix trimmed submodule name * add script to migrate generated folder * uncomment * Add readme.azure.md and readme.azure.noprofile.md * migrate readme from eng/archive-test branch * update migration script to add generated csproj in sln * fix previous commit * copy other script from eng/archive-test * fix script * refine build-module.ps1 and add some log * refine log message * color log output * use foreach instead of foreach-object to improve performance * improve write log * fix * question * apply new build process to dotnet msbuild /t:build * test pipeline 1 * test pipeline 2 * test pipeline 3 * test pipeline 4 * test pipeline 5 * test pipeline 6 * test pipeline 7 * test pipeline 8 * test pipeline 9 * test pipeline 10 * test pipeline 11 * test pipeline 12 * test pipeline 12 * test pipeline 13 * test pipeline 14 * test pipeline 15 * test pipeline 16 * test pipeline 17 * test pipeline 18 * test pipeline 19 * test pipeline 20 * test pipeline 21 * test pipeline 22 * test pipeline 23 * test pipeline 24 * test pipeline 25 * test pipeline 26 * test pipeline 27 * test pipeline 28 * test pipeline 29 * test pipeline 30 * test pipeline 31 * test pipeline 32 * test pipeline 33 * split build function to buildscripts.psm1 * Add generate id in generate-info * Add generate id in generate-info * Add generate id in generate-info * regenerate help during adaptautorestmodule * async generate * more async * move resolve tools back * update migrate script * fix path * generate info while migrating main * fix * Remove redundant dependencies for autogen modules * add log output * generate id * fix * revert async * fix * adjust generate id * exit when no generate id * fix * minor fix * fix * update readme.azure.noprofile.md * fixed after build * remove sln when build finish * add migration script * revert autorest dpendency changes * remove redundant * fix * fix * fix * fix * copy src/helpers from generation branch * fix * fix * fix * test * fix * fix * fix * fix * fix * fix * fix * fix * fix * update security tools * typo * fix * fix * fix * fix * update reference of csproj in resource.test.csproj * fix * update references of autorest modules for resource.sln * move removeunwanted and updatemodule to buildscript * polish parameter name for build script * add switch invokedbypipeline * trigger new pipeline for future branch by default * add accounts in build by default * fix * fix * build version controller during build script * fix * Update security-tools.yml * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * Update MigrateGenerated.ps1 * add accounts to build/test by default for CIPlan parameterset * Update AdaptAutorestModule.ps1 * Update AdaptAutorestModule.ps1 * do not add testfx specificly because it was already included for all test project * split build solution and test solution * add parent module csproj to module root sln for new module * fix incorrect parent module csproj name * fix incorrect help refresh for new module * fix * prepare autorest modules before calculate csproj to build * fix calculate generated files for new submodule * remove PR analyze that block PR has changes in both /src and /generated * remove files accidentally checked in * rename x.autorest/help -> x.autorest/docs * update pipeline * update build for daily-build.yml * new doc (unfinished) * finish new docs * update PR title * update * update * update * update * do not exit when pr analyze failed, write warning instead * remove generated ps1 script from autorest submodules during future migration * add assembly info attributes in readme.azure.noprofile.md * allow resources to be checked in * add git files to each autorest submodule during migration * disable assemblyinfo generate * add final block in after build task * replace module version for submodule assemblyinfo * reset assemblyinfo in finally block after re-compile * bugfix * polish file move * fix * skip livetests filder * fix * assemblyinfo * copy assemblyinfo separately * fix * check whether assemblyinfo existed before modifying it * fix child module path when add to sln * keep guid in psd1 under generated folder unchanged * update afterbuild task to take module-name instead of service-name * split archive pipeline from build-steps * refactor cifiltertask * refactor pipelines * move yml of archive pipeline * forgot function * pr validation pipeline won't be triggered by CI * fix path for util templates * fix array accidentally casted to string * fix branch name * fix parameter name for build-steps * add terminate condition when no files changed detected in archive pipeline * add helpers to not modules list * add helpers to not modules list * move helpers folder from generation branch * fix condition in yml * do use exit 0 when terminate * try to fix terminate condition * fix switch syntax * try to fix terminate condition * try to fix terminate condition * have to fail archive when no outdated modules found * remove duplicate warning message * fix * fix * enable new build process for windows-powershell.yml * remove duplicate warning message * use dotnet 8 for credscan * fix security tools pipeline * use batch ci trigger archive pipeline * refactor archive pipeline * add branch name filter, get token with internal method * add doc for future branch PR migration * add doc for future branch PR migration * removed migration docs * enable new ci/pr pipelines for all branches * add README.md for pipelinesteps scripts --------- Co-authored-by: Nori Zhang <[email protected]> Co-authored-by: NoriZC <[email protected]> Co-authored-by: Xiaogang Ding <[email protected]>
1 parent 715a440 commit ada2778

Some content is hidden

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

41 files changed

+3138
-344
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Pipeline Steps
2+
3+
This directory contains the PowerShell scripts refactored from ".azure-pipelines/util".
4+
5+
## Overview
6+
7+
The pipeline steps are refactored from yml based templates from ".azure-pipelines/util" to PowerShell scripts. This is designed for converting some Azure Devops pipelines to github action.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright Microsoft Corporation
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
# ----------------------------------------------------------------------------------
12+
[CmdletBinding(DefaultParameterSetName="AllSet")]
13+
param (
14+
[string]$RepoRoot,
15+
[string]$Configuration = 'Debug',
16+
[string]$PowerShellPlatform
17+
)
18+
19+
# Install PowerShell dependencies
20+
Write-Host -ForegroundColor Green "-------------------- Start installing PowerShell dependencies ... --------------------"
21+
Install-Module "platyPS", "PSScriptAnalyzer" -Repository PSGallery -Force -Confirm:$false -Scope CurrentUser
22+
Write-Host -ForegroundColor DarkGreen "-------------------- End installing PowerShell dependencies ... --------------------`n`n`n`n`n"
23+
24+
# Install latest Az modules
25+
Write-Host -ForegroundColor Green "-------------------- Start installing latest Az modules ... --------------------"
26+
New-Item -ItemType Directory -Path "Az-Cmdlets-latest"
27+
Invoke-WebRequest -Uri "https://azpspackage.blob.core.windows.net/release/Az-Cmdlets-latest.tar.gz" -OutFile "Az-Cmdlets-latest/Az-Cmdlets-latest.tar.gz" -MaximumRetryCount 2 -RetryIntervalSec 1
28+
tar -xvzf "Az-Cmdlets-latest/Az-Cmdlets-latest.tar.gz" -C "Az-Cmdlets-latest"
29+
& Az-Cmdlets-latest/InstallModule.ps1
30+
Write-Host -ForegroundColor DarkGreen "-------------------- End installing latest Az modules ... --------------------`n`n`n`n`n"
31+
32+
# Generate help
33+
Write-Host -ForegroundColor Green "-------------------- Start generating help ... --------------------"
34+
if ($PowerShellPlatform) {
35+
$Env:PowerShellPlatform = $PowerShellPlatform
36+
}
37+
$buildProjPath = Join-Path $RepoRoot 'build.proj'
38+
dotnet msbuild $buildProjPath /t:GenerateHelp "/p:Configuration=$Configuration"
39+
Write-Host -ForegroundColor DarkGreen "-------------------- End generating help ... --------------------`n`n`n`n`n"
40+
41+
# Static Analysis
42+
Write-Host -ForegroundColor Green "-------------------- Start static analysis ... --------------------"
43+
dotnet msbuild $buildProjPath /t:StaticAnalysis "/p:Configuration=$Configuration"
44+
Write-Host -ForegroundColor DarkGreen "-------------------- End static analysis ... --------------------`n`n`n`n`n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
[CmdletBinding(DefaultParameterSetName="AllSet")]
15+
param (
16+
[string]$RepoRoot,
17+
[string]$Configuration = 'Debug',
18+
[string]$PowerShellPlatform,
19+
[string]$FilesChangedOutputPath,
20+
[boolean]$ForceRegenerate = $false,
21+
[string]$SubTasksFilePath,
22+
[boolean]$IsSecurityCheck,
23+
[string]$BuildReason,
24+
[string]$Trigger
25+
)
26+
27+
# filter changed files
28+
Write-Host -ForegroundColor Green "-------------------- Start filtering changed files ... --------------------"
29+
$buildProjPath = Join-Path $RepoRoot 'build.proj'
30+
if ($PowerShellPlatform) {
31+
$Env:PowerShellPlatform = $PowerShellPlatform
32+
}
33+
dotnet msbuild $buildProjPath /t:FilterBuild "/p:FilesChangedOutputPath=$FilesChangedOutputPath;SubTasksFilePath=$SubTasksFilePath;IsSecurityCheck=$IsSecurityCheck"
34+
Write-Host -ForegroundColor DarkGreen "-------------------- End filtering changed files ... --------------------`n`n`n`n`n"
35+
36+
# Set subtasks
37+
if (Test-Path $SubTasksFilePath) {
38+
Write-Host -ForegroundColor Green "-------------------- Start setting subtasks ... --------------------"
39+
Get-Content $SubTasksFilePath | ForEach-Object {
40+
if ($_ && 'Predictor' -eq $_) {
41+
$subTaskPredictor = $true
42+
} elseif ($_ && 'Installer' -eq $_) {
43+
Write-Host "##vso[task.setvariable variable=SubTaskInstaller]true"
44+
$subTaskInstaller = $true
45+
} elseif ($_ && 'all' -eq $_) {
46+
$subTaskAll = $true
47+
}
48+
}
49+
Write-Host -ForegroundColor DarkGreen "-------------------- End setting subtasks ... --------------------`n`n`n`n`n"
50+
}
51+
52+
# Analyze changed files
53+
Write-Host -ForegroundColor Green "-------------------- Start Analyzing changed files ... --------------------"
54+
Write-Host "##1. Check generate-info.json for autorest generated modules" -ForegroundColor Magenta
55+
$noGenerateInfo = @()
56+
$modules = Get-Content $FilesChangedOutputPath -OutVariable paths | Foreach-Object { if($_ -match "^src.*\.Autorest"){ Write-Output $Matches[0] } } | Select-Object -Unique
57+
foreach ($module in $modules) {
58+
$hasGenerateInfo = $false
59+
$pattern = "^$module/generate-info.json"
60+
foreach ($path in $paths) {
61+
if ($path -match $pattern) {
62+
$hasGenerateInfo = $true
63+
}
64+
}
65+
if (-not $hasGenerateInfo) {
66+
$noGenerateInfo += $module
67+
}
68+
}
69+
if ($noGenerateInfo -and $noGenerateInfo.Count -gt 0) {
70+
$noGenerateInfo | Foreach-Object { Write-Warning "No generate-info.json detected for $_." }
71+
}
72+
73+
# this might not be true, for example when release branch or preview branch merge back to main branch, it's possible changes present in both /src and /generated
74+
Write-Host "##2. PR should contain changes from either /src or /generated only" -ForegroundColor Magenta
75+
$content = Get-Content $FilesChangedOutputPath
76+
$srcFiles = $content | Where-Object { $_ -match "^src.*" }
77+
$generatedFiles = $content | Where-Object { $_ -match "^generated.*" }
78+
if ($srcFiles -and $srcFiles.Count -gt 0 -and $generatedFiles -and $generatedFiles.Count -gt 0) {
79+
Write-Warning "PR should contain changes from either /src or /generated only."
80+
}
81+
Write-Host -ForegroundColor DarkGreen "-------------------- End Analyzing changed files ... --------------------`n`n`n`n`n"
82+
83+
# Check ignored files
84+
Write-Host -ForegroundColor Green "-------------------- Start checking ignored files ... --------------------"
85+
$checkIgnoreFilesScriptPath = Join-Path $RepoRoot 'tools' 'CheckIgnoredFile.ps1'
86+
& $checkIgnoreFilesScriptPath
87+
Write-Host -ForegroundColor DarkGreen "-------------------- End checking ignored files ... --------------------`n`n`n`n`n"
88+
89+
# Build
90+
Write-Host -ForegroundColor Green "-------------------- Start building modules ... --------------------"
91+
$buildScriptPath = Join-Path $RepoRoot 'tools' 'BuildScripts' 'BuildModules.ps1'
92+
if ('Manual' -eq $BuildReason -and $ForceRegenerate) {
93+
& $buildScriptPath -CIPlan -RepoRoot $RepoRoot -Configuration $Configuration -ForceRegenerate -InvokedByPipeline
94+
} else {
95+
& $buildScriptPath -CIPlan -RepoRoot $RepoRoot -Configuration $Configuration -InvokedByPipeline
96+
}
97+
Write-Host -ForegroundColor DarkGreen "-------------------- End building modules ... --------------------`n`n`n`n`n"
98+
99+
# Write pipeline result
100+
Write-Host -ForegroundColor Green "-------------------- Start writing pipeline result ... --------------------"
101+
$pipelineScript = Join-Path $RepoRoot 'tools' 'ExecuteCIStep.ps1'
102+
$repoArtifact = Join-Path $RepoRoot 'artifacts'
103+
& $pipelineScript -Build -TriggerType $BuildReason -Trigger $Trigger -RepoArtifacts $repoArtifact -Configuration $Configuration
104+
Write-Host -ForegroundColor DarkGreen "-------------------- End writing pipeline result ... --------------------`n`n`n`n`n"
105+
106+
# Build Az.Tools.Predictor
107+
if ($subTaskPredictor -or $subTaskAll) {
108+
Write-Host -ForegroundColor Green "-------------------- Start building Az.Tools.Predictor ... --------------------"
109+
dotnet msbuild $buildProjPath /t:AzToolsPredictor
110+
Write-Host -ForegroundColor DarkGreen "-------------------- End building Az.Tools.Predictor ... --------------------`n`n`n`n`n"
111+
}
112+
113+
# Build Az.Tools.Installer
114+
if ($subTaskInstaller -or $subTaskAll) {
115+
Write-Host -ForegroundColor Green "-------------------- Start building Az.Tools.Installer ... --------------------"
116+
dotnet msbuild $buildProjPath /t:AzToolsInstaller
117+
Write-Host -ForegroundColor DarkGreen "-------------------- End building Az.Tools.Installer ... --------------------`n`n`n`n`n"
118+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright Microsoft Corporation
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
# ----------------------------------------------------------------------------------
12+
[CmdletBinding(DefaultParameterSetName="AllSet")]
13+
param (
14+
[string]$RepoRoot,
15+
[string]$PowerShellPlatform,
16+
[string]$TestFramework,
17+
[string]$Configuration = 'Debug'
18+
)
19+
20+
# Remove pre-installed Az modules
21+
Write-Host -ForegroundColor Green "-------------------- Start removing pre-installed Az modules ... --------------------"
22+
$commonUtilityScriptPath = Join-Path $RepoRoot "tools" "TestFx" "Utilities" "CommonUtility.ps1"
23+
& $commonUtilityScriptPath
24+
Write-Host -ForegroundColor DarkGreen "-------------------- End removing pre-installed Az modules ... --------------------`n`n`n`n`n"
25+
26+
# Test
27+
Write-Host -ForegroundColor Green "-------------------- Start testing ... --------------------"
28+
if ($PowerShellPlatform) {
29+
$Env:PowerShellPlatform = $PowerShellPlatform
30+
}
31+
$preference = $ErrorActionPreference
32+
$ErrorActionPreference = 'Continue'
33+
$buildProjPath = Join-Path $RepoRoot 'build.proj'
34+
dotnet msbuild $buildProjPath /t:Test "/p:Configuration=$Configuration;TestFramework=$TestFramework"
35+
Write-Host -ForegroundColor DarkGreen "-------------------- End testing ... --------------------`n`n`n`n`n"
36+
37+
# Test AutoGen Modules With PowerShell Core
38+
Write-Host -ForegroundColor Green "-------------------- Start testing AutoGen modules with PowerShell Core ... --------------------"
39+
$executeCIStepScriptPath = Join-Path $RepoRoot "tools" "ExecuteCIStep.ps1"
40+
$currentPath = $PWD
41+
$debugFolderPath = Join-Path $RepoRoot "artifacts" "Debug"
42+
Set-Location $debugFolderPath
43+
44+
Install-Module -Name Pester -Repository PSGallery -RequiredVersion 4.10.1 -Force
45+
if ($IsWindows) { $sp = ";" } else { $sp = ":" }
46+
$env:PSModulePath = $env:PSModulePath + $sp + (pwd).Path
47+
Get-ChildItem -File -Recurse test-module.ps1 | ForEach-Object {
48+
Write-Host $_.Directory.FullName
49+
$repoArtifact = Join-Path $RepoRoot 'artifacts'
50+
& $executeCIStepScriptPath -TestAutorest -AutorestDirectory $_.Directory.FullName -RepoArtifacts $repoArtifact
51+
}
52+
53+
$ErrorActionPreference = $preference
54+
Set-Location $currentPath
55+
Write-Host -ForegroundColor DarkGreen "-------------------- End testing AutoGen modules with PowerShell Core ... --------------------`n`n`n`n`n"
56+
57+
# Analyze test coverage
58+
Write-Host -ForegroundColor Green "-------------------- Start analyzing test coverage ... --------------------"
59+
$validateTestCoverageScriptPath = Join-Path $RepoRoot 'tools' 'TestFx' 'Coverage' 'ValidateTestCoverage.ps1'
60+
& $validateTestCoverageScriptPath
61+
Write-Host -ForegroundColor DarkGreen "-------------------- End analyzing test coverage ... --------------------`n`n`n`n`n"
62+
63+
# Check test status
64+
Write-Host -ForegroundColor Green "-------------------- Start checking test status ... --------------------"
65+
$currentPath = $PWD
66+
$pipelineResultPath = Join-Path $RepoRoot "artifacts" "PipelineResult"
67+
Set-Location $pipelineResultPath
68+
69+
$PipelineResult = Get-Content PipelineResult.json | ConvertFrom-Json
70+
$FailedModuleList = $PipelineResult.test.Details[0].Modules | Where-Object { $_.Status -eq "Failed" } | ForEach-Object { $_.Module }
71+
if ($FailedModuleList.Length -ne 0)
72+
{
73+
throw "test fails in module: $FailedModuleList"
74+
}
75+
76+
Set-Location $currentPath
77+
Write-Host -ForegroundColor DarkGreen "-------------------- End checking test status ... --------------------`n`n`n`n`n"

0 commit comments

Comments
 (0)