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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@typespec/http-client-java"
- "@typespec/http-client-python"
---

Publish Azure DevOps test results after the shared test script for all language emitters.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-java"
---

Suppress Maven transfer progress during Java CI formatting checks and smoke-project builds while retaining normal build logs.
7 changes: 7 additions & 0 deletions .chronus/changes/UpdateTargetVersions-2026-9-29-10-7-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-java"
---

Cache Maven dependencies in Java CI and publish generator, emitter, and Spector test results to Azure DevOps, including failed test runs.
31 changes: 30 additions & 1 deletion eng/common/pipelines/templates/steps/maven-authenticate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,39 @@ steps:
# Copy mirror settings to default Maven location so all requests go through CFS
- pwsh: |
$m2Dir = if ($env:USERPROFILE) { "$env:USERPROFILE\.m2" } else { "$HOME/.m2" }
New-Item -ItemType Directory -Force -Path $m2Dir | Out-Null
$mavenRepositoryPath = Join-Path $m2Dir "repository"
New-Item -ItemType Directory -Force -Path $mavenRepositoryPath | Out-Null
Write-Host "##vso[task.setvariable variable=MavenRepositoryPath]$mavenRepositoryPath"
Copy-Item -Path "${{ parameters.SourceDirectory }}/eng/settings.xml" -Destination "$m2Dir/settings.xml"

# Hash tracked POMs to avoid circular npm links and keep the cache key bounded.
$pomFiles = git -C "${{ parameters.SourceDirectory }}" ls-files -- "**/pom.xml"
if ($LASTEXITCODE -ne 0) {
throw "Failed to list tracked Maven POM files."
}
if (-not $pomFiles) {
throw "No tracked Maven POM files found."
}
$pomHashes = $pomFiles | ForEach-Object {
$path = Join-Path "${{ parameters.SourceDirectory }}" $_
"$_=$((Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash)"
}
$pomHashInput = [System.Text.Encoding]::UTF8.GetBytes($pomHashes -join "`n")
$pomHash = [Convert]::ToHexString([System.Security.Cryptography.SHA256]::HashData($pomHashInput))
Write-Host "##vso[task.setvariable variable=MavenPomHash]$pomHash"
displayName: "Setup Maven mirror settings"

# Cache artifacts only; settings.xml contains feed credentials.
# Include the stage so test jobs can save dependencies absent from build caches.
- task: Cache@2
displayName: "Cache Maven repository"
inputs:
key: '"maven" | "$(Agent.OS)" | "$(System.StageName)" | "$(MavenPomHash)"'
restoreKeys: |
"maven" | "$(Agent.OS)" | "$(System.StageName)"
"maven" | "$(Agent.OS)"
path: $(MavenRepositoryPath)

# Authenticate with Azure Artifacts feeds
# MavenAuthenticate adds <server> entries to ~/.m2/settings.xml matching mirror id 'azure-sdk-for-java'
- task: MavenAuthenticate@0
Expand Down
14 changes: 14 additions & 0 deletions eng/emitters/pipelines/templates/steps/build-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,17 @@ steps:
-PublishType:"${{ parameters.Publish }}"
-Prerelease:$${{ parameters.BuildPrereleaseVersion }}
workingDirectory: $(selfRepositoryPath)

- ${{ if eq(parameters.LanguageShortName, 'java') }}:
- task: PublishTestResults@2
displayName: "Publish Java generator test results"
condition: succeededOrFailed()
inputs:
testResultsFormat: JUnit
testResultsFiles: "generator/**/target/surefire-reports/TEST-*.xml"
searchFolder: $(selfRepositoryPath)${{ parameters.PackagePath }}
mergeTestResults: true
testRunTitle: Java generator $(Agent.JobName)
failTaskOnFailedTests: true
failTaskOnFailureToPublishResults: true
failTaskOnMissingResultsFile: true
36 changes: 36 additions & 0 deletions eng/emitters/pipelines/templates/steps/test-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,42 @@ steps:
arguments: ${{ parameters.TestArgs }}
workingDirectory: $(selfRepositoryPath)

- task: PublishTestResults@2
displayName: "Publish ${{ parameters.LanguageShortName }} test script results"
${{ if eq(parameters.LanguageShortName, 'python') }}:
condition: and(succeededOrFailed(), contains(coalesce(variables['TestArguments'], '${{ parameters.TestArgs }}'), '-GenerationChecks'))
${{ elseif eq(parameters.LanguageShortName, 'java') }}:
# Regeneration also rebuilds the Java generator and runs its Maven tests.
condition: and(succeededOrFailed(), or(contains(coalesce(variables['TestArguments'], '${{ parameters.TestArgs }}'), '-UnitTests'), contains(coalesce(variables['TestArguments'], '${{ parameters.TestArgs }}'), '-GenerationChecks')))
${{ else }}:
condition: and(succeededOrFailed(), contains('${{ parameters.TestArgs }}', '-UnitTests'))
inputs:
testResultsFormat: JUnit
testResultsFiles: |
test-results.xml
generator/**/target/surefire-reports/TEST-*.xml
tests/test-results/*.xml
searchFolder: $(selfRepositoryPath)${{ parameters.PackagePath }}
mergeTestResults: true
testRunTitle: ${{ parameters.LanguageShortName }} $(Agent.JobName)
failTaskOnFailedTests: true
failTaskOnFailureToPublishResults: true
failTaskOnMissingResultsFile: true

- ${{ if eq(parameters.LanguageShortName, 'csharp') }}:
- task: PublishTestResults@2
displayName: "Publish C# generator and Spector test results"
condition: and(succeededOrFailed(), contains('${{ parameters.TestArgs }}', '-UnitTests'))
inputs:
testResultsFormat: VSTest
testResultsFiles: "generator/**/TestResults/*.trx"
searchFolder: $(selfRepositoryPath)${{ parameters.PackagePath }}
mergeTestResults: true
testRunTitle: C# generator $(Agent.JobName)
failTaskOnFailedTests: true
failTaskOnFailureToPublishResults: true
failTaskOnMissingResultsFile: true

- ${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.EnableCadlRanchReport, true)) }}:
- task: AzureCLI@2
displayName: "Upload Cadl Ranch Standard Coverage Report"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $specs = Get-Sorted-Specs

# test all
Write-Host "Generating Spector coverage" -ForegroundColor Cyan
$command = "dotnet test $spectorCsproj"
$command = "dotnet test $spectorCsproj --logger trx"
Invoke $command
# exit if the testing failed
if ($LASTEXITCODE -ne 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-csharp/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ try {

# test the emitter
Invoke-LoggedCommand "npm run build" -GroupOutput
Invoke-LoggedCommand "npm run test:emitter" -GroupOutput
Invoke-LoggedCommand "npm run test:emitter -- --reporter=default --reporter=junit" -GroupOutput

# enforce cop static-analysis rules on the generator sources
Invoke-LoggedCommand "./eng/scripts/Invoke-Cop.ps1" -GroupOutput

# test the generator
Invoke-LoggedCommand "dotnet test ./generator -p:RestoreConfigFile=`"$nugetConfigPath`" $ciNugetAuditArg" -GroupOutput
Invoke-LoggedCommand "dotnet test ./generator --logger trx -p:RestoreConfigFile=`"$nugetConfigPath`" $ciNugetAuditArg" -GroupOutput

Invoke-LoggedCommand "./eng/scripts/Get-Spector-Coverage.ps1" -GroupOutput
}
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-java/eng/scripts/Build-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ try {
Invoke-LoggedCommand "mvn -version"

# check code format, before package
Invoke-LoggedCommand "mvn spotless:check --activate-profiles test"
Invoke-LoggedCommand "mvn spotless:check --no-transfer-progress --activate-profiles test"

Invoke-LoggedCommand "mvn clean install --no-transfer-progress -T 1C -f ./pom.xml"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-java/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Push-Location $packageRoot
try {
if ($UnitTests) {
Invoke-LoggedCommand "npm run typecheck"
Invoke-LoggedCommand "npm run test"
Invoke-LoggedCommand "npm run test:emitter --registry=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/ -- --reporter=default --reporter=junit"
Write-Host "Emitter unit tests passed"

Write-Host "Current PATH: $env:PATH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Generate-Compile ($folder) {

Push-Location $folder
try {
mvn package
mvn package --no-transfer-progress
if ($LASTEXITCODE -ne 0) {
throw "Failed to compile smoke test of $folder"
}
Expand Down
9 changes: 8 additions & 1 deletion packages/http-client-python/emitter/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { defineConfig, mergeConfig } from "vitest/config";
import { defaultTypeSpecVitestConfig } from "../../../vitest.config.js";

export default mergeConfig(defaultTypeSpecVitestConfig, defineConfig({}));
export default mergeConfig(
defaultTypeSpecVitestConfig,
defineConfig({
test: {
reporters: process.env.TF_BUILD ? ["default", "junit"] : undefined,
},
}),
);
3 changes: 3 additions & 0 deletions packages/http-client-python/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- Runs Check-GitChanges.ps1 (verify no uncommitted changes)
- Runs npm run ci (full test suite: pytest, lint, mypy, pyright)

Azure DevOps collects emitter JUnit results from test-results.xml and
pytest JUnit results from tests/test-results/*.xml.

.PARAMETER UnitTests
Run unit tests only (just builds the project).

Expand Down
6 changes: 3 additions & 3 deletions packages/http-client-python/tests/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ deps =
-e {tox_root}/../generator
commands =
python {tox_root}/install_packages.py azure {tox_root}
pytest mock_api/azure mock_api/shared -v -n auto {posargs}
pytest mock_api/azure mock_api/shared -v -n auto --junitxml={tox_root}/test-results/{envname}.xml {posargs}

[testenv:test-unbranded]
description = Run tests for unbranded flavor
Expand All @@ -47,7 +47,7 @@ deps =
-e {tox_root}/../generator
commands =
python {tox_root}/install_packages.py unbranded {tox_root}
pytest mock_api/unbranded mock_api/shared -v -n auto {posargs}
pytest mock_api/unbranded mock_api/shared -v -n auto --junitxml={tox_root}/test-results/{envname}.xml {posargs}

[testenv:unittest]
description = Run unit tests for pygen internals
Expand All @@ -57,7 +57,7 @@ deps =
-e {tox_root}/../generator
commands =
python {tox_root}/install_packages.py unbranded {tox_root}
pytest unit/ -v -n auto {posargs}
pytest unit/ -v -n auto --junitxml={tox_root}/test-results/{envname}.xml {posargs}

# =============================================================================
# Lint, type checking, and static analysis environments
Expand Down
Loading