|
| 1 | +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. |
| 2 | +# contains an end to end validation pipeline using C# compilation tests for staging beta metadata |
| 3 | +trigger: |
| 4 | + branches: |
| 5 | + include: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + include: |
| 9 | + - schemas/*.csdl |
| 10 | +pr: none |
| 11 | + |
| 12 | +resources: |
| 13 | + repositories: |
| 14 | + - repository: typespec-msgraph |
| 15 | + type: github |
| 16 | + endpoint: microsoftgraph (22) |
| 17 | + name: microsoftgraph/typespec-msgraph |
| 18 | + ref: main |
| 19 | + - repository: typespec-msgraph-reference |
| 20 | + type: git |
| 21 | + name: typespec-msgraph-reference |
| 22 | +variables: |
| 23 | + BuildConfiguration: 'Release' |
| 24 | + scriptsDirectory: '$(Build.SourcesDirectory)\.azure-pipelines\scripts' |
| 25 | + |
| 26 | +extends: |
| 27 | + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates |
| 28 | + parameters: |
| 29 | + pool: |
| 30 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 31 | + vmImage: windows-latest |
| 32 | + stages: |
| 33 | + - stage: build_reference_tool |
| 34 | + dependsOn: [] |
| 35 | + jobs: |
| 36 | + - job: buildReferenceTool |
| 37 | + displayName: "Build Reference Lib Artifact" |
| 38 | + templateContext: |
| 39 | + outputs: |
| 40 | + - output: pipelineArtifact |
| 41 | + targetPath: '$(Build.ArtifactStagingDirectory)' |
| 42 | + artifactName: typespec-reference-tool |
| 43 | + steps: |
| 44 | + - task: UseDotNet@2 |
| 45 | + displayName: 'Use .NET 10' |
| 46 | + inputs: |
| 47 | + version: 10.x |
| 48 | + - checkout: typespec-msgraph-reference |
| 49 | + displayName: checkout typespec-msgraph-reference |
| 50 | + fetchDepth: 1 |
| 51 | + # Install the nuget tool |
| 52 | + - task: NuGetToolInstaller@1 |
| 53 | + displayName: 'Install Nuget dependency manager' |
| 54 | + inputs: |
| 55 | + versionSpec: '>=5.2.0' |
| 56 | + checkLatest: true |
| 57 | + |
| 58 | + - task: NuGetAuthenticate@1 |
| 59 | + |
| 60 | + # Restore dependencies |
| 61 | + - task: DotNetCoreCLI@2 |
| 62 | + displayName: 'Restore dependencies' |
| 63 | + inputs: |
| 64 | + command: restore |
| 65 | + projects: '$(Build.SourcesDirectory)\typespec-msgraph-reference\typespec-msgraph-reference.sln' |
| 66 | + |
| 67 | + # Build the solution |
| 68 | + - task: DotNetCoreCLI@2 |
| 69 | + displayName: 'Build solution' |
| 70 | + inputs: |
| 71 | + command: build |
| 72 | + projects: '$(Build.SourcesDirectory)\typespec-msgraph-reference\typespec-msgraph-reference.sln' |
| 73 | + arguments: '--configuration $(BuildConfiguration) --no-incremental' |
| 74 | + - task: CopyFiles@2 |
| 75 | + inputs: |
| 76 | + sourceFolder: '$(Build.SourcesDirectory)/typespec-msgraph-reference/bin/$(BuildConfiguration)/net10.0' |
| 77 | + contents: '**/*' |
| 78 | + targetFolder: '$(Build.ArtifactStagingDirectory)' |
| 79 | + displayName: Copy Typespec Reference executable |
| 80 | + - stage: generate_reference_lib |
| 81 | + dependsOn: [build_reference_tool] |
| 82 | + jobs: |
| 83 | + - job: generateLibraryFiles |
| 84 | + displayName: "Generating reference library" |
| 85 | + templateContext: |
| 86 | + inputs: |
| 87 | + - input: pipelineArtifact |
| 88 | + buildType: 'current' |
| 89 | + artifactName: 'typespec-reference-tool' |
| 90 | + targetPath: '$(Build.SourcesDirectory)/typespec-reference-tool' |
| 91 | + outputs: |
| 92 | + - output: pipelineArtifact |
| 93 | + targetPath: '$(Build.ArtifactStagingDirectory)/lib' |
| 94 | + artifactName: referenceLibrary |
| 95 | + steps: |
| 96 | + - checkout: self # Add this to checkout msgraph-metadata repo |
| 97 | + displayName: checkout msgraph-metadata |
| 98 | + fetchDepth: 1 |
| 99 | + - pwsh: '$(Build.SourcesDirectory)/.azure-pipelines/scripts/process-all-schemas.ps1 -ExecPath $(Build.SourcesDirectory)/typespec-reference-tool/typespec-msgraph-reference.exe' |
| 100 | + displayName: "Process all the valid schemas files" |
| 101 | + - task: CopyFiles@2 |
| 102 | + inputs: |
| 103 | + sourceFolder: '$(Build.SourcesDirectory)/generated-lib/' |
| 104 | + contents: '**/*' |
| 105 | + targetFolder: '$(Build.ArtifactStagingDirectory)/lib' |
| 106 | + - stage: update_reference_lib |
| 107 | + dependsOn: [generate_reference_lib] |
| 108 | + jobs: |
| 109 | + - job: update_reference_lib |
| 110 | + displayName: "Create PR to update the typespec-msgraph reference lib" |
| 111 | + templateContext: |
| 112 | + inputs: |
| 113 | + - input: pipelineArtifact |
| 114 | + buildType: 'current' |
| 115 | + artifactName: 'referenceLibrary' |
| 116 | + targetPath: '$(Build.SourcesDirectory)/tmp_lib' |
| 117 | + steps: |
| 118 | + - checkout: typespec-msgraph |
| 119 | + displayName: checkout typespec-msgraph |
| 120 | + fetchDepth: 1 |
| 121 | + persistCredentials: true |
| 122 | + - pwsh: | |
| 123 | + git config --global user.email "GraphTooling@service.microsoft.com" |
| 124 | + git config --global user.name "Microsoft Graph DevX Tooling" |
| 125 | + displayName: 'Git: set user config' |
| 126 | + # Copy files from the tmp folder to the checkout repo |
| 127 | + - task: CopyFiles@2 |
| 128 | + inputs: |
| 129 | + sourceFolder: '$(Build.SourcesDirectory)/tmp_lib' |
| 130 | + contents: '**/*' |
| 131 | + targetFolder: '$(Build.SourcesDirectory)/typespec-msgraph/packages/typespec-reference-library/lib' |
| 132 | + overwrite: true |
| 133 | + displayName: Copy OpenAPI files to local typespec-msgraph repo |
| 134 | + # Push changes to Typespec msgraph repo |
| 135 | + - pwsh: '$(scriptsDirectory)/git-push-reference-files.ps1' |
| 136 | + displayName: Publish new generated files to msgraph-metadata repo |
| 137 | + env: |
| 138 | + PublishChanges: True |
| 139 | + workingDirectory: '$(Build.SourcesDirectory)/typespec-msgraph' |
| 140 | + enabled: true |
| 141 | + |
| 142 | + # Create PR |
| 143 | + - task: AzureKeyVault@2 |
| 144 | + displayName: "Azure Key Vault: Get Secrets" |
| 145 | + inputs: |
| 146 | + azureSubscription: "Federated AKV Managed Identity Connection" |
| 147 | + KeyVaultName: akv-prod-eastus |
| 148 | + SecretsFilter: "microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey" |
| 149 | + |
| 150 | + - pwsh: '$(scriptsDirectory)/create-pull-request.ps1' |
| 151 | + displayName: 'Create Pull Request for the generated OpenAPI files for msgraph-metadata' |
| 152 | + env: |
| 153 | + BaseBranch: main |
| 154 | + GeneratePullRequest: true |
| 155 | + GhAppId: $(microsoft-graph-devx-bot-appid) |
| 156 | + GhAppKey: $(microsoft-graph-devx-bot-privatekey) |
| 157 | + OverrideSkipCI: false |
| 158 | + RepoName: 'microsoftgraph/typespec-msgraph' |
| 159 | + ScriptsDirectory: $(scriptsDirectory) |
| 160 | + # Version is intentionally left empty for OpenAPI PRs as versioning is not applicable in this context. |
| 161 | + Version: '' |
| 162 | + workingDirectory: '$(Build.SourcesDirectory)/typespec-msgraph' |
| 163 | + |
| 164 | + |
0 commit comments