Skip to content
3 changes: 3 additions & 0 deletions .azure-pipelines/generation-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ variables:
cleanOpenAPIFileBetaOutputPath: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/beta/'
cleanMetadataFileV1OutputPath: '$(Build.SourcesDirectory)/msgraph-metadata/clean_v10_metadata/'
cleanMetadataFileBetaOutputPath: '$(Build.SourcesDirectory)/msgraph-metadata/clean_beta_metadata/'
metadataTypeSpecAnnotationsSource: '$(Build.SourcesDirectory)/msgraph-metadata/additions/'
cleanMetadataFolderBeta: 'clean_beta_metadata'
cleanMetadataFolderV1: 'clean_v10_metadata'
cleanOpenAPIFolderBeta: 'clean_beta_openapi'
Expand Down Expand Up @@ -218,6 +219,7 @@ stages:
cleanMetadataFile: $(cleanMetadataFileV1)
cleanMetadataFolder: $(cleanMetadataFolderV1)
cleanMetadataFileWithAnnotations: $(cleanMetadataFileWithAnnotationsV1)
metadataTypeSpecAnnotationsSource: $(metadataTypeSpecAnnotationsSource)

# Same description as stage_v1_metadata
- stage: stage_beta_metadata
Expand All @@ -236,6 +238,7 @@ stages:
cleanMetadataFile: $(cleanMetadataFileBeta)
cleanMetadataFolder: $(cleanMetadataFolderBeta)
cleanMetadataFileWithAnnotations: $(cleanMetadataFileWithAnnotationsBeta)
metadataTypeSpecAnnotationsSource: $(metadataTypeSpecAnnotationsSource)

- stage: stage_v1_openapi
dependsOn: stage_v1_metadata
Expand Down
45 changes: 45 additions & 0 deletions .azure-pipelines/generation-templates/capture-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ parameters:
- name: 'cleanMetadataFileWithAnnotations'
type: string
default: $(cleanMetadataFileWithAnnotationsV1)
- name: 'metadataTypeSpecAnnotationsSource'
type: string
default: $(metadataTypeSpecAnnotationsSource)
- name: 'metadataTypeSpecAnnotationsOutputDir'
type: string
default: 'tsp-output'
- name: metadataAnnotationsCopyScriptPath
type: string
default: '/../scripts/copy-annotations-to-csdl.ps1'

steps:

Expand All @@ -39,6 +48,23 @@ steps:
- template: checkout-metadata.yml
- template: set-user-config.yml

# required for TypeSpec
- task: UseNode@1
inputs:
version: '22.x'
checkLatest: true

- pwsh: 'npm install -g @typespec/compiler typescript'
displayName: 'install TypeSpec and TypeScript globally'

- pwsh: 'npm ci'
displayName: 'install TypeSpec dependencies'
workingDirectory: '$(metadataTypeSpecAnnotationsSource)'

- pwsh: 'tsp compile .'
displayName: 'compile TypeSpec annotations'
workingDirectory: '$(metadataTypeSpecAnnotationsSource)'

# Results in a raw metadata file written to microsoftgraph/msgraph-metadata if there are changes.
# An error will cancel this step if there are no changes.
- pwsh: '$(scriptsDirectory)/download-diff-metadata.ps1'
Expand Down Expand Up @@ -70,6 +96,12 @@ steps:
endpointVersion: ${{ parameters.endpoint }}
displayName: 'run Typewriter to clean ${{ parameters.endpoint }} metadata'

- pwsh: '. $(metadataTypeSpecAnnotationsSource)/$Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_$($Env:Endpoint.Replace(''.'', ''''))_metadata/cleanMetadataWithDescriptions${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}
Endpoint: ${{ parameters.endpoint }}
displayName: 'copy TypeSpec annotations to cleaned metadata'

## Only run if the previous step was successful
- pwsh: '$(scriptsDirectory)/run-typewriter-clean-metadata.ps1'
env:
Expand All @@ -85,6 +117,12 @@ steps:
OutputMetadataFileName: 'cleanMetadataWithDescriptionsAndAnnotations'
displayName: 'run Typewriter to clean ${{ parameters.endpoint }} metadata and keep capability annotations'

- pwsh: '. $(metadataTypeSpecAnnotationsSource)/$Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_$($Env:Endpoint.Replace(''.'', ''''))_metadata/cleanMetadataWithDescriptionsAndAnnotations${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}
Endpoint: ${{ parameters.endpoint }}
displayName: 'copy TypeSpec annotations to cleaned metadata'

## Only run if the previous step was successful
- pwsh: '$(scriptsDirectory)/run-typewriter-clean-metadata.ps1'
env:
Expand All @@ -101,6 +139,13 @@ steps:
OutputMetadataFileName: 'cleanMetadataWithDescriptionsAndAnnotationsAndErrors'
displayName: 'run Typewriter to clean ${{ parameters.endpoint }} metadata and keep capability annotations and include error information'

- pwsh: '. $(metadataTypeSpecAnnotationsSource)/$Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_$($Env:Endpoint.Replace(''.'', ''''))_metadata/cleanMetadataWithDescriptionsAndAnnotationsAndErrors${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}
Endpoint: ${{ parameters.endpoint }}
displayName: 'copy TypeSpec annotations to cleaned metadata'


# publish metadata as an artifact
- task: CopyFiles@2
inputs:
Expand Down
Loading