diff --git a/eng/GenerateSdkForNetCodeGenerationMatrix.ps1 b/eng/GenerateSdkForNetCodeGenerationMatrix.ps1 index ff8d8228036..c98743748fa 100644 --- a/eng/GenerateSdkForNetCodeGenerationMatrix.ps1 +++ b/eng/GenerateSdkForNetCodeGenerationMatrix.ps1 @@ -99,9 +99,10 @@ function New-Matrix([array]$PropsFiles) { for($i=0;$i -lt $PropsFiles.Length;$i++) { $fileName = $PropsFiles[$i].FileName $projects = $PropsFiles[$i].Projects - $firstInitial = $projects[0].ServiceArea.Substring(0, 1) - $lastInitial = $projects[-1].ServiceArea.Substring(0, 1) - $matrix["$i`: $firstInitial-$lastInitial"] = @{ 'ProjectListOverrideFile' = $fileName } + $firstPrefix = $projects[0].ServiceArea.Substring(0, 2) + $lastPrefix = $projects[-1].ServiceArea.Substring(0, 2) + $key = "$firstPrefix`_$lastPrefix`_$i" + $matrix[$key] = @{ 'JobKey' = $key; 'ProjectListOverrideFile' = $fileName } } return $matrix } diff --git a/eng/PackEmitter.ps1 b/eng/PackEmitter.ps1 index 3d60fb2d59b..517719f853c 100644 --- a/eng/PackEmitter.ps1 +++ b/eng/PackEmitter.ps1 @@ -28,4 +28,4 @@ finally { Pop-Location } -Write-Host "##vso[task.setvariable variable=emitterVersion;isoutput=true]$alphaVersion" +Write-Host "##vso[task.setvariable variable=TypeSpecEmitterVersion;isoutput=true]$alphaVersion" diff --git a/eng/UpdateAzureSdkForNet.ps1 b/eng/UpdateAzureSdkForNet.ps1 index 83dd52f7e4a..3aa271b5186 100644 --- a/eng/UpdateAzureSdkForNet.ps1 +++ b/eng/UpdateAzureSdkForNet.ps1 @@ -2,9 +2,6 @@ param( [Parameter(Mandatory)] [string]$AutorestCSharpVersion, - [Parameter(Mandatory)] - [string]$TypeSpecEmitterVersion, - [Parameter(Mandatory)] [string]$SdkRepoRoot, @@ -12,12 +9,8 @@ param( [string]$ProjectListOverrideFile, - [switch]$ShowSummary, - - [bool]$UseInternalFeed = $false) + [switch]$ShowSummary) $ErrorActionPreference = 'Stop' -Invoke-Expression "$PSScriptRoot\UpdateGeneratorMetadata.ps1 -AutorestCSharpVersion $AutorestCSharpVersion -TypeSpecEmitterVersion $TypeSpecEmitterVersion -SdkRepoRoot $SdkRepoRoot -UseInternalFeed `$$UseInternalFeed" - Invoke-Expression "$PSScriptRoot\UpdateAzureSdkCodes.ps1 -SdkRepoRoot $SdkRepoRoot -ServiceDirectoryFilters $($ServiceDirectoryFilters -Join ',') -ProjectListOverrideFile $ProjectListOverrideFile $(if ($ShowSummary) {'-ShowSummary'})" diff --git a/eng/UpdateGeneratorMetadata.ps1 b/eng/UpdateGeneratorMetadata.ps1 index 8b08e194a69..943b9110ba9 100644 --- a/eng/UpdateGeneratorMetadata.ps1 +++ b/eng/UpdateGeneratorMetadata.ps1 @@ -3,36 +3,16 @@ param( [string]$AutorestCSharpVersion, [Parameter(Mandatory)] - [string]$TypeSpecEmitterVersion, - - [Parameter(Mandatory)] - [string]$SdkRepoRoot, - - [bool]$UseInternalFeed = $false) + [string]$SdkRepoRoot) $ErrorActionPreference = 'Stop' $SdkRepoRoot = Resolve-Path $SdkRepoRoot -Write-Host "Updating Autorest.CSharp($AutorestCSharpVersion) and TypeSpec Emitter($TypeSpecEmitterVersion) under $SdkRepoRoot" +Write-Host "Updating Autorest.CSharp($AutorestCSharpVersion) int Packages.Data.props under $SdkRepoRoot" $PackagesProps = "$SdkRepoRoot\eng\Packages.Data.props" (Get-Content -Raw $PackagesProps) -replace ` '', "" | ` Set-Content $PackagesProps -NoNewline - -$TypeSpecEmitterProps = "$SdkRepoRoot\eng\emitter-package.json" -(Get-Content -Raw $TypeSpecEmitterProps) -replace ` - '"@azure-tools/typespec-csharp": ".*?"', -"`"@azure-tools/typespec-csharp`": `"$TypeSpecEmitterVersion`"" | ` - Set-Content $TypeSpecEmitterProps -NoNewline - -if ($UseInternalFeed) { - $npmrcFile = Resolve-Path (Join-Path $SdkRepoRoot ".npmrc") - $projectGeneratePath = "$SdkRepoRoot\eng\common\scripts\TypeSpec-Project-Generate.ps1" - (Get-Content -Raw $projectGeneratePath) -replace ` - 'npm install --no-lock-file', -"Copy-Item -Path $npmrcFile -Destination `".npmrc`" -Force`nnpm install --no-lock-file" | ` - Set-Content $projectGeneratePath -NoNewline -} diff --git a/eng/pipelines/build.yml b/eng/pipelines/build.yml index 1d70130ba86..393755c8dc9 100644 --- a/eng/pipelines/build.yml +++ b/eng/pipelines/build.yml @@ -19,7 +19,7 @@ resources: type: github name: Azure/azure-sdk-tools endpoint: azure - ref: refs/tags/azure-sdk-tools_20230428.1 + ref: refs/tags/azure-sdk-tools_20231010.1 - repository: azure-sdk-for-net type: github name: Azure/azure-sdk-for-net @@ -65,7 +65,7 @@ stages: npm run prettier displayName: "Emitter format check" workingDirectory: $(Build.SourcesDirectory)/autorest.csharp/src/TypeSpec.Extension/Emitter.Csharp - - script: 'dotnet pack src/AutoRest.CSharp/AutoRest.CSharp.csproj -o $(Build.ArtifactStagingDirectory) -warnaserror -c Release' + - script: 'dotnet pack src/AutoRest.CSharp/AutoRest.CSharp.csproj -o $(Build.ArtifactStagingDirectory)/packages -warnaserror -c Release' name: Package displayName: 'Package' workingDirectory: $(Build.SourcesDirectory)/autorest.csharp @@ -111,11 +111,6 @@ stages: npm run test --prefix src/TypeSpec.Extension/Emitter.Csharp displayName: 'Unit Test' workingDirectory: $(Build.SourcesDirectory)/autorest.csharp - - task: PublishBuildArtifacts@1 - condition: succeededOrFailed() - displayName: 'Publish Artifacts' - inputs: - ArtifactName: packages - ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}: - pwsh: > ./eng/PublishRelease.ps1 @@ -144,6 +139,18 @@ stages: scriptLocation: "inlineScript" inlineScript: npx cadl-ranch upload-coverage --coverageFile ./artifacts/coverage/cadl-ranch-coverage-csharp.json --generatorName csharp --storageAccountName azuresdkcadlranch --generatorVersion $(node -p -e "require('./src/TypeSpec.Extension/Emitter.Csharp/package.json').version") workingDirectory: $(Build.SourcesDirectory)/autorest.csharp + - ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}: + - template: new-emitter-package-files.yml + parameters: + EmitterPackageJsonPath: '$(Build.SourcesDirectory)/autorest.csharp/src/TypeSpec.Extension/Emitter.Csharp/package.json' + AutorestCSharpVersion: $(Package.AutorestCSharpVersion) + TypeSpecEmitterVersion: $(Publish.TypeSpecEmitterVersion) + OutputDirectory: $(Build.ArtifactStagingDirectory) + ToolsRepositoryPath: $(Build.SourcesDirectory)/azure-sdk-tools + - publish: $(Build.ArtifactStagingDirectory) + artifact: build_artifacts + condition: succeededOrFailed() + displayName: "Publish build artifacts" - template: check-code-generation.yml parameters: name: Check_Code_Generation_A_B @@ -173,25 +180,28 @@ stages: variables: AutorestCSharpVersion: $[stageDependencies.Build_and_Test.Build.outputs['Package.AutorestCSharpVersion']] TypeSpecEmitterVersion: $[stageDependencies.Build_and_Test.Build.outputs['Publish.TypeSpecEmitterVersion']] + BranchName: "auto-update-autorest-$(AutorestCSharpVersion)" jobs: - template: update-generator-versions.yml parameters: + Name: Update_Generator_Version AutorestCSharpVersion: $(AutorestCSharpVersion) - TypeSpecEmitterVersion: $(TypeSpecEmitterVersion) + BranchName: $(BranchName) - template: generate-sdk-job-matrix-files.yml parameters: Name: Generate_Job_Matrix + DependsOn: Update_Generator_Version JobCount: 7 + BranchName: $(BranchName) - template: update-azure-sdk-for-net-codes.yml parameters: Name: Update_Code + DependsOn: Generate_Job_Matrix Matrix: $[dependencies.Generate_Job_Matrix.outputs['generate_job_matrix.matrix']] AutorestCSharpVersion: $(AutorestCSharpVersion) - TypeSpecEmitterVersion: $(TypeSpecEmitterVersion) - DependsOn: Generate_Job_Matrix + BranchName: $(BranchName) - job: Create_PR - dependsOn: - - Update_Code + dependsOn: Update_Code steps: - checkout: self - checkout: azure-sdk-tools @@ -205,7 +215,7 @@ stages: -RepoName "azure-sdk-for-net" -BaseBranch "main" -PROwner "azure-sdk" - -PRBranch "auto-update-autorest-$(AutorestCSharpVersion)" + -PRBranch $(BranchName) -AuthToken "$(azuresdk-github-pat)" -PRTitle "Update AutoRest C# version to $(AutorestCSharpVersion)" -PRBody "Update AutoRest C# version to $(AutorestCSharpVersion)" diff --git a/eng/pipelines/check-code-generation.yml b/eng/pipelines/check-code-generation.yml index 8bae043e8ff..335d759eca4 100644 --- a/eng/pipelines/check-code-generation.yml +++ b/eng/pipelines/check-code-generation.yml @@ -30,14 +30,12 @@ jobs: useGlobalJson: true performMultiLevelLookup: true - ${{ if eq(parameters.usePackageJsonFromArtifacts, 'true') }}: - - task: DownloadPipelineArtifact@2 + - download: current + artifact: package-json displayName: 'Download package-json artifact' - inputs: - buildType: current - artifact: package-json - targetPath: $(Build.SourcesDirectory) - pwsh: | - Move-Item ./emitter-package.json ./src/TypeSpec.Extension/Emitter.Csharp/package.json -Force + Copy-Item $(Pipeline.Workspace)/package-json/package*.json ./ -Force + Copy-Item $(Pipeline.Workspace)/package-json/emitter/package.json ./src/TypeSpec.Extension/Emitter.Csharp/package.json -Force git add './package.json' './package-lock.json' './src/TypeSpec.Extension/Emitter.Csharp/package.json' displayName: 'Replace Emitter.Csharp/package.json' workingDirectory: $(Build.SourcesDirectory) diff --git a/eng/pipelines/generate-sdk-job-matrix-files.yml b/eng/pipelines/generate-sdk-job-matrix-files.yml index a6ea9c36cf1..0c642ced527 100644 --- a/eng/pipelines/generate-sdk-job-matrix-files.yml +++ b/eng/pipelines/generate-sdk-job-matrix-files.yml @@ -1,14 +1,20 @@ parameters: - JobCount: 0 - Name: "" + - name: JobCount + type: number + - name: Name + type: string + - name: DependsOn + type: object + - name: BranchName + type: string jobs: - job: ${{ parameters.Name }} + dependsOn: ${{ parameters.DependsOn }} timeoutInMinutes: 60 pool: name: azsdk-pool-mms-ubuntu-2004-general vmImage: ubuntu-20.04 - steps: - checkout: self fetchDepth: 1 @@ -22,6 +28,7 @@ jobs: Repositories: - Name: Azure/azure-sdk-for-net WorkingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net + Committish: refs/heads/${{ parameters.BranchName}} SkipCheckoutNone: true - pwsh: ./eng/GenerateSdkForNetCodeGenerationMatrix.ps1 -SdkForNetPath $(Build.SourcesDirectory)/azure-sdk-for-net -GroupCount ${{ parameters.JobCount }} -OutputFolder $(System.DefaultWorkingDirectory)/output displayName: "Generate Matrix Files" diff --git a/eng/pipelines/new-emitter-package-files.yml b/eng/pipelines/new-emitter-package-files.yml new file mode 100644 index 00000000000..c3a529d800d --- /dev/null +++ b/eng/pipelines/new-emitter-package-files.yml @@ -0,0 +1,34 @@ +parameters: +- name: EmitterPackageJsonPath + type: string +- name: AutorestCSharpVersion + type: string +- name: TypeSpecEmitterVersion + type: string +- name: ToolsRepositoryPath + type: string +- name: OutputDirectory + type: string + +steps: +- pwsh: | + $feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry" + + $overridesPath = "${{ parameters.OutputDirectory }}/overrides.json" + + $overrides = @{ + "@autorest/csharp" = "$feedUrl/@autorest/csharp/-/csharp-${{ parameters.AutorestCSharpVersion }}.tgz" + "@azure-tools/typespec-csharp" = "$feedUrl/@azure-tools/typespec-csharp/-/typespec-csharp-${{ parameters.TypeSpecEmitterVersion }}.tgz" + } + + $overrides | ConvertTo-Json | Set-Content $overridesPath + + & ${{ parameters.ToolsRepositoryPath }}/eng/scripts/autorest/New-EmitterPackageJson.ps1 ` + -PackageJsonPath '${{ parameters.EmitterPackageJsonPath }}' ` + -OverridesPath $overridesPath ` + -OutputDirectory '${{ parameters.OutputDirectory }}' + + & ${{ parameters.ToolsRepositoryPath }}/eng/scripts/autorest/New-EmitterPackageLock.ps1 ` + -EmitterPackageJsonPath '${{ parameters.OutputDirectory }}/emitter-package.json' ` + -OutputDirectory '${{ parameters.OutputDirectory }}' + displayName: Create emitter-package.json diff --git a/eng/pipelines/sdk-update.yml b/eng/pipelines/sdk-update.yml index e7b8c2e6f59..f23ff7023ec 100644 --- a/eng/pipelines/sdk-update.yml +++ b/eng/pipelines/sdk-update.yml @@ -14,16 +14,12 @@ resources: type: github name: Azure/azure-sdk-tools endpoint: azure - ref: refs/tags/azure-sdk-tools_20230428.1 + ref: main - repository: azure-sdk-for-net type: github name: Azure/azure-sdk-for-net endpoint: azure ref: main - - repository: azure-sdk-build-tools - type: git - name: internal/azure-sdk-build-tools - ref: refs/tags/azure-sdk-build-tools_20230829.1 stages: - stage: 'Build_and_Test' @@ -53,9 +49,9 @@ stages: displayName: "Use 'next' TypeSpec dependencies" workingDirectory: $(Build.SourcesDirectory)/autorest.csharp - pwsh: | - $dir = New-Item -ItemType Directory -Path $(Build.ArtifactStagingDirectory)/package-json -Verbose + $dir = New-Item -ItemType Directory -Path $(Build.ArtifactStagingDirectory)/package-json/emitter -Verbose Copy-Item ./package*.json $(Build.ArtifactStagingDirectory)/package-json -Verbose - Copy-Item ./src/TypeSpec.Extension/Emitter.Csharp/package.json $(Build.ArtifactStagingDirectory)/package-json/emitter-package.json -Verbose + Copy-Item ./src/TypeSpec.Extension/Emitter.Csharp/package.json $(Build.ArtifactStagingDirectory)/package-json/emitter/package.json -Verbose workingDirectory: $(Build.SourcesDirectory)/autorest.csharp displayName: 'Stage package-json artifact' condition: succeededOrFailed() @@ -123,7 +119,7 @@ stages: workingDir: '$(Build.SourcesDirectory)/autorest.csharp/artifacts/bin/AutoRest.CSharp/Release/net6.0' publishRegistry: 'useFeed' publishFeed: '29ec6040-b234-4e31-b139-33dc4287b756/05efbea8-6e52-49dd-ad3d-ac3d4aa65036' - - pwsh: ./eng/PackEmitter.ps1 -BuildNumber $(Build.BuildNumber) -AutorestVersion $(Package.autorestVersion) -StagingDirectory $(Build.ArtifactStagingDirectory)/packages + - pwsh: ./eng/PackEmitter.ps1 -BuildNumber $(Build.BuildNumber) -AutorestVersion $(Package.AutorestCSharpVersion) -StagingDirectory $(Build.ArtifactStagingDirectory)/packages name: PackEmitter displayName: "Pack Emitter" workingDirectory: $(Build.SourcesDirectory)/autorest.csharp @@ -134,10 +130,17 @@ stages: workingDir: '$(Build.SourcesDirectory)/autorest.csharp/src/TypeSpec.Extension/Emitter.Csharp' publishRegistry: 'useFeed' publishFeed: '29ec6040-b234-4e31-b139-33dc4287b756/05efbea8-6e52-49dd-ad3d-ac3d4aa65036' - - publish: $(Build.ArtifactStagingDirectory)/packages - artifact: packages + - template: new-emitter-package-files.yml + parameters: + EmitterPackageJsonPath: '$(Build.SourcesDirectory)/autorest.csharp/src/TypeSpec.Extension/Emitter.Csharp/package.json' + AutorestCSharpVersion: $(Package.AutorestCSharpVersion) + TypeSpecEmitterVersion: $(PackEmitter.TypeSpecEmitterVersion) + OutputDirectory: $(Build.ArtifactStagingDirectory) + ToolsRepositoryPath: $(Build.SourcesDirectory)/azure-sdk-tools + - publish: $(Build.ArtifactStagingDirectory) + artifact: build_artifacts condition: succeededOrFailed() - displayName: "Publish packages artifact" + displayName: "Publish build artifacts" - ${{ if eq(parameters.UseTypeSpecNext, 'true') }}: - stage: 'Check_Code_Generation' dependsOn: @@ -167,30 +170,30 @@ stages: dependsOn: - Build_and_Test variables: - AutorestCSharpVersion: $[stageDependencies.Build_and_Test.Build.outputs['Package.autorestVersion']] - TypeSpecEmitterVersion: $[stageDependencies.Build_and_Test.Build.outputs['PackEmitter.emitterVersion']] + AutorestCSharpVersion: $[stageDependencies.Build_and_Test.Build.outputs['Package.AutorestCSharpVersion']] + TypeSpecEmitterVersion: $[stageDependencies.Build_and_Test.Build.outputs['PackEmitter.TypeSpecEmitterVersion']] + BranchName: "auto-update-autorest-$(AutorestCSharpVersion)" jobs: - template: update-generator-versions.yml parameters: + Name: Update_Generator_Version AutorestCSharpVersion: $(AutorestCSharpVersion) - TypeSpecEmitterVersion: $(TypeSpecEmitterVersion) - IsInternalFeed: true + BranchName: $(BranchName) - template: generate-sdk-job-matrix-files.yml parameters: Name: Generate_Job_Matrix + DependsOn: Update_Generator_Version JobCount: 7 + BranchName: $(BranchName) - template: update-azure-sdk-for-net-codes.yml parameters: Name: Update_Code + DependsOn: Generate_Job_Matrix Matrix: $[dependencies.Generate_Job_Matrix.outputs['generate_job_matrix.matrix']] AutorestCSharpVersion: $(AutorestCSharpVersion) - TypeSpecEmitterVersion: $(TypeSpecEmitterVersion) - IsInternalFeed: true - DependsOn: Generate_Job_Matrix + BranchName: $(BranchName) - job: Create_PR - dependsOn: - - Update_Generator_Versions - - Update_Code + dependsOn: Update_Code steps: - checkout: self fetchDepth: 1 @@ -210,7 +213,7 @@ stages: -RepoName "azure-sdk-for-net" -BaseBranch "main" -PROwner "azure-sdk" - -PRBranch "auto-update-autorest-$(AutorestCSharpVersion)" + -PRBranch "$(BranchName)" -AuthToken "$(azuresdk-github-pat)" -PRTitle "Autorest Regen Preview to $(AutorestCSharpVersion) by $(Build.QueuedBy) from $(Build.SourceBranch)" -PRBody "Triggered from $(PRUrl.PRUrl)" diff --git a/eng/pipelines/update-azure-sdk-for-net-codes.yml b/eng/pipelines/update-azure-sdk-for-net-codes.yml index d7bd75c430b..5f9d3369d34 100644 --- a/eng/pipelines/update-azure-sdk-for-net-codes.yml +++ b/eng/pipelines/update-azure-sdk-for-net-codes.yml @@ -1,12 +1,16 @@ # Generate SDK codes parameters: - Name: '' - AutorestCSharpVersion: '' - TypeSpecEmitterVersion: '' - IsInternalFeed: false - Matrix: {} - DependsOn: [] + - name: Name + type: string + - name: AutorestCSharpVersion + type: string + - name: BranchName + type: string + - name: DependsOn + type: object + - name: Matrix + type: object jobs: - job: ${{ parameters.Name }} @@ -30,6 +34,7 @@ jobs: Repositories: - Name: Azure/azure-sdk-for-net WorkingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net + Committish: refs/heads/${{ parameters.BranchName }}} SkipCheckoutNone: true - task: UseDotNet@2 displayName: 'Use .NET Core SDK' @@ -41,47 +46,27 @@ jobs: inputs: artifact: matrix-props targetPath: $(Build.SourcesDirectory)/azure-sdk-for-net/artifacts/matrix-props - - - ${{ if eq(parameters.IsInternalFeed, true) }}: - - pwsh: ./eng/GenerateInternalNpmrc.ps1 -ContainingFolder $(Build.SourcesDirectory)/azure-sdk-for-net - displayName: "Generate Internal Npmrc" - workingDirectory: $(Build.SourcesDirectory)/autorest.csharp - - task: npmAuthenticate@0 - inputs: - workingFile: '$(Build.SourcesDirectory)/azure-sdk-for-net/.npmrc' - displayName: Setup Internal NPM Auth - task: Powershell@2 displayName: Update SDK codes inputs: pwsh: true - filePath: $(Build.SourcesDirectory)/autorest.csharp/eng/UpdateAzureSdkForNet.ps1 + filePath: $(Build.SourcesDirectory)/autorest.csharp/eng/UpdateAzureSdkCodes.ps1 arguments: > - -AutorestCSharpVersion ${{ parameters.AutorestCSharpVersion }} - -TypeSpecEmitterVersion ${{ parameters.TypeSpecEmitterVersion }} -SdkRepoRoot $(Build.SourcesDirectory)/azure-sdk-for-net -ProjectListOverrideFile artifacts/matrix-props/$(ProjectListOverrideFile) -ShowSummary - -UseInternalFeed $${{parameters.IsInternalFeed}} failOnStderr: false workingDirectory: $(Build.SourcesDirectory)/autorest.csharp retryCountOnTaskFailure: 1 - pwsh: | - git restore eng/Packages.Data.props - git restore eng/emitter-package.json + git restore NuGet.Config displayName: Discard versions change workingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net - - ${{ if eq(parameters.IsInternalFeed, true) }}: - - pwsh: | - git restore NuGet.Config - git restore eng/common/scripts/TypeSpec-Project-Generate.ps1 - rm .npmrc - displayName: Discard Internal Change - workingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net - template: /eng/common/pipelines/templates/steps/git-push-changes.yml@azure-sdk-tools parameters: - BaseRepoBranch: auto-update-autorest-${{ parameters.AutorestCSharpVersion }} + BaseRepoBranch: ${{ parameters.BranchName }}} BaseRepoOwner: azure-sdk - CommitMsg: Update SDK codes ${{ parameters.filter }} + CommitMsg: Update SDK codes $(JobKey) TargetRepoOwner: Azure TargetRepoName: azure-sdk-for-net WorkingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net diff --git a/eng/pipelines/update-generator-versions.yml b/eng/pipelines/update-generator-versions.yml index 1c9c7faffb3..662cdb0c8d5 100644 --- a/eng/pipelines/update-generator-versions.yml +++ b/eng/pipelines/update-generator-versions.yml @@ -1,25 +1,42 @@ # Update `autorest.csharp` and TypeSpec emitter versions parameters: - AutorestCSharpVersion: "" - TypeSpecEmitterVersion: "" - IsInternalFeed: false + - name: Name + type: string + - name: AutorestCSharpVersion + type: string + - name: BranchName + type: string jobs: -- job: Update_Generator_Versions +- job: ${{ parameters.Name }} pool: name: azsdk-pool-mms-ubuntu-2004-general vmImage: ubuntu-20.04 steps: - checkout: self fetchDepth: 1 - - checkout: azure-sdk-for-net - checkout: azure-sdk-tools fetchDepth: 1 - - ${{ if eq(parameters.IsInternalFeed, true) }}: - - pwsh: ./eng/GenerateInternalNpmrc.ps1 -ContainingFolder $(Build.SourcesDirectory)/azure-sdk-for-net - displayName: "Generate Internal Npmrc" - workingDirectory: $(Build.SourcesDirectory)/autorest.csharp + - template: eng/common/pipelines/templates/steps/sparse-checkout.yml@azure-sdk-tools + parameters: + Paths: + - "/*" + - "!SessionRecords" + Repositories: + - Name: Azure/azure-sdk-for-net + WorkingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net + SkipCheckoutNone: true + - download: current + artifact: build_artifacts + - pwsh: | + Write-Host "Deleting existing emitter-package files" + Remove-Item emitter-package*.json -Force + + Write-Host "Copying emitter-package files" + Copy-Item $(Pipeline.Workspace)/build_artifacts/emitter-package*.json . + displayName: Copy emitter-package files + workingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net/eng - task: Powershell@2 displayName: Update SDK Generator Versions inputs: @@ -27,19 +44,11 @@ jobs: filePath: $(Build.SourcesDirectory)/autorest.csharp/eng/UpdateGeneratorMetadata.ps1 arguments: > -AutorestCSharpVersion ${{parameters.AutorestCSharpVersion}} - -TypeSpecEmitterVersion ${{parameters.TypeSpecEmitterVersion}} -SdkRepoRoot $(Build.SourcesDirectory)/azure-sdk-for-net - -UseInternalFeed $${{parameters.IsInternalFeed}} workingDirectory: $(Build.SourcesDirectory)/autorest.csharp - - ${{ if eq(parameters.IsInternalFeed, true) }}: # This stage needs to be remove after https://github.com/Azure/autorest.csharp/issues/3216 - - pwsh: | - git restore eng/common/scripts/TypeSpec-Project-Generate.ps1 - rm .npmrc - displayName: Discard Internal Change - workingDirectory: $(Build.SourcesDirectory)/azure-sdk-for-net - template: /eng/common/pipelines/templates/steps/git-push-changes.yml@azure-sdk-tools parameters: - BaseRepoBranch: auto-update-autorest-${{parameters.AutorestCSharpVersion}} + BaseRepoBranch: ${{ parameters.BranchName }} BaseRepoOwner: azure-sdk CommitMsg: Update Generator Version ${{parameters.AutorestCSharpVersion}} TargetRepoOwner: Azure diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/lib/clientModelBuilder.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/lib/clientModelBuilder.ts index 847097196cb..a23079ee769 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/lib/clientModelBuilder.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/lib/clientModelBuilder.ts @@ -185,7 +185,7 @@ export function createModelForService( for (const client of clients) { for (const op of client.Operations) { const apiVersionIndex = op.Parameters.findIndex( - (value) => value.IsApiVersion + (value: InputParameter) => value.IsApiVersion ); if (apiVersionIndex !== -1) { const apiVersionInOperation = op.Parameters[apiVersionIndex]; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/lib/typespecServer.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/lib/typespecServer.ts index 03c4432e790..d48717d9237 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/lib/typespecServer.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/lib/typespecServer.ts @@ -15,7 +15,7 @@ import { import { InputTypeKind } from "../type/inputTypeKind.js"; import { RequestLocation } from "../type/requestLocation.js"; import { getInputType, getFormattedType } from "./model.js"; -import { SdkContext } from "@azure-tools/typespec-client-generator-core/dist/src/interfaces.js"; +import { SdkContext } from "@azure-tools/typespec-client-generator-core"; export interface TypeSpecServer { url: string; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputClient.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputClient.ts index 516f82f3c2f..64b7e29fd78 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputClient.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputClient.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputOperation } from "./inputOperation"; -import { InputParameter } from "./inputParameter"; -import { Protocols } from "./protocols"; +import { InputOperation } from "./inputOperation.js"; +import { InputParameter } from "./inputParameter.js"; +import { Protocols } from "./protocols.js"; export interface InputClient { Name: string; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputModelProperty.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputModelProperty.ts index 640cd38397f..3e3fbd5ecd3 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputModelProperty.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputModelProperty.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputType } from "./inputType"; +import { InputType } from "./inputType.js"; export interface InputModelProperty { Name: string; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputOperation.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputOperation.ts index 913a31cfe91..845e76e856e 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputOperation.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputOperation.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { BodyMediaType } from "./bodyMediaType"; -import { OperationLongRunning } from "./operationLongRunning"; -import { OperationPaging } from "./operationPaging"; -import { InputParameter } from "./inputParameter"; -import { OperationResponse } from "./operationResponse"; -import { RequestMethod } from "./requestMethod"; +import { BodyMediaType } from "./bodyMediaType.js"; +import { OperationLongRunning } from "./operationLongRunning.js"; +import { OperationPaging } from "./operationPaging.js"; +import { InputParameter } from "./inputParameter.js"; +import { OperationResponse } from "./operationResponse.js"; +import { RequestMethod } from "./requestMethod.js"; export interface Paging { NextLinkName?: string; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputParameter.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputParameter.ts index 98b202dd252..6a02dbe0bd3 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputParameter.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/type/inputParameter.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputConstant } from "./inputConstant"; -import { InputOperationParameterKind } from "./inputOperationParameterKind"; -import { InputType } from "./inputType"; -import { RequestLocation } from "./requestLocation"; +import { InputConstant } from "./inputConstant.js"; +import { InputOperationParameterKind } from "./inputOperationParameterKind.js"; +import { InputType } from "./inputType.js"; +import { RequestLocation } from "./requestLocation.js"; //TODO: Define VirtualParameter for HLC export interface VirtualParameter {} diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/type/operationPaging.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/type/operationPaging.ts index 408cc7b96de..c93b741aec3 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/type/operationPaging.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/type/operationPaging.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputOperation } from "./inputOperation"; +import { InputOperation } from "./inputOperation.js"; export interface OperationPaging { NextLinkName?: string; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/tsconfig.json b/src/TypeSpec.Extension/Emitter.Csharp/tsconfig.json index d051e75f0c5..41fdce813b0 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/tsconfig.json +++ b/src/TypeSpec.Extension/Emitter.Csharp/tsconfig.json @@ -5,8 +5,8 @@ "alwaysStrict": true, "forceConsistentCasingInFileNames": true, "preserveConstEnums": true, - "module": "esnext", - "moduleResolution": "node", + "module": "node16", + "moduleResolution": "node16", "esModuleInterop": true, "noImplicitAny": true, "noImplicitReturns": true,