diff --git a/.azure-pipelines/generation-pipeline.yml b/.azure-pipelines/generation-pipeline.yml index 8afce4f14..3460e7abd 100644 --- a/.azure-pipelines/generation-pipeline.yml +++ b/.azure-pipelines/generation-pipeline.yml @@ -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' @@ -218,6 +219,7 @@ stages: cleanMetadataFile: $(cleanMetadataFileV1) cleanMetadataFolder: $(cleanMetadataFolderV1) cleanMetadataFileWithAnnotations: $(cleanMetadataFileWithAnnotationsV1) + metadataTypeSpecAnnotationsSource: $(metadataTypeSpecAnnotationsSource) # Same description as stage_v1_metadata - stage: stage_beta_metadata @@ -236,6 +238,7 @@ stages: cleanMetadataFile: $(cleanMetadataFileBeta) cleanMetadataFolder: $(cleanMetadataFolderBeta) cleanMetadataFileWithAnnotations: $(cleanMetadataFileWithAnnotationsBeta) + metadataTypeSpecAnnotationsSource: $(metadataTypeSpecAnnotationsSource) - stage: stage_v1_openapi dependsOn: stage_v1_metadata diff --git a/.azure-pipelines/generation-templates/capture-metadata.yml b/.azure-pipelines/generation-templates/capture-metadata.yml index 2e0812046..6becdb047 100644 --- a/.azure-pipelines/generation-templates/capture-metadata.yml +++ b/.azure-pipelines/generation-templates/capture-metadata.yml @@ -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: @@ -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' @@ -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: @@ -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: @@ -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: