Skip to content

ci/ts annotations #1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
42 changes: 42 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,18 @@ 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: $[format('{0}/../scripts/copy-annotations-to-csdl.ps1', parameters['metadataTypeSpecAnnotationsSource'])]
- name: sanitizedEndpoint
type: string
default: $[replace(parameters['endpoint'], '/', ''))]

steps:

Expand All @@ -39,6 +51,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 +99,10 @@ steps:
endpointVersion: ${{ parameters.endpoint }}
displayName: 'run Typewriter to clean ${{ parameters.endpoint }} metadata'

- pwsh: '. $Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_${{ parameters.sanitizedEndpoint }}_metadata/cleanMetadataWithDescriptions${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}

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

- pwsh: '. $Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_$(sanitizedEndpoint)_metadata/cleanMetadataWithDescriptionsAndAnnotations${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}

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

- pwsh: '. $Env:ScriptPath -targetCsdlPath "$(Build.SourcesDirectory)/msgraph-metadata/clean_$(sanitizedEndpoint)_metadata/cleanMetadataWithDescriptionsAndAnnotationsAndErrors${{ parameters.endpoint }}.xml" -sourceCsdlDirectoryPath "$(metadataTypeSpecAnnotationsSource)/${{ parameters.metadataTypeSpecAnnotationsOutputDir }}"'
env:
ScriptPath: ${{ parameters.metadataAnnotationsCopyScriptPath }}


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