-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for a TypeSpec/sdk regeneration preview pipeline
- Loading branch information
Showing
8 changed files
with
233 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ common/autoinstallers/*/.npmrc | |
**/types | ||
dist-esm | ||
dist | ||
/artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
trigger: none | ||
pr: none | ||
|
||
parameters: | ||
- name: UseTypeSpecNext | ||
displayName: Use TypeSpec "next" version | ||
type: boolean | ||
default: true | ||
|
||
resources: | ||
repositories: | ||
- repository: sdk-repository | ||
type: github | ||
endpoint: Azure | ||
name: Azure/azure-sdk-for-js | ||
ref: refs/heads/main | ||
- repository: azure-sdk-tools | ||
type: github | ||
endpoint: Azure | ||
name: Azure/azure-sdk-tools | ||
ref: refs/heads/main | ||
|
||
pool: | ||
name: azsdk-pool-mms-win-2022-general | ||
vmImage: windows-2022 | ||
|
||
extends: | ||
template: eng/pipelines/templates/stages/archetype-autorest-preview.yml@azure-sdk-tools | ||
parameters: | ||
RegenerationJobCount: 1 | ||
BuildPrereleaseVersion: true | ||
PublishInternal: true | ||
UseTypeSpecNext: ${{ parameters.UseTypeSpecNext }} | ||
EmitterPackageJsonPath: packages/typespec-ts/package.json | ||
Packages: | ||
- name: generator | ||
file: autorest-typescript-*.tgz | ||
type: npm | ||
- name: emitter | ||
file: azure-tools-typespec-ts-*.tgz | ||
type: npm | ||
- name: common | ||
file: azure-tools-rlc-common-*.tgz | ||
type: npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#Requires -Version 7.0 | ||
param( | ||
[string] $BuildNumber, | ||
[string] $Output, | ||
[switch] $Prerelease, | ||
[switch] $PublishInternal | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
Set-StrictMode -Version 3.0 | ||
$root = (Resolve-Path "$PSScriptRoot/../..").Path.Replace('\', '/') | ||
. "$root/eng/scripts/CommandInvocation-Helpers.ps1" | ||
Set-ConsoleEncoding | ||
|
||
$artifactsPath = "$root/artifacts" | ||
$outputPath = $Output ? $Output : "$artifactsPath/ci-build" | ||
|
||
$packagesPath = New-Item "$outputPath/packages" -ItemType Directory -Force | ||
|
||
function UpdatePackage($name, $path) { | ||
Push-Location $path | ||
try { | ||
$version = (Get-Content "./package.json" -Raw | ConvertFrom-Json).version | ||
|
||
if ($Prerelease) { | ||
$version = "$($version.Split('-')[0])-preview.$BuildNumber" | ||
Invoke-LoggedCommand "npm version --allow-same-version --no-git-tag-version $version" | ||
} | ||
|
||
$packageMatrix[$name] = $version | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} | ||
|
||
function PackPackage($path) { | ||
Push-Location $path | ||
try { | ||
Invoke-LoggedCommand "node ../../common/scripts/install-run-rush.js build" | ||
Invoke-LoggedCommand "node ../../common/scripts/install-run-rush-pnpm.js pack -q --pack-destination $packagesPath" | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} | ||
|
||
$packageMatrix = @{} | ||
|
||
UpdatePackage "common" "$root/packages/rlc-common" | ||
UpdatePackage "generator" "$root/packages/autorest.typescript" | ||
UpdatePackage "emitter" "$root/packages/typespec-ts" | ||
|
||
PackPackage "$root/packages/rlc-common" | ||
PackPackage "$root/packages/autorest.typescript" | ||
PackPackage "$root/packages/typespec-ts" | ||
|
||
if ($PublishInternal) { | ||
$feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry" | ||
|
||
$overrides = @{ | ||
"@autorest/typescript" = "$feedUrl/@autorest/typescript/-/typescript-$($packageMatrix['generator']).tgz" | ||
"@azure-tools/typespec-ts" = "$feedUrl/@azure-tools/typespec-ts/-/typespec-ts-$($packageMatrix['emitter']).tgz" | ||
"@azure-tools/rlc-common" = "$feedUrl/@azure-tools/rlc-common/-/rlc-common-$($packageMatrix['common']).tgz" | ||
} | ||
} | ||
else { | ||
$overrides = @{} | ||
} | ||
|
||
$packageMatrix | ConvertTo-Json | Set-Content "$outputPath/package-versions.json" | ||
$overrides | ConvertTo-Json | Set-Content "$outputPath/overrides.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#Requires -Version 7.0 | ||
Set-StrictMode -Version 3.0 | ||
|
||
function Set-ConsoleEncoding { | ||
[CmdletBinding()] | ||
param | ||
( | ||
[string] $Encoding = 'utf-8' | ||
) | ||
|
||
$outputEncoding = [System.Text.Encoding]::GetEncoding($Encoding) | ||
[Console]::OutputEncoding = $outputEncoding | ||
[Console]::InputEncoding = $outputEncoding | ||
} | ||
|
||
function Invoke-LoggedCommand { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string] $Command, | ||
|
||
[ValidateScript({ Test-Path $_ -PathType Container })] | ||
[string] $ExecutePath, | ||
|
||
[switch] $IgnoreExitCode | ||
) | ||
|
||
$width = [Math]::Min($Host.UI.RawUI.WindowSize.Width ?? 80, 80) | ||
$separator = '=' * $width | ||
$startTime = Get-Date | ||
|
||
Push-Location $ExecutePath | ||
try { | ||
Write-Host "$separator`n$PWD> $Command`n$separator" | ||
Invoke-Expression $Command | ||
|
||
$duration = (Get-Date) - $startTime | ||
$separator = '-' * $width | ||
|
||
if ($IgnoreExitCode -or $LASTEXITCODE -eq 0) { | ||
Write-Host "$separator`nExit Code: $LASTEXITCODE, Duration: $duration`n$separator`n" | ||
} | ||
else { | ||
Write-Error "$separator`nExit Code: $LASTEXITCODE, Duration: $duration`n$Command`n$separator`n" | ||
} | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Requires -Version 7.0 | ||
param( | ||
[string] $BuildArtifactsPath, | ||
[switch] $UseTypeSpecNext | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
Set-StrictMode -Version 3.0 | ||
$root = (Resolve-Path "$PSScriptRoot/../..").Path.Replace('\', '/') | ||
. "$root/eng/scripts/CommandInvocation-Helpers.ps1" | ||
Set-ConsoleEncoding | ||
|
||
Push-Location $root | ||
try { | ||
# install and list npm packages | ||
if ($BuildArtifactsPath) { | ||
$lockFilesPath = Resolve-Path "$BuildArtifactsPath/lock-files" | ||
# if we were passed a build_artifacts path, use the package.json and pnpm-lock.yaml from there | ||
Write-Host "Using emitter/package.json and pnpm-lock.yaml from $lockFilesPath" | ||
Copy-Item "$lockFilesPath/pnpm-lock.yaml" './common/config/rush/pnpm-lock.yaml' -Force | ||
Copy-Item "$lockFilesPath/emitter/package.json" './packages/typespec-ts/package.json' -Force | ||
} | ||
elseif ($UseTypeSpecNext) { | ||
Write-Host "Using TypeSpec.Next" | ||
Invoke-LoggedCommand "npx -y @azure-tools/typespec-bump-deps@latest --use-peer-ranges ./packages/typespec-ts/package.json" | ||
} | ||
|
||
Invoke-LoggedCommand "node common/scripts/install-run-rush.js update" | ||
|
||
Invoke-LoggedCommand "npm list --all" | ||
|
||
$artifactStagingDirectory = $env:Build_ArtifactStagingDirectory | ||
if ($artifactStagingDirectory -and !$BuildArtifactsPath) { | ||
$lockFilesPath = "$artifactStagingDirectory/lock-files" | ||
New-Item -ItemType Directory -Path "$lockFilesPath/emitter" | Out-Null | ||
|
||
Write-Host "Copying typespec-ts/package.json and pnpm-lock.yaml to $lockFilesPath" | ||
Copy-Item './common/config/rush/pnpm-lock.yaml' "$lockFilesPath/pnpm-lock.yaml" -Force | ||
Copy-Item './packages/typespec-ts/package.json' "$lockFilesPath/emitter/package.json" -Force | ||
} | ||
} | ||
finally { | ||
Pop-Location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters