Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration from cadl-ranch to spector #2977

Merged
merged 15 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 10 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,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-python"
---

Migrate cadl-ranch to spector
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
cadl-ranch/

# Translations
*.mo
Expand Down
4 changes: 0 additions & 4 deletions eng/pipelines/ci-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ steps:
displayName: Install TypeSpec
condition: and(succeeded(), ${{ parameters.installTypeSpec }})

- script: npm install -g @azure-tools/cadl-ranch
displayName: Install Cadl Ranch
condition: and(succeeded(), ${{ parameters.installCadlRanch }})

- script: npx @azure-tools/typespec-bump-deps package.json packages/typespec-python/package.json
displayName: Update typespec packages to latest dev version
workingDirectory: $(Build.SourcesDirectory)/autorest.python/
Expand Down
7 changes: 4 additions & 3 deletions eng/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@ jobs:
package: "typespec-python"
folderName: "unbranded"

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

- publish: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs/cadl-ranch-coverage.json
- publish: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs/spec-coverage.json
artifact: CoverageReport
continueOnError: true
12 changes: 6 additions & 6 deletions eng/pipelines/internal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ steps:
- task: AzureCLI@2
displayName: Upload scenario manifest for unbranded
inputs:
azureSubscription: "Cadl Ranch Storage"
azureSubscription: "TypeSpec Storage"
scriptType: "bash"
scriptLocation: "inlineScript"
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
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs
inlineScript: tsp-spector upload-coverage --generatorName "@typespec/http-client-python" --storageAccountName typespec --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@typspec/http-client-python/package.json').version") --containerName coverages --generatorMode standard
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs

- script: |
tox run -e ci
Expand All @@ -44,8 +44,8 @@ steps:
- task: AzureCLI@2
displayName: Upload scenario manifest for azure
inputs:
azureSubscription: "Cadl Ranch Storage"
azureSubscription: "TypeSpec Storage"
scriptType: "bash"
scriptLocation: "inlineScript"
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
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/cadl-ranch-specs
inlineScript: tsp-spector upload-coverage --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
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs
3 changes: 0 additions & 3 deletions eng/pipelines/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ extends:
- script: npm install -g [email protected]
displayName: Install PNPM 9.5.0

- script: npm install -g @azure-tools/cadl-ranch
displayName: Install cadl ranch

- script: pnpm install
displayName: Install dependencies

Expand Down
5 changes: 2 additions & 3 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@
"@azure-tools/typespec-azure-rulesets": "~0.49.0",
"@azure-tools/typespec-autorest": "~0.49.0",
"@azure-tools/typespec-client-generator-core": "~0.49.0",
"@azure-tools/cadl-ranch-expect": "~0.15.7",
"@azure-tools/cadl-ranch-specs": "~0.39.6",
"@azure-tools/cadl-ranch": "~0.16.2",
"@azure-tools/azure-http-specs": "0.1.0-alpha.4",
"@typespec/http-specs": "0.1.0-alpha.5",
"@types/js-yaml": "~4.0.5",
"@types/node": "~22.5.4",
"@types/yargs": "~17.0.33",
Expand Down
14 changes: 9 additions & 5 deletions packages/typespec-python/scripts/eng/regenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const exec = promisify(execCallback);

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

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

function defaultPackageName(spec: string): string {
return toPosix(relative(CADL_RANCH_DIR, dirname(spec)))
const specDir = spec.includes("azure") ? AZURE_HTTP_SPECS : HTTP_SPECS;
return toPosix(relative(specDir, dirname(spec)))
.replace(/\//g, "-")
.toLowerCase();
}
Expand Down Expand Up @@ -259,8 +262,9 @@ async function regenerate(flags: RegenerateFlagsInput): Promise<void> {
await regenerate({ ...flags, flavor: "unbranded" });
} else {
const flagsResolved = { debug: false, flavor: flags.flavor, ...flags };
const CADL_RANCH_DIR = resolve(PLUGIN_DIR, "node_modules/@azure-tools/cadl-ranch-specs/http");
const subdirectories = await getSubdirectories(CADL_RANCH_DIR, flagsResolved);
const subdirectories1 = await getSubdirectories(AZURE_HTTP_SPECS, flagsResolved);
const subdirectories2 = await getSubdirectories(HTTP_SPECS, flagsResolved);
tadelesh marked this conversation as resolved.
Show resolved Hide resolved
const subdirectories = [...subdirectories1, ...subdirectories2];
const cmdList: TspCommand[] = subdirectories.flatMap((subdirectory) =>
_getCmdList(subdirectory, flagsResolved),
);
Expand Down
Loading
Loading