1+ # capture-openapi.yml
12# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
23# The following template creates multiple artifacts from a matrix, this is the intended behavior to follow the same workflow before the governance migration
34
2122 persistCredentials : true
2223
2324 - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
25+
2426 - pwsh : |
2527 $dirPath = "./conversion-settings"
2628 $endpoint = "${{ parameters.endpoint }}"
3739 Write-Host "##vso[task.setvariable variable=targets;isOutput=true]$json"
3840 name: setTargets
3941 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
42+
4043 - script : echo $(setTargets.targets)
4144 displayName : " Print settings"
45+
4246- job : convert_openapi
4347 dependsOn : get_conversion_settings
4448 displayName : Convert
@@ -58,28 +62,33 @@ jobs:
5862 persistCredentials : true
5963
6064 - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
61-
6265 # required for the hidi to run
6366 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6467 parameters :
6568 version : ' 8.x'
66-
67- # required for the hidi installation validation
69+ displayName : use dotnet sdk 8.x
70+ # required for the hidi installation validation
6871 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6972 parameters :
7073 version : ' 9.x'
74+ displayName : use dotnet sdk 9.x
7175
7276 - pwsh : dotnet tool install --global Microsoft.OpenApi.Hidi --version 1.6.24
7377 displayName : install hidi
7478
7579 - pwsh : |
76- git fetch origin master
77- git switch master
80+ git fetch origin master | Write-Host -ForegroundColor Yellow
81+ git switch master | Write-Host -ForegroundColor Yellow
7882 displayName: ensure the generation happens from master latest
7983 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8084
81- - pwsh : ' $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"'
82- displayName : ' update ${{ parameters.endpoint }} open API description'
85+ - pwsh : |
86+ Write-Host "`nGet status before generation:" -ForegroundColor Green
87+ git status | Write-Host -ForegroundColor Yellow
88+ $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
89+ Write-Host "`nGet status after generation:" -ForegroundColor Green
90+ git status | Write-Host -ForegroundColor Yellow
91+ displayName: 'generate ${{ parameters.endpoint }} open API description'
8392 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8493
8594 # publish metadata as an artifact
@@ -88,16 +97,16 @@ jobs:
8897 sourceFolder : ${{ parameters.outputPath }}
8998 contents : ' **/$(Name).yaml'
9099 targetFolder : ' $(Build.ArtifactStagingDirectory)/$(Name)'
91- displayName : Copy generated metadata
100+ displayName : Copy generated OpenAPI yaml file to ArtifactStagingDirectory
101+
92102 - pwsh : |
93103 ./scripts/run-openapi-validation.ps1 -repoDirectory (Get-Location).Path -version "${{ parameters.endpoint }}" -platformName "$(Name)"
94- displayName: ensure that OpenAPI docs can be parsed
104+ displayName: Validate that OpenAPI docs can be parsed
95105 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
96106
97-
98107 - job : publish_openapi
99108 dependsOn : convert_openapi
100- displayName : Publish
109+ displayName : Publish OpenAPI files
101110 # # If there's new settings added please add them here too
102111 templateContext :
103112 inputs :
@@ -123,32 +132,31 @@ jobs:
123132 displayName : checkout generator
124133 fetchDepth : 1
125134 persistCredentials : true
126- # Copy files from the maxtrix artifacts to a single folder
135+
136+ # Note that msgraph-metadata repo has detached HEAD
137+ - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
138+
139+ - template : /.azure-pipelines/generation-templates/set-user-config.yml@self
140+
141+ # Copy OpenAPI files from the matrix artifacts to the ArtifactStagingDirectory
142+ # This is used for library generation later
127143 - task : CopyFiles@2
128144 inputs :
129145 sourceFolder : ' $(Build.SourcesDirectory)/artifacts'
130146 contents : ' **/*.yaml'
131147 targetFolder : ' $(Build.ArtifactStagingDirectory)'
132- displayName : Copy artifact metadata
133- # Copy files from the target path where artifacts should be downloaded
148+ displayName : Copy OpenAPI input artifacts to artifact staging directory
149+
150+ # Copy OpenAPI files from ArtifactStagingDirectory to local msgraph-metadata repo
134151 - task : CopyFiles@2
135152 inputs :
136153 sourceFolder : ' $(Build.ArtifactStagingDirectory)'
137154 contents : ' **/*.yaml'
138155 targetFolder : ' $(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
139- displayName : Copy downloaded metadata
156+ displayName : Copy OpenAPI files to local msgraph- metadata repo
140157
141- # publish metadata as an artifact
142- - task : CopyFiles@2
143- inputs :
144- sourceFolder : ${{ parameters.outputPath }}
145- contents : ' **/*.yaml'
146- targetFolder : ' $(Build.ArtifactStagingDirectory)'
147- displayName : Copy downloaded metadata
148- - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
149- - template : /.azure-pipelines/generation-templates/set-user-config.yml@self
158+ # Push changes to msgraph-metadata repo
150159 - pwsh : ' $(scriptsDirectory)/git-push-cleanmetadata.ps1'
151-
152160 displayName : push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
153161 env :
154162 EndpointVersion : ${{ parameters.endpoint }}
0 commit comments