Skip to content

Commit

Permalink
http-client-java, eng, fix script for release pipeline (microsoft#5127)
Browse files Browse the repository at this point in the history
fix microsoft#5046

- Copy `cadl-ranch-coverage-java-standard.json` to the location that
will be uploaded by shared script
- Move cadl-ranch test to "UnitTests" block ("GenerationChecks" is the
diff on re-generated code -- it won't run in publish)
- Update publish.yml to disable NuGet, and enable release to "public"

Note that this coverage is actually not via unbranded. It is Azure.
We should be able to switch the cases to unbranded, when we got
clientcore lib on maven.
  • Loading branch information
weidongxu-microsoft authored Nov 21, 2024
1 parent 1cf8601 commit 5cfd1f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
4 changes: 2 additions & 2 deletions packages/http-client-java/eng/pipeline/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extends:
parameters:
BuildPrereleaseVersion: true
UseTypeSpecNext: false
Publish: "internal"
Publish: "public"
PublishDependsOnTest: true
PackagePath: /packages/http-client-java
EmitterPackageJsonPath: packages/http-client-java/emitter/package.json
Expand All @@ -28,5 +28,5 @@ extends:
UnitTestArgs: -UnitTests
StagePrefix: "Java"
LanguageShortName: "java"
HasNugetPackages: true
HasNugetPackages: false
CadlRanchName: "@typespec/http-client-java"
59 changes: 35 additions & 24 deletions packages/http-client-java/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,44 @@ Invoke-LoggedCommand "mvn -version"
Push-Location $packageRoot
try {
if ($UnitTests) {
Push-Location "$packageRoot"
try {
Write-Host "Current PATH: $env:PATH"
Write-Host "Current JAVA_HOME: $Env:JAVA_HOME"
$env:JAVA_HOME = $env:JAVA_HOME_21_X64
Write-Host "Updated JAVA_HOME: $Env:JAVA_HOME"
Write-Host "Current PATH: $env:PATH"
Write-Host "Current JAVA_HOME: $Env:JAVA_HOME"
$env:JAVA_HOME = $env:JAVA_HOME_21_X64
Write-Host "Updated JAVA_HOME: $Env:JAVA_HOME"

$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"

Write-Host "Updated PATH: $env:PATH"
# test the emitter
Invoke-LoggedCommand "npm run build" -GroupOutput

Write-Host "Updated PATH: $env:PATH"

# cadl-ranch tests (unit tests included in java/typescript package build)
try {
$generatorTestDir = Join-Path $packageRoot 'generator/http-client-generator-test'
Push-Location $generatorTestDir
try {
& ./Setup.ps1
& ./CadlRanch-Tests.ps1
Set-Location $packageRoot
Write-Host 'Cadl ranch tests passed'
}
finally {
Pop-Location
}
}
catch {
Write-Error "Cadl ranch tests failed: $_"
}
finally {
Pop-Location
# copy coverage report to artifacts dir
try {
$coverageReportDir = Join-Path $packageRoot 'generator/artifacts/coverage'
if (!(Test-Path $coverageReportDir)) {
New-Item -ItemType Directory -Path $coverageReportDir

$sourceFile = Join-Path $packageRoot 'generator/http-client-generator-test/cadl-ranch-coverage-java-standard.json'
$targetFile = Join-Path $coverageReportDir 'cadl-ranch-coverage-java-standard.json'
Copy-Item $sourceFile -Destination $targetFile
}
} catch {
Write-Error "Failed to copy coverage report file: $_"
}
}
if ($GenerationChecks) {
Expand All @@ -53,17 +75,6 @@ try {
catch {
Write-Error 'Generated code is not up to date. Please run: eng/Generate.ps1'
}

try {
$generatorTestDir = Join-Path $packageRoot 'generator/http-client-generator-test'
Set-Location $generatorTestDir
& ./CadlRanch-Tests.ps1
Set-Location $packageRoot
Write-Host 'Cadl ranch tests passed'
}
catch {
Write-Error "Cadl ranch tests failed: $_"
}
}
}
finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"format": "npm run -s prettier -- --write",
"check-format": "npm run prettier -- --check",
"prettier": "prettier --config ./.prettierrc.yaml **/*.tsp",
"testserver-run": "npx cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java.json",
"testserver-start": "npx cadl-ranch server start ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java.json",
"testserver-stop": "npx cadl-ranch server stop"
"testserver-run": "cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java-standard.json",
"testserver-start": "cadl-ranch server start ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java-standard.json",
"testserver-stop": "cadl-ranch server stop"
},
"dependencies": {
"@azure-tools/cadl-ranch-specs": "0.39.0",
Expand Down

0 comments on commit 5cfd1f7

Please sign in to comment.