Skip to content

Commit 07a14f8

Browse files
Sync eng/common directory with azure-sdk-tools for PR 10293 (#33810)
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#10293 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow) --------- Co-authored-by: jolov <[email protected]>
1 parent 2d0f5b0 commit 07a14f8

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

eng/common/pipelines/templates/archetype-typespec-emitter.yml

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ parameters:
6767
type: object
6868
default: []
6969

70-
- name: EmitterPackageJsonPath
70+
# The path to the emitter package json file.
71+
- name: EmitterPackageJsonOutputPath
72+
type: string
73+
default: "eng/emitter-package.json"
74+
75+
# The relative path to the emitter package.
76+
- name: EmitterPackagePath
7177
type: string
72-
default: ""
7378

7479
extends:
7580
template: /eng/pipelines/templates/stages/1es-redirect.yml
@@ -98,7 +103,17 @@ extends:
98103
inputs:
99104
pwsh: true
100105
filePath: $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
101-
arguments: -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
106+
${{ if parameters.BuildPrereleaseVersion }}:
107+
arguments: >
108+
-PrereleaseSuffix "-alpha.$(Build.BuildNumber)"
109+
-OutputDirectory "$(Build.ArtifactStagingDirectory)"
110+
-UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
111+
-EmitterPackagePath:${{ parameters.EmitterPackagePath }}
112+
${{ else }}:
113+
arguments: >
114+
-OutputDirectory "$(Build.ArtifactStagingDirectory)"
115+
-UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
116+
-EmitterPackagePath:${{ parameters.EmitterPackagePath }}
102117
103118
- task: PowerShell@2
104119
displayName: 'Run build script'
@@ -107,10 +122,9 @@ extends:
107122
pwsh: true
108123
filePath: $(Build.SourcesDirectory)/eng/scripts/typespec/Build-Emitter.ps1
109124
arguments: >
110-
-BuildNumber "$(Build.BuildNumber)"
111-
-OutputDirectory "$(Build.ArtifactStagingDirectory)"
125+
-OutputDirectory "$(Build.ArtifactStagingDirectory)/packages"
112126
-TargetNpmJsFeed:$${{ parameters.PublishPublic }}
113-
-Prerelease:$${{ parameters.BuildPrereleaseVersion }}
127+
-EmitterPackagePath:${{ parameters.EmitterPackagePath }}
114128
115129
- pwsh: |
116130
$sourceBranch = '$(Build.SourceBranch)'
@@ -138,7 +152,7 @@ extends:
138152
# Publish stage
139153
# Responsible for publishing the packages in `build_artifacts/packages` and producing `emitter-package-lock.json`
140154
# Produces the artifact `publish_artifacts` which contains the following:
141-
# emitter-package.json: Created using the package json from the build step.
155+
# emitter-package.json: Created using the package json from the build step.
142156
# emitter-package-lock.json: Created by calling `npm install` using `emitter-package.json`
143157
- ${{ if parameters.ShouldPublish }}:
144158
- stage: Publish
@@ -198,20 +212,25 @@ extends:
198212
displayName: Install tsp-client
199213
200214
- pwsh: |
201-
if (Test-Path -Path '$(buildArtifactsPath)/overrides.json') {
215+
Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json"
216+
217+
if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') {
202218
Write-Host "Using overrides.json to generate emitter-package.json"
203219
tsp-client generate-config-files `
204220
--package-json '$(buildArtifactsPath)/lock-files/package.json' `
205-
--output-dir '$(Build.ArtifactStagingDirectory)' `
206-
--emitter-package-json-path '${{ parameters.EmitterPackageJsonPath }}' `
207-
--overrides '$(buildArtifactsPath)/overrides.json'
221+
--output-dir '$(Build.SourcesDirectory)' `
222+
--emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' `
223+
--overrides '$(buildArtifactsPath)/packages/overrides.json'
208224
} else {
225+
Write-Host "No overrides.json found. Running tsp-client without overrides."
226+
209227
tsp-client generate-config-files `
210228
--package-json '$(buildArtifactsPath)/lock-files/package.json' `
211-
--output-dir '$(Build.ArtifactStagingDirectory)' `
212-
--emitter-package-json-path '${{ parameters.EmitterPackageJsonPath }}'
229+
--output-dir '$(Build.SourcesDirectory)' `
230+
--emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}'
213231
}
214232
displayName: Generate emitter-package.json and emitter-package-lock files
233+
workingDirectory: $(Build.SourcesDirectory)
215234
216235
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
217236
parameters:
@@ -243,11 +262,8 @@ extends:
243262
displayName: Download pipeline artifacts
244263

245264
- pwsh: |
246-
Write-Host "Copying emitter-package.json to $(Build.SourcesDirectory)/eng"
247-
Copy-Item $(publishArtifactsPath)/emitter-package.json $(Build.SourcesDirectory)/eng/ -Force
248-
249-
Write-Host "Copying emitter-package-lock.json to $(Build.SourcesDirectory)/eng"
250-
Copy-Item $(publishArtifactsPath)/emitter-package-lock.json $(Build.SourcesDirectory)/eng/ -Force
265+
Write-Host "Copying *emitter-package*.json to $(Build.SourcesDirectory)/eng"
266+
Copy-Item $(publishArtifactsPath)/*emitter-package*.json $(Build.SourcesDirectory)/eng/ -Force
251267
displayName: Copy emitter-package json files
252268
253269
- ${{ parameters.InitializationSteps }}
@@ -294,7 +310,7 @@ extends:
294310
Paths:
295311
- "/*"
296312
- "!SessionRecords"
297-
313+
298314
- download: current
299315
displayName: Download pipeline artifacts
300316

@@ -435,7 +451,9 @@ extends:
435451
inputs:
436452
pwsh: true
437453
filePath: $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
438-
arguments: -BuildArtifactsPath '$(buildArtifactsPath)'
454+
arguments: >
455+
-BuildArtifactsPath '$(buildArtifactsPath)/lock-files'
456+
-EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
439457
440458
- task: PowerShell@2
441459
displayName: 'Run test script'
@@ -445,6 +463,7 @@ extends:
445463
arguments: >
446464
$(TestArguments)
447465
-OutputDirectory "$(Build.ArtifactStagingDirectory)"
466+
-EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
448467
449468
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
450469
parameters:

0 commit comments

Comments
 (0)