Skip to content
Open
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
75 changes: 11 additions & 64 deletions eng/pipelines/jobs/build-for-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,10 @@ jobs:

- template: /eng/pipelines/templates/upload-coverage.yml

# Python e2e tests and spector coverage upload
- task: UsePythonVersion@0
displayName: "Use Python 3.12"
inputs:
versionSpec: "3.12"

- script: pnpm run prepare
displayName: "Prepare Python environment"
workingDirectory: packages/typespec-python

- script: pnpm run regenerate
displayName: "Regenerate Python test code"
workingDirectory: packages/typespec-python

- script: pnpm run test:python:e2e
displayName: "Run Python e2e tests"
workingDirectory: packages/typespec-python

- template: /eng/pipelines/templates/upload-spector-coverage.yml
parameters:
PackagePath: packages/typespec-python
GeneratorName: "@azure-tools/typespec-python"

# Java e2e tests and spector coverage upload. The emitter-tests project is a
# standalone npm+Maven project (not in the pnpm workspace). The emitter + its
# dependencies are already built by the repo-wide `pnpm build` above, so pass
# -SkipBuild: Generate.ps1 -> Setup.ps1 only packs the .tgz, npm installs it and
# regenerates the SDK from the spector specs; Spector-Tests.ps1 starts the
# mock server, runs the JUnit tests and produces tsp-spector-coverage-java.json.
- pwsh: ./Generate.ps1 -SkipBuild
displayName: "Regenerate Java test code"
workingDirectory: packages/typespec-java/emitter-tests

- pwsh: ./Spector-Tests.ps1
displayName: "Run Java spector tests"
workingDirectory: packages/typespec-java/emitter-tests

- template: /eng/pipelines/templates/upload-spector-coverage.yml
parameters:
PackagePath: packages/typespec-java/emitter-tests
GeneratorName: "@azure-tools/typespec-java"
# TypeScript (typespec-ts) e2e tests and spector coverage upload.
# The emitter was migrated here from Azure/autorest.typescript; this replaces
# the coverage upload that previously ran in that (now deprecated) repo.
- script: pnpm run integration-test-ci
displayName: "Run TypeScript e2e tests"
workingDirectory: packages/typespec-ts

- task: AzureCLI@2
displayName: "Upload spector coverage (typespec-ts, azure)"
continueOnError: true
inputs:
azureSubscription: "TypeSpec Storage"
scriptType: "bash"
scriptLocation: "inlineScript"
inlineScript: >-
npx tsp-spector upload-coverage
--coverageFile ./coverage/spector-coverage-typescript-azure.json
--generatorName "@azure-tools/typespec-ts"
--storageAccountName typespec
--containerName coverages
--generatorVersion $(node -p -e "require('./package.json').version")
--generatorMode azure
workingDirectory: packages/typespec-ts
# The emitter e2e tests + spector coverage upload no longer run here so they
# don't gate npm publishing. They run in parallel in the `spector_coverage`
# stage, reusing the turbo build cache published below. See
# eng/pipelines/jobs/spector-coverage.yml.

- template: /eng/pipelines/templates/pack.yml
parameters:
Expand Down Expand Up @@ -144,3 +84,10 @@ jobs:
path: $(Build.ArtifactStagingDirectory)/npm-packages-next
artifact: npm-packages-next
displayName: Publish npm next packages(.tgz) as pipeline artifacts

# Turbo build cache, consumed by the spector_coverage stage so its jobs
# restore build outputs (dist/**) instead of recompiling the repo.
- output: pipelineArtifact
path: $(Build.SourcesDirectory)/.turbo/cache
artifact: turbo-cache
displayName: Publish turbo build cache for spector coverage jobs
135 changes: 135 additions & 0 deletions eng/pipelines/jobs/spector-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Emitter end-to-end tests that produce and upload spector coverage reports.
#
# These jobs are intentionally decoupled from the npm publish path: they run in
# the `spector_coverage` stage which `publish_npm` does NOT depend on, so a slow
# or failing emitter e2e run never blocks publishing. A failure here still fails
# the overall pipeline run for visibility.
#
# Each job restores the turbo build cache published by the `build` stage
# (artifact `turbo-cache`) and then runs `pnpm run build`, which is a series of
# turbo cache hits that restore dist/** outputs instead of recompiling the repo.

parameters:
- name: TurboCacheArtifact
type: string
default: turbo-cache

jobs:
- job: spector_python
displayName: Spector Coverage (Python)
variables:
TYPESPEC_SKIP_WEBSITE_BUILD: true
steps:
- checkout: self
submodules: true

- template: /eng/pipelines/templates/install.yml

- task: UsePythonVersion@0
displayName: "Use Python 3.12"
inputs:
versionSpec: "3.12"

- task: DownloadPipelineArtifact@2
displayName: Restore turbo build cache
inputs:
artifact: ${{ parameters.TurboCacheArtifact }}
path: $(Build.SourcesDirectory)/.turbo/cache

- script: pnpm run build
displayName: Build (turbo cache restore)

- script: pnpm run prepare
displayName: "Prepare Python environment"
workingDirectory: packages/typespec-python

- script: pnpm run regenerate
displayName: "Regenerate Python test code"
workingDirectory: packages/typespec-python

- script: pnpm run test:python:e2e
displayName: "Run Python e2e tests"
workingDirectory: packages/typespec-python

- template: /eng/pipelines/templates/upload-spector-coverage.yml
parameters:
PackagePath: packages/typespec-python
GeneratorName: "@azure-tools/typespec-python"

- job: spector_java
displayName: Spector Coverage (Java)
variables:
TYPESPEC_SKIP_WEBSITE_BUILD: true
steps:
- checkout: self
submodules: true

- template: /eng/pipelines/templates/install.yml

- task: DownloadPipelineArtifact@2
displayName: Restore turbo build cache
inputs:
artifact: ${{ parameters.TurboCacheArtifact }}
path: $(Build.SourcesDirectory)/.turbo/cache

- script: pnpm run build
displayName: Build (turbo cache restore)

# emitter-tests is a standalone npm+Maven project (not in the pnpm
# workspace). The turbo cache only restores dist/** outputs, not the
# Maven emitter.jar, so run Generate.ps1 WITHOUT -SkipBuild: it builds the
# emitter jar, then regenerates the SDK from the spector specs.
# Spector-Tests.ps1 starts the mock server, runs the JUnit tests and
# produces tsp-spector-coverage-java.json.
- pwsh: ./Generate.ps1
displayName: "Regenerate Java test code"
workingDirectory: packages/typespec-java/emitter-tests

- pwsh: ./Spector-Tests.ps1
displayName: "Run Java spector tests"
workingDirectory: packages/typespec-java/emitter-tests

- template: /eng/pipelines/templates/upload-spector-coverage.yml
parameters:
PackagePath: packages/typespec-java/emitter-tests
GeneratorName: "@azure-tools/typespec-java"

- job: spector_ts
displayName: Spector Coverage (TypeScript)
variables:
TYPESPEC_SKIP_WEBSITE_BUILD: true
steps:
- checkout: self
submodules: true

- template: /eng/pipelines/templates/install.yml

- task: DownloadPipelineArtifact@2
displayName: Restore turbo build cache
inputs:
artifact: ${{ parameters.TurboCacheArtifact }}
path: $(Build.SourcesDirectory)/.turbo/cache

- script: pnpm run build
displayName: Build (turbo cache restore)

- script: pnpm run integration-test-ci
displayName: "Run TypeScript e2e tests"
workingDirectory: packages/typespec-ts

- task: AzureCLI@2
displayName: "Upload spector coverage (typespec-ts, azure)"
continueOnError: true
inputs:
azureSubscription: "TypeSpec Storage"
scriptType: "bash"
scriptLocation: "inlineScript"
inlineScript: >-
npx tsp-spector upload-coverage
--coverageFile ./coverage/spector-coverage-typescript-azure.json
--generatorName "@azure-tools/typespec-ts"
--storageAccountName typespec
--containerName coverages
--generatorVersion $(node -p -e "require('./package.json').version")
--generatorMode azure
workingDirectory: packages/typespec-ts
14 changes: 14 additions & 0 deletions eng/pipelines/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ extends:
jobs:
- template: /eng/pipelines/jobs/build-for-publish.yml@self

# Emitter e2e tests + spector coverage upload. Runs in parallel with the
# publish path (publish_npm does not depend on this stage), so it never
# gates npm publishing. dependsOn build only to consume the turbo-cache
# artifact and avoid recompiling the repo.
- stage: spector_coverage
displayName: Spector Coverage
dependsOn: build
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux
jobs:
- template: /eng/pipelines/jobs/spector-coverage.yml@self

- stage: publish_npm
displayName: Publish Npm Packages
dependsOn: build
Expand Down
Loading