Skip to content

Split generator pipelines and make E2E publish work #49321

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

Merged
merged 71 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
877084c
tsp-client debug
JoshLove-msft Apr 9, 2025
d79e0cf
backtick
JoshLove-msft Apr 9, 2025
06c5982
workingdirectory
JoshLove-msft Apr 9, 2025
277c208
add working directory
JoshLove-msft Apr 9, 2025
7f0c6e9
source
JoshLove-msft Apr 9, 2025
7c4211e
don't install globally
JoshLove-msft Apr 9, 2025
23183f3
outputdir
JoshLove-msft Apr 9, 2025
4edcd1f
sources
JoshLove-msft Apr 9, 2025
fe08be1
fix path
JoshLove-msft Apr 9, 2025
1f72f42
Pass version
JoshLove-msft Apr 9, 2025
370d264
backtick
JoshLove-msft Apr 9, 2025
f782b98
use eng
JoshLove-msft Apr 10, 2025
ef1fd41
print emitter version
JoshLove-msft Apr 10, 2025
77972bc
fix print
JoshLove-msft Apr 10, 2025
f33d675
remove version
JoshLove-msft Apr 10, 2025
18df156
fix
JoshLove-msft Apr 10, 2025
284c99a
relative path
JoshLove-msft Apr 10, 2025
4baedd3
add back version
JoshLove-msft Apr 10, 2025
22562c1
Temp work for multiple-emitter-prs
hallipr Apr 10, 2025
c18e891
Merge branch 'users/pahallis/emitter-temp' of https://github.com/hall…
JoshLove-msft Apr 10, 2025
793abf1
create dir
JoshLove-msft Apr 10, 2025
a7cd635
pass name
JoshLove-msft Apr 10, 2025
d4d5fa6
fix version
JoshLove-msft Apr 10, 2025
8a93ef9
fix file name
JoshLove-msft Apr 11, 2025
375c0c8
fix filename
JoshLove-msft Apr 11, 2025
c3661ac
fix build path
JoshLove-msft Apr 11, 2025
587692f
fix working directory and always pass emitter path
JoshLove-msft Apr 11, 2025
91413c5
Use parameter default
JoshLove-msft Apr 11, 2025
21d74ef
npmrc
JoshLove-msft Apr 11, 2025
4acb6bf
ci
JoshLove-msft Apr 11, 2025
92875fb
remove packagename
JoshLove-msft Apr 11, 2025
085dcb4
remove pn
JoshLove-msft Apr 11, 2025
667bb7f
make lockfiles
JoshLove-msft Apr 11, 2025
50ef651
skip mgmt for now
JoshLove-msft Apr 11, 2025
c62b20c
fix outputdirectory build
JoshLove-msft Apr 11, 2025
444c874
copy nmrc to source dir
JoshLove-msft Apr 11, 2025
809263e
fix npmrc
JoshLove-msft Apr 11, 2025
cfa1e12
print the registry
JoshLove-msft Apr 11, 2025
e4373b2
ugh
JoshLove-msft Apr 11, 2025
3aae120
fix overrides
JoshLove-msft Apr 11, 2025
a2258da
add logging
JoshLove-msft Apr 11, 2025
c0adafe
fix escaped $
JoshLove-msft Apr 11, 2025
5eea61f
fix $
JoshLove-msft Apr 11, 2025
d721874
log
JoshLove-msft Apr 11, 2025
1980ca5
print overrides
JoshLove-msft Apr 11, 2025
eb49a4b
fix
JoshLove-msft Apr 11, 2025
5cb1aaa
fix override path
JoshLove-msft Apr 11, 2025
fd6e068
actually commit changes
JoshLove-msft Apr 11, 2025
97840ca
buildartifactspath
JoshLove-msft Apr 11, 2025
1612b8a
more logs
JoshLove-msft Apr 11, 2025
ba297af
fix path
JoshLove-msft Apr 11, 2025
c13aa53
updates
JoshLove-msft Apr 11, 2025
1e1f4cd
restore
JoshLove-msft Apr 11, 2025
aa29de1
fix
JoshLove-msft Apr 11, 2025
5a55699
remove lockfilespath
JoshLove-msft Apr 11, 2025
2fcbfc2
fix arg
JoshLove-msft Apr 11, 2025
6e17fa2
if
JoshLove-msft Apr 11, 2025
01e675e
logging
JoshLove-msft Apr 11, 2025
acb83c3
Add package path
JoshLove-msft Apr 11, 2025
d5ab180
sync
JoshLove-msft Apr 11, 2025
3dcc81e
move inside function
JoshLove-msft Apr 11, 2025
6aa272b
check-codegen
JoshLove-msft Apr 12, 2025
87fb02b
Revert unintended change
JoshLove-msft Apr 12, 2025
1584393
revert doc
JoshLove-msft Apr 12, 2025
d29ca2b
delete artifacts
JoshLove-msft Apr 12, 2025
c081c1e
revert
JoshLove-msft Apr 12, 2025
3be918f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
JoshLove-msft Apr 12, 2025
eb54bb6
delete
JoshLove-msft Apr 12, 2025
af4993b
revert
JoshLove-msft Apr 12, 2025
14fe540
revert
JoshLove-msft Apr 12, 2025
2ade0e8
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
JoshLove-msft Apr 14, 2025
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
73 changes: 73 additions & 0 deletions eng/packages/http-client-csharp-mgmt/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
trigger:
branches:
include:
- main
paths:
include:
- eng/packages/http-client-csharp
- eng/packages/http-client-csharp-mgmt
- eng/scripts/typespec
pr:
branches:
include:
- main
- feature/*
- hotfix/*
- release/*
paths:
include:
- eng/packages/http-client-csharp
- eng/packages/http-client-csharp-mgmt
- eng/scripts/typespec

parameters:
- name: UseTypeSpecNext
displayName: "Use TypeSpec Next"
type: boolean
default: false
- name: ShouldPublish
displayName: "Publish packages"
type: boolean
default: false
- name: PublishPublic
displayName: "Publish to npmjs.org"
type: boolean
default: false
- name: ShouldRegenerate
displayName: "Regenerate clients"
type: boolean
default: false

variables:
- template: /eng/pipelines/templates/variables/image.yml

extends:
template: /eng/common/pipelines/templates/archetype-typespec-emitter.yml
parameters:
EmitterPackageJsonPath: eng/http-client-csharp-mgmt-emitter-package.json
EmitterPackagePath: eng/packages/http-client-csharp-mgmt
SparseCheckoutPaths:
- /sdk/core/Azure.Core/src/Shared
- /sdk/core/Azure.Core.TestFramework/src
BuildPrereleaseVersion: true
UseTypeSpecNext: ${{ parameters.UseTypeSpecNext }}
${{ if eq(variables['System.TeamProject'], 'internal') }}:
${{ if eq(variables['Build.Reason'], 'Manual') }}:
ShouldPublish: ${{ parameters.ShouldPublish }}
${{ if startswith(variables['Build.SourceBranch'], 'refs/pull/') }}: # PR ref's can't be published to public, even in a manual run
PublishPublic: false
PublishDependsOnTest: false
${{ else }}: # Any other manual run can go to public
PublishPublic: ${{ parameters.PublishPublic }}
PublishDependsOnTest: ${{ parameters.PublishPublic }}
${{ else }}: # All automatic runs publish, but only CI of main goes public
ShouldPublish: true
PublishDependsOnTest: false
PublishPublic: ${{ and(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}
RegenerationJobCount: 5
MinimumPerJob: 10
OnlyGenerateTypespec: true
TestMatrix:
All:
TestArguments: -UnitTests -GenerationChecks -Filter .NET
SpectorName: "http-client-csharp-mgmt"
11 changes: 3 additions & 8 deletions eng/packages/http-client-csharp/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ trigger:
paths:
include:
- eng/packages/http-client-csharp
- eng/packages/http-client-csharp-mgmt
- eng/scripts/typespec
pr:
branches:
Expand All @@ -17,14 +16,9 @@ pr:
paths:
include:
- eng/packages/http-client-csharp
- eng/packages/http-client-csharp-mgmt
- eng/scripts/typespec

parameters:
- name: BuildPrereleaseVersion
displayName: "Build prerelease version"
type: boolean
default: true
- name: UseTypeSpecNext
displayName: "Use TypeSpec Next"
type: boolean
Expand All @@ -48,11 +42,12 @@ variables:
extends:
template: /eng/common/pipelines/templates/archetype-typespec-emitter.yml
parameters:
EmitterPackageJsonPath: /eng/azure-typespec-emitter-package.json
EmitterPackageJsonOutputPath: eng/http-client-csharp-emitter-package.json
EmitterPackagePath: eng/packages/http-client-csharp
SparseCheckoutPaths:
- /sdk/core/Azure.Core/src/Shared
- /sdk/core/Azure.Core.TestFramework/src
BuildPrereleaseVersion: ${{ parameters.BuildPrereleaseVersion }}
BuildPrereleaseVersion: true
UseTypeSpecNext: ${{ parameters.UseTypeSpecNext }}
${{ if eq(variables['System.TeamProject'], 'internal') }}:
${{ if eq(variables['Build.Reason'], 'Manual') }}:
Expand Down
77 changes: 35 additions & 42 deletions eng/scripts/typespec/Build-Emitter.ps1
Original file line number Diff line number Diff line change
@@ -1,83 +1,76 @@
#Requires -Version 7.0

param(
[string] $BuildNumber,
[string] $OutputDirectory,
[switch] $Prerelease,
[switch] $TargetNpmJsFeed
[switch] $TargetNpmJsFeed,
[string] $emitterPackagePath
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 3.0
. "$PSScriptRoot/../../common/scripts/common.ps1"
Set-ConsoleEncoding

$packageRoot = Resolve-Path "$RepoRoot/eng/packages/http-client-csharp"
$mgmtPackageRoot = Resolve-Path "$RepoRoot/eng/packages/http-client-csharp-mgmt"
$outputPath = $OutputDirectory ? $OutputDirectory : (Join-Path $packageRoot "artifacts" "build")
$mgmtOutputPath = $OutputDirectory ? $OutputDirectory : (Join-Path $mgmtPackageRoot "artifacts" "build")

function Build-Emitter {
param (
[string]$packageRoot,
[string]$outputPath
[string]$outputPath,
[hashtable]$overrides
)

Push-Location $packageRoot
try {
Write-Host "Working in $PWD"

$outputPath = New-Item -ItemType Directory -Force -Path $outputPath | Select-Object -ExpandProperty FullName

$emitterVersion = (npm pkg get version).Trim('"')
Write-Host "TargetNpmJsFeed: $TargetNpmJsFeed"

if ($BuildNumber) {
# set package versions
$versionTag = $Prerelease ? "-alpha" : "-beta"

$emitterVersion = "$($emitterVersion.Split('-')[0])$versionTag.$BuildNumber"
Write-Host "Setting output variable 'emitterVersion' to $emitterVersion"
Write-Host "##vso[task.setvariable variable=emitterVersion;isoutput=true]$emitterVersion"
}
$outputPath = New-Item -ItemType Directory -Force -Path $outputPath | Select-Object -ExpandProperty FullName

# build and pack the emitter
Invoke-LoggedCommand "npm install @types/node --save-dev" -GroupOutput
Invoke-LoggedCommand "npm run build" -GroupOutput

if ($BuildNumber) {
Write-Host "Updating version package.json to the new emitter version`n"
Invoke-LoggedCommand "npm pkg set version=$emitterVersion"
}

# remove any existing tarballs
Remove-Item -Path "./*.tgz" -Force | Out-Null

#pack the emitter
Invoke-LoggedCommand "npm pack"
$file = Get-ChildItem -Filter "*.tgz" | Select-Object -ExpandProperty FullName

# ensure the packages directory exists
New-Item -ItemType Directory -Force -Path "$outputPath/packages" | Out-Null
Write-Host "Copying $file to $outputPath"
Copy-Item $file -Destination $outputPath

Write-Host "Copying $file to $outputPath/packages"
Copy-Item $file -Destination "$outputPath/packages"

if ($TargetNpmJsFeed) {
$overrides = @{}
}
else {
if (!$TargetNpmJsFeed) {
$feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry"

$overrides = @{
"@azure-typespec/http-client-csharp" = "$feedUrl/@azure-typespec/http-client-csharp/-/http-client-csharp-$emitterVersion.tgz"
}
$packageJson = Get-Content -Path "./package.json" | ConvertFrom-Json
$packageVersion = $packageJson.version
$packageName = $packageJson.name

$unscopedName = $packageName.Split("/")[1]
$overrides[$packageName] = "$feedUrl/$packageName/-/$unscopedName-$packageVersion.tgz"
}

# restore the package.json and package-lock.json files to their original state
Write-Host "Restoring package.json and package-lock.json to their original state"
Invoke-LoggedCommand "git restore package.json package-lock.json"
}
finally {
Pop-Location
}
}

Build-Emitter -packageRoot $packageRoot -outputPath $outputPath
$overrides = @{}

$outputPath = $OutputDirectory ? $OutputDirectory : (Join-Path $RepoRoot "artifacts" "emitters")
New-Item -ItemType Directory -Force -Path $outputPath | Out-Null

# strip leading slash from emitterPackagePath if it exists
if ($emitterPackagePath.StartsWith("/")) {
$emitterPackagePath = $emitterPackagePath.Substring(1)
}
$packageRoot = Join-Path $RepoRoot $emitterPackagePath
Build-Emitter -packageRoot $packageRoot -outputPath $outputPath -overrides $overrides

Write-Host "Writing overrides to $outputPath/overrides.json"

Build-Emitter -packageRoot $mgmtPackageRoot -outputPath $mgmtOutputPath
$overrides | ConvertTo-Json | Out-File -FilePath "$outputPath/overrides.json" -Encoding utf8 -Force
Get-Content -Path "$outputPath/overrides.json" | Out-Host
29 changes: 7 additions & 22 deletions eng/scripts/typespec/Check-CodeGeneration.ps1
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
#Requires -Version 7.0

param(
[string] $EmitterPackagePath
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 3.0

$packageRoot = Resolve-Path "$PSScriptRoot../../../packages/http-client-csharp"
Push-Location $packageRoot
Push-Location $EmitterPackagePath

try {
& "$packageRoot/eng/scripts/Generate.ps1"
& "$EmitterPackagePath/eng/scripts/Generate.ps1"

Write-Host 'Checking generated files difference...'
git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code
if ($LastExitCode -ne 0) {
Write-Error 'Generated codes of Azure generator are not up to date. Please run: eng/packages/http-client-csharp/eng/scripts/Generate.ps1'
Write-Error 'Generated code of Azure generator is not up to date. Please run: /eng/scripts/Generate.ps1'
exit 1
}
Write-Host 'Done for Azure generator. No change is detected.'
}
finally {
Pop-Location
}

$mgmtPackageRoot = Resolve-Path "$PSScriptRoot../../../packages/http-client-csharp-mgmt"
Push-Location $mgmtPackageRoot

try {
& "$mgmtPackageRoot/eng/scripts/Generate.ps1"

Write-Host 'Checking generated files difference...'
git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code
if ($LastExitCode -ne 0) {
Write-Error 'Generated codes of mgmt generator are not up to date. Please run: eng/packages/http-client-csharp/eng/scripts/Generate.ps1'
exit 1
}
Write-Host 'Done for mgmt generator. No change is detected.'
}
finally {
Pop-Location
}
Loading