From 5cfd1f7e6f9d0d971874c774cdc81793da91ce5d Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 21 Nov 2024 10:48:43 +0800 Subject: [PATCH] http-client-java, eng, fix script for release pipeline (#5127) fix https://github.com/microsoft/typespec/issues/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. --- .../http-client-java/eng/pipeline/publish.yml | 4 +- .../eng/scripts/Test-Packages.ps1 | 59 +++++++++++-------- .../http-client-generator-test/package.json | 6 +- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/packages/http-client-java/eng/pipeline/publish.yml b/packages/http-client-java/eng/pipeline/publish.yml index 3c4b652895..ef49a193bb 100644 --- a/packages/http-client-java/eng/pipeline/publish.yml +++ b/packages/http-client-java/eng/pipeline/publish.yml @@ -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 @@ -28,5 +28,5 @@ extends: UnitTestArgs: -UnitTests StagePrefix: "Java" LanguageShortName: "java" - HasNugetPackages: true + HasNugetPackages: false CadlRanchName: "@typespec/http-client-java" diff --git a/packages/http-client-java/eng/scripts/Test-Packages.ps1 b/packages/http-client-java/eng/scripts/Test-Packages.ps1 index f9dd7ac5fe..157fcde780 100644 --- a/packages/http-client-java/eng/scripts/Test-Packages.ps1 +++ b/packages/http-client-java/eng/scripts/Test-Packages.ps1 @@ -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) { @@ -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 { diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index b0c748b999..b7793eb89a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -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",