Skip to content

Commit 8b1147b

Browse files
eng, migrate to tsp-spector (#2998)
1 parent 16bda4a commit 8b1147b

File tree

71 files changed

+4682
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4682
-525
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ javagen/*.yaml
8484
# vanilla
8585
/azure-dataplane-tests/src/main/java/module-info.java
8686

87-
# Cadl output
87+
# tsp-spector output
8888
/typespec-tests/tsp-output/
89-
/typespec-tests/cadl-ranch-coverage.json
90-
/typespec-tests/cadl-ranch-coverage-java.json
89+
/typespec-tests/tsp-spector-coverage.json
90+
/typespec-tests/tsp-spector-coverage-java.json
9191
/typespec-tests/tsp-src/
9292

9393
# Coverage report

core

Submodule core updated 340 files

eng/pipelines/ci-typespec-java-dev-nightly.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
# displayName: 'Check no Diff'
8888

8989
- script: |
90-
node node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js serve node_modules/\@azure-tools/cadl-ranch-specs/http/ --coverageFile ./cadl-ranch-coverage-java.json &
91-
displayName: 'Start Cadl Ranch Test Server'
90+
npx --no-install tsp-spector server start ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java.json
91+
displayName: 'Start Spector Test Server'
9292
workingDirectory: ./typespec-tests
9393
9494
- task: Maven@3
@@ -104,8 +104,8 @@ jobs:
104104
publishJUnitResults: false
105105

106106
- script: |
107-
node node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js server stop
108-
displayName: 'Stop Cadl Ranch Test Server'
107+
npx --no-install tsp-spector server stop
108+
displayName: 'Stop Spector Test Server'
109109
workingDirectory: ./typespec-tests
110110
111111
- template: /eng/pipelines/steps/cleanup-maven-local-cache.yml

eng/pipelines/ci-typespec-java.yaml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ jobs:
7979
publishJUnitResults: false
8080

8181
- script: |
82-
node node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js serve node_modules/\@azure-tools/cadl-ranch-specs/http/ --coverageFile ./cadl-ranch-coverage-java.json &
83-
displayName: 'Start Cadl Ranch Test Server'
82+
npx --no-install tsp-spector server start ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java.json
83+
displayName: 'Start Spector Test Server'
8484
workingDirectory: ./typespec-tests
8585
8686
- task: Maven@3
@@ -96,27 +96,22 @@ jobs:
9696
publishJUnitResults: false
9797

9898
- script: |
99-
node node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js server stop
100-
displayName: 'Stop Cadl Ranch Test Server'
99+
npx --no-install tsp-spector server stop
100+
displayName: 'Stop Spector Test Server'
101101
workingDirectory: ./typespec-tests
102102
103-
- script: |
104-
node node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js check-coverage node_modules/@azure-tools/cadl-ranch-specs/http --coverageFiles ./cadl-ranch-coverage-java.json
105-
displayName: 'Cadl Ranch Coverage Report'
106-
workingDirectory: ./typespec-tests
107-
continueOnError: true
108-
109-
- publish: $(Build.SourcesDirectory)/typespec-tests/cadl-ranch-coverage-java.json
103+
- publish: $(Build.SourcesDirectory)/typespec-tests/tsp-spector-coverage-java.json
110104
artifact: CoverageReport
111-
displayName: 'Publish Cadl Ranch Coverage Report'
105+
displayName: 'Publish Spector Coverage Report'
112106

113107
- task: AzureCLI@2
114-
displayName: 'Upload to Cadl Ranch Coverage Report Dashboard'
108+
displayName: 'Upload to Spector Coverage Report Dashboard'
115109
condition: eq(variables.isMain, 'true')
116110
inputs:
117-
azureSubscription: "Cadl Ranch Storage"
111+
azureSubscription: "TypeSpec Storage"
118112
scriptType: "bash"
119113
scriptLocation: "inlineScript"
120-
inlineScript: node $(Build.SourcesDirectory)/typespec-tests/node_modules/\@azure-tools/cadl-ranch/dist/cli/cli.js upload-coverage --coverageFile $(Build.SourcesDirectory)/typespec-tests/cadl-ranch-coverage-java.json --generatorName java --storageAccountName azuresdkcadlranch --generatorMode azure --generatorVersion $(node -p -e "require('./typespec-extension/package.json').version")
114+
inlineScript: npx --no-install tsp-spector upload-coverage --coverageFile ./tsp-spector-coverage-java.json --generatorName "@azure-tools/typespec-java" --storageAccountName typespec --containerName coverages --generatorMode azure --generatorVersion $(node -p -e "require('../typespec-extension/package.json').version")
115+
workingDirectory: ./typespec-tests
121116

122117
- template: /eng/pipelines/steps/cleanup-maven-local-cache.yml

package-lock.json

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typespec-tests/Generate.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ $generateScript = {
9090
}
9191

9292
$tspTrace = "--trace import-resolution --trace projection --trace typespec-java"
93-
$tspCommand = "npx tsp compile $tspFile $tspOptions $tspTrace"
93+
$tspCommand = "npx --no-install tsp compile $tspFile $tspOptions $tspTrace"
9494

9595
$timer = [Diagnostics.Stopwatch]::StartNew()
9696
$generateOutput = Invoke-Expression $tspCommand
@@ -136,28 +136,29 @@ if (Test-Path ./tsp-output) {
136136
Remove-Item ./tsp-output -Recurse -Force
137137
}
138138

139-
# run other local tests except partial update
139+
# generate for other local test sources except partial update
140140
$job = Get-Item ./tsp/* -Filter "*.tsp" -Exclude "*partialupdate*" | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob
141141

142142
$job | Wait-Job -Timeout 600
143143
$job | Receive-Job
144144

145145
# partial update test
146-
npx tsp compile ./tsp/partialupdate.tsp --option="@azure-tools/typespec-java.emitter-output-dir={project-root}/existingcode"
146+
npx --no-install tsp compile ./tsp/partialupdate.tsp --option="@azure-tools/typespec-java.emitter-output-dir={project-root}/existingcode"
147147
Copy-Item -Path ./existingcode/src/main/java/tsptest/partialupdate -Destination ./src/main/java/tsptest/partialupdate -Recurse -Force
148148
Remove-Item ./existingcode -Recurse -Force
149149

150-
# run cadl ranch tests sources
151-
Copy-Item -Path node_modules/@azure-tools/cadl-ranch-specs/http -Destination ./ -Recurse -Force
150+
# generate for http-specs/azure-http-specs test sources
151+
Copy-Item -Path node_modules/@typespec/http-specs/specs -Destination ./ -Recurse -Force
152+
Copy-Item -Path node_modules/@azure-tools/azure-http-specs/specs -Destination ./ -Recurse -Force
152153
# remove xml tests, emitter has not supported xml model
153-
Remove-Item ./http/payload/xml -Recurse -Force
154+
Remove-Item ./specs/payload/xml -Recurse -Force
154155

155-
$job = (Get-ChildItem ./http -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob
156+
$job = (Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob
156157

157158
$job | Wait-Job -Timeout 1200
158159
$job | Receive-Job
159160

160-
Remove-Item ./http -Recurse -Force
161+
Remove-Item ./specs -Recurse -Force
161162

162163
Copy-Item -Path ./tsp-output/*/src -Destination ./ -Recurse -Force -Exclude @("ReadmeSamples.java", "module-info.java")
163164

typespec-tests/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"format": "npm run -s prettier -- --write",
77
"check-format": "npm run prettier -- --check",
88
"prettier": "prettier --config ./.prettierrc.yaml **/*.tsp",
9-
"testserver-run": "npx cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java.json"
9+
"spector-serve": "tsp-spector serve ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java.json"
1010
},
1111
"dependencies": {
12-
"@azure-tools/cadl-ranch-specs": "0.39.5",
12+
"@typespec/http-specs": "0.1.0-alpha.5",
13+
"@azure-tools/azure-http-specs": "0.1.0-alpha.4",
1314
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.27.0.tgz"
1415
},
1516
"devDependencies": {

typespec-tests/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@
105105
</excludePackageNames>
106106
<sourceFileExcludes>
107107
<sourceFileExclude>module-info.java</sourceFileExclude>
108-
<!-- Java 11 seems having a bug on line starting with @, in @code tag -->
109-
<sourceFileExclude>com/cadl/naming/NamingAsyncClient.java</sourceFileExclude>
110108
</sourceFileExcludes>
111109
<failOnError>true</failOnError>
112110
<failOnWarnings>true</failOnWarnings>

typespec-tests/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ The existing code is already in sync. Run this if you have changed the code of T
2424

2525
## Run Test
2626

27-
Start Cadl-Ranch
27+
Start tsp-spector Test Server
2828

29-
`npm run testserver-run`
29+
`npm run spector-serve`
3030

3131
Then, run the tests in `typespec-tests` module as usual Java Tests.
3232

typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationAsyncClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Mono<Response<BinaryData>> operationWithResponse(String name, RequestOptions req
8080
}
8181

8282
/**
83-
* Expected query parameter: kind= "real"
83+
* Expected query parameter: kind="real"
8484
* Expected response body:
8585
* ```json
8686
* {
@@ -147,7 +147,7 @@ Mono<OuterModel> operation(String name) {
147147
}
148148

149149
/**
150-
* Expected query parameter: kind= "real"
150+
* Expected query parameter: kind="real"
151151
* Expected response body:
152152
* ```json
153153
* {

0 commit comments

Comments
 (0)