Skip to content
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

Changes required for sdk-repo based emitter pipelines #9147

Merged
merged 5 commits into from
Oct 16, 2024
Merged
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
440 changes: 440 additions & 0 deletions eng/common/pipelines/templates/archetype-typespec-emitter.yml

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions eng/common/scripts/Helpers/CommandInvocation-Helpers.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function Invoke-LoggedCommand($Command, $ExecutePath, [switch]$GroupOutput)
function Invoke-LoggedCommand
{
[CmdletBinding()]
param
(
[string] $Command,
[string] $ExecutePath,
[switch] $GroupOutput,
[int[]] $AllowedExitCodes = @(0)
)

$pipelineBuild = !!$env:TF_BUILD
$startTime = Get-Date

Expand All @@ -22,7 +31,7 @@ function Invoke-LoggedCommand($Command, $ExecutePath, [switch]$GroupOutput)
Write-Host "##[endgroup]"
}

if($LastExitCode -ne 0)
if($LastExitCode -notin $AllowedExitCodes)
{
if($pipelineBuild) {
Write-Error "##[error]Command failed to execute ($duration): $Command`n"
Expand All @@ -40,3 +49,16 @@ function Invoke-LoggedCommand($Command, $ExecutePath, [switch]$GroupOutput)
}
}
}

function Set-ConsoleEncoding
{
[CmdletBinding()]
param
(
[string] $Encoding = 'utf-8'
)

$outputEncoding = [System.Text.Encoding]::GetEncoding($Encoding)
[Console]::OutputEncoding = $outputEncoding
[Console]::InputEncoding = $outputEncoding
}
11 changes: 5 additions & 6 deletions eng/common/scripts/New-RegenerateMatrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ param (
[int]$MinimumPerJob = 10,

[Parameter()]
[string]$OnlyTypespec
[string]$OnlyTypeSpec
)

. (Join-Path $PSScriptRoot common.ps1)
Expand Down Expand Up @@ -57,14 +57,13 @@ function Split-Items([array]$Items) {
New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null

if (Test-Path "Function:$GetDirectoriesForGenerationFn") {
$directoriesForGeneration = &$GetDirectoriesForGenerationFn
$directoriesForGeneration = &$GetDirectoriesForGenerationFn -OnlyTypeSpec $OnlyTypespec
}
else {
$directoriesForGeneration = Get-ChildItem "$RepoRoot/sdk" -Directory | Get-ChildItem -Directory
}

if ($OnlyTypespec) {
$directoriesForGeneration = $directoriesForGeneration | Where-Object { Test-Path "$_/tsp-location.yaml" }
if ($OnlyTypespec) {
$directoriesForGeneration = $directoriesForGeneration | Where-Object { Test-Path "$_/tsp-location.yaml" }
}
}

[array]$packageDirectories = $directoriesForGeneration
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts"
. (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1)
. (Join-Path $EngCommonScriptsDir "Helpers" git-helpers.ps1)
. (Join-Path $EngCommonScriptsDir "Helpers" Package-Helpers.ps1)
. (Join-Path $EngCommonScriptsDir "Helpers" CommandInvocation-Helpers.ps1)

# Setting expected from common languages settings
$Language = "Unknown"
Expand Down
6 changes: 5 additions & 1 deletion eng/common/scripts/typespec/New-EmitterPackageJson.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Requires -Version 7.0
[CmdletBinding()]
param (
[parameter(Mandatory = $true)]
Expand Down Expand Up @@ -35,9 +36,12 @@ if ($OverridesPath) {

$devDependencies = [ordered]@{}

foreach ($package in $packageJson.peerDependencies.Keys | Sort-Object) {
$possiblyPinnedPackages = $packageJson['azure-sdk/emitter-package-json-pinning'] ?? $packageJson.peerDependencies.Keys;

foreach ($package in $possiblyPinnedPackages | Sort-Object) {
$pinnedVersion = $packageJson.devDependencies[$package]
if ($pinnedVersion -and -not $overrides[$package]) {
#We have a dev pinned version that isn't overridden by the overrides.json file
Write-Host "Pinning $package to $pinnedVersion"
$devDependencies[$package] = $pinnedVersion
}
Expand Down
16 changes: 8 additions & 8 deletions eng/pipelines/templates/stages/archetype-autorest-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ stages:
jobs:
- job: Build
steps:
- template: ../steps/emit-pipeline-repositories.yml
- template: /eng/pipelines/templates/steps/emit-pipeline-repositories.yml
parameters:
name: repositories
displayName: 'Get repository details'
Expand Down Expand Up @@ -130,7 +130,7 @@ stages:
-OutputDirectory '$(Build.ArtifactStagingDirectory)'
workingDirectory: $(autorestRepositoryPath)

- template: ../../../common/pipelines/templates/steps/publish-artifact.yml
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
artifactName: build_artifacts
artifactPath: $(Build.ArtifactStagingDirectory)
Expand Down Expand Up @@ -204,7 +204,7 @@ stages:

# Create authenticated .npmrc file for publishing
- ${{ if eq(parameters.PublishInternal, 'true') }}:
- template: ../steps/create-authenticated-npmrc.yml
- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml
parameters:
npmrcPath: $(buildArtifactsPath)/packages/.npmrc
registryUrl: https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/
Expand Down Expand Up @@ -243,7 +243,7 @@ stages:
-EmitterPackageJsonPath "$(buildArtifactsPath)/emitter-package.json"
-OutputDirectory "$(Build.ArtifactStagingDirectory)"

- template: ../../../common/pipelines/templates/steps/publish-artifact.yml
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
artifactName: publish_artifacts
artifactPath: $(Build.ArtifactStagingDirectory)
Expand Down Expand Up @@ -292,7 +292,7 @@ stages:
arguments: $(TestArguments)
workingDirectory: $(autorestRepositoryPath)

- template: ../../../common/pipelines/templates/steps/publish-artifact.yml
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
artifactName: test_artifacts_$(System.JobName)
artifactPath: $(Build.ArtifactStagingDirectory)
Expand All @@ -314,7 +314,7 @@ stages:
jobs:
- job: Initialize
steps:
- template: ../../../common/pipelines/templates/steps/sparse-checkout.yml
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
Paths:
- "/*"
Expand Down Expand Up @@ -372,7 +372,7 @@ stages:
-MinimumPerJob ${{ parameters.MinimumPerJob }}
-OnlyTypespec ${{ parameters.OnlyGenerateTypespec }}

- template: ../../../common/pipelines/templates/steps/publish-artifact.yml
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
artifactName: matrix_artifacts
artifactPath: $(Build.ArtifactStagingDirectory)
Expand All @@ -386,7 +386,7 @@ stages:
steps:
- checkout: self
- checkout: azure-sdk-tools
- template: ../../../common/pipelines/templates/steps/sparse-checkout.yml
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
Paths:
- "/*"
Expand Down