Skip to content

Commit 720f248

Browse files
msyyctadelesh
andauthored
migration from cadl-ranch to spector (#2977)
* update cadl-ranch to spector * update ignore * Update dependencies (2024-12-18 06:19:16) * Regenerate for typespec-python (2024-12-18 06:23:49) * fix ci * Fix ci * review * update package.json * add changelog * fix sub name in ci * Rename subdirectory variables for clarity * update internal-ci with specific coverage file name * update internal-ci for spector coverage upload * fix ci --------- Co-authored-by: AutoPrFromHttpClientPython <AutoPrFromHttpClientPython> Co-authored-by: Chenjie Shi <tadelesh.shi@live.cn>
1 parent 156bf9b commit 720f248

File tree

123 files changed

+11149
-1179
lines changed

Some content is hidden

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

123 files changed

+11149
-1179
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@azure-tools/typespec-python"
5+
---
6+
7+
Migrate cadl-ranch to spector

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ coverage.xml
5151
*.cover
5252
.hypothesis/
5353
.pytest_cache/
54-
cadl-ranch/
5554

5655
# Translations
5756
*.mo

eng/pipelines/ci-template.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ steps:
3636
displayName: Install TypeSpec
3737
condition: and(succeeded(), ${{ parameters.installTypeSpec }})
3838

39-
- script: npm install -g @azure-tools/cadl-ranch
40-
displayName: Install Cadl Ranch
41-
condition: and(succeeded(), ${{ parameters.installCadlRanch }})
42-
4339
- script: npx @azure-tools/typespec-bump-deps package.json packages/typespec-python/package.json
4440
displayName: Update typespec packages to latest dev version
4541
workingDirectory: $(Build.SourcesDirectory)/autorest.python/

eng/pipelines/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,11 @@ jobs:
184184
package: "typespec-python"
185185
folderName: "unbranded"
186186

187-
- script: cadl-ranch check-coverage http/
187+
- script: tsp-spector check-coverage http/
188188
displayName: Check Coverage
189-
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs
189+
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs
190190
continueOnError: true
191191

192-
- publish: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs/cadl-ranch-coverage.json
192+
- publish: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs/spec-coverage.json
193193
artifact: CoverageReport
194+
continueOnError: true

eng/pipelines/internal-ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ steps:
3030
- task: AzureCLI@2
3131
displayName: Upload scenario manifest for unbranded
3232
inputs:
33-
azureSubscription: "Cadl Ranch Storage"
33+
azureSubscription: "TypeSpec Storage"
3434
scriptType: "bash"
3535
scriptLocation: "inlineScript"
36-
inlineScript: cadl-ranch upload-coverage --generatorName python --storageAccountName azuresdkcadlranch --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/package.json').version") --generatorMode standard
37-
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs
36+
inlineScript: npx tsp-spector upload-coverage --coverageFile ./spec-coverage.json --generatorName "@typespec/http-client-python" --storageAccountName typespec --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@typespec/http-client-python/package.json').version") --containerName coverages --generatorMode standard
37+
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs
3838

3939
- script: |
4040
tox run -e ci
@@ -44,8 +44,8 @@ steps:
4444
- task: AzureCLI@2
4545
displayName: Upload scenario manifest for azure
4646
inputs:
47-
azureSubscription: "Cadl Ranch Storage"
47+
azureSubscription: "TypeSpec Storage"
4848
scriptType: "bash"
4949
scriptLocation: "inlineScript"
50-
inlineScript: cadl-ranch upload-coverage --generatorName python --storageAccountName azuresdkcadlranch --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/package.json').version") --generatorMode azure
51-
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs
50+
inlineScript: npx tsp-spector upload-coverage --coverageFile ./spec-coverage.json --generatorName "@azure-tools/typespec-python" --storageAccountName typespec --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/package.json').version") --containerName coverages --generatorMode azure
51+
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs

eng/pipelines/publish-release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ extends:
3131
- script: npm install -g pnpm@9.5.0
3232
displayName: Install PNPM 9.5.0
3333

34-
- script: npm install -g @azure-tools/cadl-ranch
35-
displayName: Install cadl ranch
36-
3734
- script: pnpm install
3835
displayName: Install dependencies
3936

packages/typespec-python/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@
7474
"@azure-tools/typespec-azure-rulesets": "~0.49.0",
7575
"@azure-tools/typespec-autorest": "~0.49.0",
7676
"@azure-tools/typespec-client-generator-core": "~0.49.0",
77-
"@azure-tools/cadl-ranch-expect": "~0.15.7",
78-
"@azure-tools/cadl-ranch-specs": "~0.39.6",
79-
"@azure-tools/cadl-ranch": "~0.16.2",
77+
"@azure-tools/azure-http-specs": "0.1.0-alpha.4",
78+
"@typespec/http-specs": "0.1.0-alpha.5",
8079
"@types/js-yaml": "~4.0.5",
8180
"@types/node": "~22.5.4",
8281
"@types/yargs": "~17.0.33",

packages/typespec-python/scripts/eng/regenerate.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const exec = promisify(execCallback);
1212

1313
// Get the directory of the current file
1414
const PLUGIN_DIR = resolve(fileURLToPath(import.meta.url), "../../../");
15-
const CADL_RANCH_DIR = resolve(PLUGIN_DIR, "node_modules/@azure-tools/cadl-ranch-specs/http");
15+
const AZURE_HTTP_SPECS = resolve(PLUGIN_DIR, "node_modules/@azure-tools/azure-http-specs/specs");
16+
const HTTP_SPECS = resolve(PLUGIN_DIR, "node_modules/@typespec/http-specs/specs");
1617
interface TspCommand {
1718
outputDir: string;
1819
command: string;
@@ -111,7 +112,8 @@ function toPosix(dir: string): string {
111112
}
112113

113114
function getEmitterOption(spec: string): Record<string, string>[] {
114-
const relativeSpec = toPosix(relative(CADL_RANCH_DIR, spec));
115+
const specDir = spec.includes("azure") ? AZURE_HTTP_SPECS : HTTP_SPECS;
116+
const relativeSpec = toPosix(relative(specDir, spec));
115117
const key = relativeSpec.includes("resiliency/srv-driven/old.tsp") ? relativeSpec : dirname(relativeSpec);
116118
const result = EMITTER_OPTIONS[key] || [{}];
117119
return Array.isArray(result) ? result : [result];
@@ -205,7 +207,8 @@ async function getSubdirectories(baseDir: string, flags: RegenerateFlags): Promi
205207
}
206208

207209
function defaultPackageName(spec: string): string {
208-
return toPosix(relative(CADL_RANCH_DIR, dirname(spec)))
210+
const specDir = spec.includes("azure") ? AZURE_HTTP_SPECS : HTTP_SPECS;
211+
return toPosix(relative(specDir, dirname(spec)))
209212
.replace(/\//g, "-")
210213
.toLowerCase();
211214
}
@@ -259,8 +262,9 @@ async function regenerate(flags: RegenerateFlagsInput): Promise<void> {
259262
await regenerate({ ...flags, flavor: "unbranded" });
260263
} else {
261264
const flagsResolved = { debug: false, flavor: flags.flavor, ...flags };
262-
const CADL_RANCH_DIR = resolve(PLUGIN_DIR, "node_modules/@azure-tools/cadl-ranch-specs/http");
263-
const subdirectories = await getSubdirectories(CADL_RANCH_DIR, flagsResolved);
265+
const subdirectoriesForAzure = await getSubdirectories(AZURE_HTTP_SPECS, flagsResolved);
266+
const subdirectoriesForNonAzure = await getSubdirectories(HTTP_SPECS, flagsResolved);
267+
const subdirectories = [...subdirectoriesForAzure, ...subdirectoriesForNonAzure];
264268
const cmdList: TspCommand[] = subdirectories.flatMap((subdirectory) =>
265269
_getCmdList(subdirectory, flagsResolved),
266270
);

0 commit comments

Comments
 (0)