Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Ingest test infrastructure changes in `@typespec/http-client-python`
3 changes: 3 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ words:
- npmjs
- odata
- overriden
- pkgs
- psscriptanalyzer
- ptvsd
- pylint
Expand Down Expand Up @@ -126,12 +127,14 @@ words:
- tikka
- toctree
- tspd
- unconfigure
- undoc
- venv
- venvtools
- wday
- westus
- windowsvmimage
- xdist
- xmsclientrequestid
- xmserrorresponse
- xmserrorresponseversiontolerant
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/ci-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ steps:

- script: node ../../../eng/scripts/check-for-changed-files.js
displayName: Fail on regeneration diff in Typespec
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/test
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/tests
condition: and(succeeded(), ${{ parameters.regenerate }}, ${{ parameters.checkChange }}, eq(variables['Agent.OS'], 'Linux'))

- script: node ../../../eng/scripts/check-for-changed-files.js
Expand Down
17 changes: 9 additions & 8 deletions eng/pipelines/generated-code-checks-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ parameters:
package: "autorest.python"

steps:
- script: npm run test -- --command=ci --folder=${{ parameters.folderName }}
- script: npm run test -- --env=ci --flavor=${{ parameters.folderName }}
displayName: Execute ${{ parameters.folderName }} tests - Python $(PythonVersion)
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.package}}

- script: npm run test -- --command=lint --folder=${{ parameters.folderName }}
displayName: Lint ${{ parameters.folderName }} - Python $(PythonVersion) --folder=${{ parameters.folderName }}
- script: npm run test -- --env=lint --flavor=${{ parameters.folderName }}
displayName: Lint ${{ parameters.folderName }} - Python $(PythonVersion)
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.package}}
condition: and(eq(variables['PythonVersion'], '3.9'), or(contains( '${{ parameters.folderName }}', 'version-tolerant'), eq('${{parameters.package}}', 'typespec-python')))
condition: and(eq(variables['PythonVersion'], '3.9'), or(contains('${{ parameters.folderName }}', 'version-tolerant'), eq('${{parameters.package}}', 'typespec-python')))

- script: npm run test -- --command=mypy --folder=${{ parameters.folderName }}
- script: npm run test -- --env=mypy --flavor=${{ parameters.folderName }}
displayName: Mypy ${{ parameters.folderName }} - Python $(PythonVersion)
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.package}}
condition: and(eq(variables['PythonVersion'], '3.11'), or(contains('${{ parameters.folderName }}', 'version-tolerant'), eq('${{parameters.package}}', 'typespec-python')))

- script: npm run test -- --command=pyright --folder=${{ parameters.folderName }}
- script: npm run test -- --env=pyright --flavor=${{ parameters.folderName }}
displayName: Pyright ${{ parameters.folderName }} - Python $(PythonVersion)
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.package}}
condition: and(eq(variables['PythonVersion'], '3.10'), or(contains('${{ parameters.folderName }}', 'version-tolerant'), eq('${{parameters.package}}', 'typespec-python')))

- script: npm run test -- --command=apiview --folder=${{ parameters.folderName }}
# docs/apiview only for typespec-python (removed from autorest.python to reduce CI time)
- script: npm run test -- --env=docs --flavor=${{ parameters.folderName }}
displayName: ApiView ${{ parameters.folderName }} - Python $(PythonVersion)
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.package}}
condition: eq(variables['PythonVersion'], '3.11')
condition: and(eq(variables['PythonVersion'], '3.11'), eq('${{parameters.package}}', 'typespec-python'))
8 changes: 4 additions & 4 deletions eng/pipelines/internal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ steps:
regenerate: true

- script: |
tox run -e ci
tox run -e ci-unbranded
displayName: Mock Api Tests for Unbranded
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/test/unbranded
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/tests

- task: AzureCLI@2
displayName: Upload scenario manifest for unbranded
Expand All @@ -37,9 +37,9 @@ steps:
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@typespec/http-specs

- script: |
tox run -e ci
tox run -e ci-azure
displayName: Mock Api Tests for Azure
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/test/azure
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/tests

- task: AzureCLI@2
displayName: Upload scenario manifest for azure
Expand Down
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNjA4ODMyMy9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.28.2.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNjEwOTY3My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.28.2.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "^4.21.0"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
55 changes: 28 additions & 27 deletions packages/autorest.python/scripts/eng/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { fileURLToPath } from "url";

interface Arguments {
validFolders: string[];
folder?: string;
command?: string;
flavor?: string;
env?: string;
name?: string;
}

const validCommands = ["ci", "lint", "mypy", "pyright", "apiview"];
// Note: apiview removed to reduce CI time - it was causing timeouts
const validEnvs = ["ci", "lint", "mypy", "pyright"];

// Parse command-line arguments using yargs
const argv = yargs(hideBin(process.argv))
Expand All @@ -23,15 +24,15 @@ const argv = yargs(hideBin(process.argv))
type: "array",
default: ["azure", "unbranded"],
})
.option("folder", {
alias: "f",
describe: "Specify the folder to use",
.option("flavor", {
alias: ["f", "folder"],
describe: "Specify the flavor/folder to use",
type: "string",
})
.option("command", {
alias: "c",
describe: "Specify the command to run",
choices: validCommands,
.option("env", {
alias: ["e", "command"],
describe: "Specify the environment/command to run",
choices: validEnvs,
type: "string",
})
.option("name", {
Expand All @@ -40,16 +41,16 @@ const argv = yargs(hideBin(process.argv))
type: "string",
}).argv as Arguments;

const foldersToProcess = argv.folder ? [argv.folder] : argv.validFolders;
const foldersToProcess = argv.flavor ? [argv.flavor] : argv.validFolders;

const commandToRun = argv.command || "all";
const envToRun = argv.env || "all";

function getCommand(command: string, folder: string, name?: string): string {
if (!validCommands.includes(command)) throw new Error(`Unknown command '${command}'.`);
function getCommand(env: string, folder: string, name?: string): string {
if (!validEnvs.includes(env)) throw new Error(`Unknown env '${env}'.`);

// Check if running on Windows
const isWindows = process.platform === "win32";
const baseCommand = `tox -c ./test/${folder}/tox.ini -e ${command}`;
const baseCommand = `tox -c ./test/${folder}/tox.ini -e ${env}`;

let retval: string;
if (isWindows) {
Expand All @@ -66,33 +67,33 @@ function getCommand(command: string, folder: string, name?: string): string {
return retval;
}

function sectionExistsInToxIni(command: string, folder: string): boolean {
function sectionExistsInToxIni(env: string, folder: string): boolean {
const toxIniPath = join(fileURLToPath(import.meta.url), `../../../test/${folder}/tox.ini`);
const toxIniContent = readFileSync(toxIniPath, "utf-8");
const sectionHeader = `[testenv:${command}]`;
const sectionHeader = `[testenv:${env}]`;
return toxIniContent.includes(sectionHeader);
}

function myExecSync(command: string, folder: string, name?: string): void {
if (!sectionExistsInToxIni(command, folder)) {
console.log(`No section for ${command} in tox.ini for folder ${folder}. Skipping...`);
function myExecSync(env: string, folder: string, name?: string): void {
if (!sectionExistsInToxIni(env, folder)) {
console.log(`No section for ${env} in tox.ini for folder ${folder}. Skipping...`);
return;
}
execSync(getCommand(command, folder, name), { stdio: "inherit" });
execSync(getCommand(env, folder, name), { stdio: "inherit" });
}

foldersToProcess.forEach((folder) => {
try {
if (commandToRun === "all") {
for (const key of validCommands) {
if (envToRun === "all") {
for (const key of validEnvs) {
console.log(`Running ${key} for folder ${folder}...`);
myExecSync(key, folder, argv.name);
}
} else if (getCommand(commandToRun, folder, argv.name)) {
console.log(`Running ${commandToRun} for folder ${folder}...`);
myExecSync(commandToRun, folder, argv.name);
} else if (getCommand(envToRun, folder, argv.name)) {
console.log(`Running ${envToRun} for folder ${folder}...`);
myExecSync(envToRun, folder, argv.name);
} else {
console.error(`Error: Unknown command '${commandToRun}'.`);
console.error(`Error: Unknown env '${envToRun}'.`);
process.exit(1);
}
} catch (error) {
Expand Down
3 changes: 0 additions & 3 deletions packages/typespec-python/.c8rc.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/typespec-python/.mocharc.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions packages/typespec-python/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trailingComma: "all"
printWidth: 120
quoteProps: "consistent"
endOfLine: lf
arrowParens: always
Loading
Loading