Skip to content

Commit 24a0a8e

Browse files
committed
ci update logging
1 parent 4c2f858 commit 24a0a8e

File tree

4 files changed

+57
-49
lines changed

4 files changed

+57
-49
lines changed

.azure-pipelines/generation-templates/capture-openapi.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ jobs:
7676
displayName: install hidi
7777

7878
- pwsh: |
79-
git fetch origin master | Write-Host -ForegroundColor Yellow
80-
git switch master | Write-Host -ForegroundColor Yellow
79+
git fetch origin master
80+
git switch master
8181
displayName: ensure the generation happens from master latest
8282
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8383
8484
- pwsh: |
85-
Write-Host "`nGet status before generation:" -ForegroundColor Green
86-
git status | Write-Host -ForegroundColor Yellow
85+
Write-Host "`ngit status before generation:"
86+
git status
8787
$(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
88-
Write-Host "`nGet status after generation:" -ForegroundColor Green
89-
git status | Write-Host -ForegroundColor Yellow
88+
Write-Host "`ngit status after generation:"
89+
git status
9090
displayName: 'generate ${{ parameters.endpoint }} open API description'
9191
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
9292
@@ -153,6 +153,8 @@ jobs:
153153
contents: '**/*.yaml'
154154
targetFolder: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
155155
displayName: Copy OpenAPI files to local msgraph-metadata repo
156+
overwrite: true
157+
156158

157159
# Push changes to msgraph-metadata repo and create PR
158160
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
@@ -163,6 +165,7 @@ jobs:
163165
PublishChanges: $(publishChanges)
164166
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
165167
enabled: true
168+
166169

167170
# Create PR - note that this PR is not used for gating. It's just for discovery purposes.
168171
# Library generation PRs will still be created based on the OpenAPI files.

scripts/create-pull-request.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
if (($env:OverrideSkipCI -eq $False) -and ($env:BUILD_REASON -eq 'Manual')) # Skip CI if manually running this pipeline.
22
{
3-
Write-Host "Skipping pull request creation due Skip CI." -ForegroundColor Green
3+
Write-Host "Skipping pull request creation due Skip CI."
44
return;
55
}
66

77
if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this pipeline.
8-
Write-Host "Skipping pull request creation due this repository being disabled" -ForegroundColor Green
8+
Write-Host "Skipping pull request creation due this repository being disabled"
99
return;
1010
}
1111

@@ -33,10 +33,10 @@ if (![string]::IsNullOrEmpty($env:BaseBranch))
3333
# The installed application is required to have the following permissions: read/write on pull requests/
3434
$tokenGenerationScript = "$env:ScriptsDirectory\Generate-Github-Token.ps1"
3535
$env:GITHUB_TOKEN = & $tokenGenerationScript -AppClientId $env:GhAppId -AppPrivateKeyContents $env:GhAppKey -Repository $env:RepoName
36-
Write-Host "Fetched Github Token for PR generation and set as environment variable." -ForegroundColor Green
36+
Write-Host "Fetched Github Token for PR generation and set as environment variable."
3737

3838
# No need to specify reviewers as code owners should be added automatically.
3939
Invoke-Expression "gh auth login" # login to GitHub
4040
Invoke-Expression "gh pr create -t ""$title"" -b ""$body"" $baseBranchParameter | Write-Host"
4141

42-
Write-Host "Pull Request Created successfully." -ForegroundColor Green
42+
Write-Host "Pull Request Created successfully."

scripts/generate-open-api.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ param(
2121
[parameter(Mandatory = $true)][String]$platformName
2222
)
2323

24+
Write-Host "Starting $endpointVersion OpenAPI generation for $platformName using generate-open-api.ps1"
25+
2426
$outputFile = Join-Path "./" "openapi" $endpointVersion "$platformName.yaml"
2527
$oldOutputFile = "$outputFile.old"
2628
$cleanVersion = $endpointVersion.Replace(".", "")
@@ -34,23 +36,24 @@ if($platformName -eq "openapi")
3436
$fileName = "$baseFileName$endpointVersion.xml";
3537

3638
$inputFile = Join-Path "./" "clean_$($cleanVersion)_metadata" "$fileName"
37-
Write-Host "Settings: $settings"
38-
Write-Verbose "Generating OpenAPI description from $inputFile"
39-
Write-Verbose "Output file: $outputFile"
39+
Write-Host "`nSettings: $settings"
40+
Write-Host "Generating OpenAPI description from $inputFile"
41+
Write-Host "Output file: $outputFile"
4042

4143
if(Test-Path $outputFile)
4244
{
43-
Write-Verbose "Removing existing output file"
45+
Write-Host "`nRemoving existing output file"
4446
if(Test-Path $oldOutputFile)
4547
{
46-
Write-Verbose "Removing existing old output file"
48+
Write-Host "Removing existing old output file: $oldOutputFile"
4749
Remove-Item $oldOutputFile -Force
4850
}
4951
$oldFileName = Split-Path $outputFile -leaf
5052
$oldFileName += ".old"
5153
Rename-Item $outputFile $oldFileName
5254
}
5355

56+
Write-Host "`nGenerating OpenAPI description using hidi..."
5457
$command = "hidi transform --csdl ""$inputFile"" --output ""$outputFile"" --settings-path ""$settings"" --version ""3.0"" --metadata-version ""$endpointVersion"" --log-level Information --format yaml"
5558
Write-Host $command
5659

@@ -62,16 +65,18 @@ try {
6265
Set-Content $outputFile $updatedContent -NoNewline
6366
if(Test-Path $oldOutputFile)
6467
{
65-
Write-Verbose "Removing existing old output file"
68+
Write-Host "`nRemoving existing old output file: $oldOutputFile"
6669
Remove-Item $oldOutputFile -Force
6770
}
71+
Write-Host "Completed generating OpenAPI description using hidi"
6872
} catch {
6973
if(Test-Path $oldOutputFile)
7074
{
71-
Write-Warning "Restoring old output file"
75+
Write-Host "`nRestoring old output file: $oldOutputFile"
7276
$originalFileName = Split-Path $outputFile -leaf
7377
Rename-Item $oldOutputFile $originalFileName
7478
}
7579
Write-Error "Error generating OpenAPI description: $_"
7680
throw $_
7781
}
82+

scripts/git-push-cleanmetadata.ps1

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,71 @@
1111

1212
if ($env:PublishChanges -eq $False)
1313
{
14-
Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Yellow
14+
Write-Host "Not publishing changes per the run parameter!"
1515
return;
1616
}
1717

18-
Write-Host "`nGet status:" -ForegroundColor Green
19-
git status | Write-Host -ForegroundColor Yellow
18+
Write-Host "`ngit status:"
19+
git status | Write-Host
2020

21-
Write-Host "`nStash the update metadata files.....`nRunning: git stash" -ForegroundColor Green
22-
git stash | Write-Host -ForegroundColor Yellow
21+
Write-Host "`nStash the update metadata files.....`nRunning: git stash"
22+
git stash | Write-Host
2323

24-
Write-Host "`nFetching latest master branch to ensure we are up to date..." -ForegroundColor Green
25-
git fetch origin master | Write-Host -ForegroundColor Yellow
24+
Write-Host "`nFetching latest master branch to ensure we are up to date..."
25+
git fetch origin master | Write-Host
2626
# checkout master to move from detached HEAD mode
27-
git switch master | Write-Host -ForegroundColor Yellow
27+
git switch master | Write-Host
2828

29-
Write-Host "`nGet status:" -ForegroundColor Green
30-
git status | Write-Host -ForegroundColor Yellow
29+
Write-Host "`ngit status:"
30+
git status | Write-Host
3131

32-
Write-Host "`nApply stashed metadata files...`nRunning: git stash pop" -ForegroundColor Green
33-
git stash pop | Write-Host -ForegroundColor Yellow
32+
Write-Host "`nApply stashed metadata files...`nRunning: git stash pop"
33+
git stash pop | Write-Host
3434

35-
Write-Host "`nGet status:" -ForegroundColor Green
36-
git status | Write-Host -ForegroundColor Yellow
35+
Write-Host "`ngit status:"
36+
git status | Write-Host
3737

3838
if ($env:CreatePR -eq $True)
3939
{
40-
Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI" -ForegroundColor Green
41-
git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
40+
Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI"
41+
git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host
4242
}
4343

44-
Write-Host "`nStaging clean $env:EndpointVersion metadata files....." -ForegroundColor Green
45-
git add . | Write-Host -ForegroundColor Yellow
44+
Write-Host "`nStaging clean $env:EndpointVersion metadata files.....`nRunning: git add ."
45+
git add . | Write-Host
4646

47-
Write-Host "`nGet status:" -ForegroundColor Green
48-
git status | Write-Host -ForegroundColor Yellow
47+
Write-Host "`ngit status:"
48+
git status | Write-Host
4949

50-
Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....." -ForegroundColor Green
50+
Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....."
5151

5252
if ($env:BUILD_REASON -eq 'Manual') # Skip CI if manually running this pipeline.
5353
{
54-
git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host -ForegroundColor Yellow
54+
git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host
5555
}
5656
else
5757
{
58-
git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host -ForegroundColor Yellow
58+
git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host
5959
}
6060

61-
Write-Host "`nGet status:" -ForegroundColor Green
62-
git status | Write-Host -ForegroundColor Yellow
61+
Write-Host "`ngit status:"
62+
git status | Write-Host
6363

6464
if ($env:CreatePR -eq $True)
6565
{
66-
Write-Host "`nPushing branch for PR creation" -ForegroundColor Green
66+
Write-Host "`nPushing branch for PR creation"
6767

68-
Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:" -ForegroundColor Green
69-
git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
68+
Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:"
69+
git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host
7070
}
7171
else # original behavior: push to master
7272
{
73-
Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
73+
Write-Host "`nRunning: git pull origin master --rebase..."
7474
# sync branch before pushing
7575
# this is especially important while running v1 and beta in parallel
7676
# and one process goes out of sync because of the other's check-in
77-
git pull origin master --rebase | Write-Host -ForegroundColor Yellow
77+
git pull origin master --rebase | Write-Host
7878

79-
Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
80-
git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
79+
Write-Host "`nRunning: git push --set-upstream origin master ..."
80+
git push --set-upstream origin master | Write-Host
8181
}

0 commit comments

Comments
 (0)