diff --git a/.chronus/changes/azsdk-pool-2025-5-25-15-4-16.md b/.chronus/changes/azsdk-pool-2025-5-25-15-4-16.md new file mode 100644 index 00000000000..d3ca5afbf36 --- /dev/null +++ b/.chronus/changes/azsdk-pool-2025-5-25-15-4-16.md @@ -0,0 +1,8 @@ +--- +changeKind: internal +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Fix CI to use windows \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 2a0e8466c2c..9ccb537a987 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,10 @@ -# These files are text and should be normalized (convert crlf => lf) -*.cs text diff=csharp -*.py text -*.json text -*.md text -*.iced text -*.csproj text +# Default: auto-detect text files and force LF line endings +* text=auto eol=lf -# Use unix line endings always, even on Windows -* text=auto eol=lf +# Specific text files (these will inherit eol=lf from above) +*.cs text diff=csharp +*.py text +*.json text +*.md text +*.iced text +*.csproj text diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml index 7f0c51d2673..ac742c62743 100644 --- a/.github/policies/resourceManagement.yml +++ b/.github/policies/resourceManagement.yml @@ -1,378 +1,378 @@ -id: -name: GitOps.PullRequestIssueManagement -description: GitOps.PullRequestIssueManagement primitive -owner: -resource: repository -disabled: false -where: -configuration: - resourceManagementConfiguration: - scheduledSearches: - - description: - frequencies: - - daily: - time: 1:0 - filters: - - isIssue - - isOpen - - hasLabel: - label: needs-author feedback - - hasLabel: - label: no-recent-activity - - noActivitySince: - days: 14 - actions: - - closeIssue - - description: - frequencies: - - hourly: - hour: 6 - filters: - - isIssue - - isOpen - - hasLabel: - label: needs-author feedback - - noActivitySince: - days: 7 - - isNotLabeledWith: - label: no-recent-activity - actions: - - addLabel: - label: no-recent-activity - - addReply: - reply: Hi, we're sending this friendly reminder because we haven't heard back from you in **7 days**. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within **14 days** of this comment the issue will be automatically closed. Thank you! - - description: - frequencies: - - hourly: - hour: 6 - filters: - - isIssue - - isOpen - - hasLabel: - label: issue-addressed - - noActivitySince: - days: 7 - actions: - - addReply: - reply: Hi @${issueAuthor}, since you haven’t asked that we “`/unresolve`” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “`/unresolve`” to reopen the issue. - - closeIssue - - description: - frequencies: - - hourly: - hour: 6 - filters: - - isOpen - - hasLabel: - label: no-recent-activity - - isPullRequest - - noActivitySince: - days: 7 - actions: - - closeIssue - - addReply: - reply: "Hi @${issueAuthor}. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing \"/reopen\" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the \"no-recent-activity\" label; otherwise, this is likely to be closed again with the next cleanup pass. " - - description: - frequencies: - - weekday: - day: Friday - time: 5:0 - filters: - - isOpen - - isNotLabeledWith: - label: no-recent-activity - - noActivitySince: - days: 60 - - isPullRequest - actions: - - addLabel: - label: no-recent-activity - - addReply: - reply: Hi @${issueAuthor}. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. - eventResponderTasks: - - if: - - payloadType: Issue_Comment - - isAction: - action: Created - - isActivitySender: - issueAuthor: True - - hasLabel: - label: needs-author feedback - - isOpen - then: - - addLabel: - label: needs-team attention - - removeLabel: - label: needs-author feedback - description: - - if: - - payloadType: Issues - - not: - isAction: - action: Closed - - hasLabel: - label: no-recent-activity - then: - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Issue_Comment - - hasLabel: - label: no-recent-activity - then: - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Issues - - isAction: - action: Opened - - and: - - not: - activitySenderHasPermission: - permission: Write - - not: - activitySenderHasAssociation: - association: Member - - not: - activitySenderHasAssociation: - association: Collaborator - - not: - activitySenderHasPermission: - permission: Admin - then: - - addLabel: - label: customer-reported - - addLabel: - label: question - description: - - if: - - payloadType: Issues - - isAction: - action: Labeled - - labelAdded: - label: needs-author feedback - then: - - removeLabel: - label: needs-team attention - - removeLabel: - label: triage - - removeLabel: - label: needs-team triage - description: - - if: - - payloadType: Pull_Request - - isAction: - action: Opened - - and: - - not: - activitySenderHasPermission: - permission: Write - - not: - activitySenderHasAssociation: - association: Member - - not: - activitySenderHasAssociation: - association: Collaborator - - not: - activitySenderHasPermission: - permission: Admin - then: - - addLabel: - label: customer-reported - - addReply: - reply: Thank you for your contribution @${issueAuthor}! We will review the pull request and get back to you soon. - - addLabel: - label: community contribution - description: - - if: - - payloadType: Issues - - isAction: - action: Labeled - - not: - hasLabel: - label: needs-triage - - not: - hasLabel: - label: needs-team-triage - - not: - hasLabel: - label: needs-author-feedback - - hasLabel: - label: customer-reported - - not: - isInMilestone: - milestone: '' - - isOpen - - not: - hasLabel: - label: issue-addressed - then: - - addLabel: - label: needs-team-attention - description: - - if: - - payloadType: Pull_Request - - isOpen - - hasLabel: - label: auto-merge - - isAction: - action: Synchronize - - and: - - not: - activitySenderHasPermission: - permission: Admin - - not: - activitySenderHasPermission: - permission: Write - then: - - dismissPullRequestReview: - message: Hi @{issueAuthor}. We've noticed that new changes have been pushed to this pull request. Because it is set to automatically merge, we've reset the approvals to allow the opportunity to review the updates. - description: - - if: - - payloadType: Issues - - labelAdded: - label: issue-addressed - then: - - addReply: - reply: Hi @${issueAuthor}. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “`/unresolve`” to remove the “issue-addressed” label and continue the conversation. - - removeLabel: - label: needs-triage - - removeLabel: - label: needs-team-triage - - removeLabel: - label: needs-team-attention - - removeLabel: - label: needs-author-feedback - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Issue_Comment - - hasLabel: - label: issue-addressed - - commentContains: - pattern: /unresolve - isRegex: False - - or: - - isActivitySender: - issueAuthor: True - - activitySenderHasPermission: - permission: Admin - - activitySenderHasPermission: - permission: Write - then: - - reopenIssue - - removeLabel: - label: issue-addressed - - addLabel: - label: needs-team-attention - description: - - if: - - payloadType: Issue_Comment - - hasLabel: - label: issue-addressed - - commentContains: - pattern: /unresolve - isRegex: False - - and: - - not: - isActivitySender: - issueAuthor: True - - not: - activitySenderHasPermission: - permission: Admin - - not: - activitySenderHasPermission: - permission: Write - then: - - addReply: - reply: Hi ${contextualAuthor}, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team. - description: - - if: - - payloadType: Issues - - isOpen - - hasLabel: - label: issue-addressed - - or: - - labelAdded: - label: needs-team-attention - - labelAdded: - label: needs-author-feedback - - labelAdded: - label: Service Attention - - labelAdded: - label: needs-triage - - labelAdded: - label: needs-team-triage - then: - - removeLabel: - label: issue-addressed - description: - - if: - - payloadType: Pull_Request - - hasLabel: - label: no-recent-activity - - isOpen - - or: - - isAction: - action: Null - - isAction: - action: Synchronize - - isAction: - action: Null - then: - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Pull_Request_Review - - hasLabel: - label: no-recent-activity - - isOpen - then: - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Issue_Comment - - isAction: - action: Created - - hasLabel: - label: no-recent-activity - - isOpen - - and: - - not: - commentContains: - pattern: What is Check Enforcer? - isRegex: False - - not: - commentContains: - pattern: Since there hasn't been recent engagement, this is being closed out. - isRegex: False - then: - - removeLabel: - label: no-recent-activity - description: - - if: - - payloadType: Issue_Comment - - not: isOpen - - commentContains: - pattern: /reopen - isRegex: False - - hasLabel: - label: no-recent-activity - - or: - - isActivitySender: - issueAuthor: True - - activitySenderHasPermission: - permission: Admin - - activitySenderHasPermission: - permission: Write - then: - - reopenIssue - - removeLabel: - label: no-recent-activity - description: -onFailure: -onSuccess: +id: +name: GitOps.PullRequestIssueManagement +description: GitOps.PullRequestIssueManagement primitive +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: + frequencies: + - daily: + time: 1:0 + filters: + - isIssue + - isOpen + - hasLabel: + label: needs-author feedback + - hasLabel: + label: no-recent-activity + - noActivitySince: + days: 14 + actions: + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: needs-author feedback + - noActivitySince: + days: 7 + - isNotLabeledWith: + label: no-recent-activity + actions: + - addLabel: + label: no-recent-activity + - addReply: + reply: Hi, we're sending this friendly reminder because we haven't heard back from you in **7 days**. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within **14 days** of this comment the issue will be automatically closed. Thank you! + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: issue-addressed + - noActivitySince: + days: 7 + actions: + - addReply: + reply: Hi @${issueAuthor}, since you haven’t asked that we “`/unresolve`” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “`/unresolve`” to reopen the issue. + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: no-recent-activity + - isPullRequest + - noActivitySince: + days: 7 + actions: + - closeIssue + - addReply: + reply: "Hi @${issueAuthor}. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing \"/reopen\" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the \"no-recent-activity\" label; otherwise, this is likely to be closed again with the next cleanup pass. " + - description: + frequencies: + - weekday: + day: Friday + time: 5:0 + filters: + - isOpen + - isNotLabeledWith: + label: no-recent-activity + - noActivitySince: + days: 60 + - isPullRequest + actions: + - addLabel: + label: no-recent-activity + - addReply: + reply: Hi @${issueAuthor}. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. + eventResponderTasks: + - if: + - payloadType: Issue_Comment + - isAction: + action: Created + - isActivitySender: + issueAuthor: True + - hasLabel: + label: needs-author feedback + - isOpen + then: + - addLabel: + label: needs-team attention + - removeLabel: + label: needs-author feedback + description: + - if: + - payloadType: Issues + - not: + isAction: + action: Closed + - hasLabel: + label: no-recent-activity + then: + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Issue_Comment + - hasLabel: + label: no-recent-activity + then: + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Issues + - isAction: + action: Opened + - and: + - not: + activitySenderHasPermission: + permission: Write + - not: + activitySenderHasAssociation: + association: Member + - not: + activitySenderHasAssociation: + association: Collaborator + - not: + activitySenderHasPermission: + permission: Admin + then: + - addLabel: + label: customer-reported + - addLabel: + label: question + description: + - if: + - payloadType: Issues + - isAction: + action: Labeled + - labelAdded: + label: needs-author feedback + then: + - removeLabel: + label: needs-team attention + - removeLabel: + label: triage + - removeLabel: + label: needs-team triage + description: + - if: + - payloadType: Pull_Request + - isAction: + action: Opened + - and: + - not: + activitySenderHasPermission: + permission: Write + - not: + activitySenderHasAssociation: + association: Member + - not: + activitySenderHasAssociation: + association: Collaborator + - not: + activitySenderHasPermission: + permission: Admin + then: + - addLabel: + label: customer-reported + - addReply: + reply: Thank you for your contribution @${issueAuthor}! We will review the pull request and get back to you soon. + - addLabel: + label: community contribution + description: + - if: + - payloadType: Issues + - isAction: + action: Labeled + - not: + hasLabel: + label: needs-triage + - not: + hasLabel: + label: needs-team-triage + - not: + hasLabel: + label: needs-author-feedback + - hasLabel: + label: customer-reported + - not: + isInMilestone: + milestone: '' + - isOpen + - not: + hasLabel: + label: issue-addressed + then: + - addLabel: + label: needs-team-attention + description: + - if: + - payloadType: Pull_Request + - isOpen + - hasLabel: + label: auto-merge + - isAction: + action: Synchronize + - and: + - not: + activitySenderHasPermission: + permission: Admin + - not: + activitySenderHasPermission: + permission: Write + then: + - dismissPullRequestReview: + message: Hi @{issueAuthor}. We've noticed that new changes have been pushed to this pull request. Because it is set to automatically merge, we've reset the approvals to allow the opportunity to review the updates. + description: + - if: + - payloadType: Issues + - labelAdded: + label: issue-addressed + then: + - addReply: + reply: Hi @${issueAuthor}. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “`/unresolve`” to remove the “issue-addressed” label and continue the conversation. + - removeLabel: + label: needs-triage + - removeLabel: + label: needs-team-triage + - removeLabel: + label: needs-team-attention + - removeLabel: + label: needs-author-feedback + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Issue_Comment + - hasLabel: + label: issue-addressed + - commentContains: + pattern: /unresolve + isRegex: False + - or: + - isActivitySender: + issueAuthor: True + - activitySenderHasPermission: + permission: Admin + - activitySenderHasPermission: + permission: Write + then: + - reopenIssue + - removeLabel: + label: issue-addressed + - addLabel: + label: needs-team-attention + description: + - if: + - payloadType: Issue_Comment + - hasLabel: + label: issue-addressed + - commentContains: + pattern: /unresolve + isRegex: False + - and: + - not: + isActivitySender: + issueAuthor: True + - not: + activitySenderHasPermission: + permission: Admin + - not: + activitySenderHasPermission: + permission: Write + then: + - addReply: + reply: Hi ${contextualAuthor}, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team. + description: + - if: + - payloadType: Issues + - isOpen + - hasLabel: + label: issue-addressed + - or: + - labelAdded: + label: needs-team-attention + - labelAdded: + label: needs-author-feedback + - labelAdded: + label: Service Attention + - labelAdded: + label: needs-triage + - labelAdded: + label: needs-team-triage + then: + - removeLabel: + label: issue-addressed + description: + - if: + - payloadType: Pull_Request + - hasLabel: + label: no-recent-activity + - isOpen + - or: + - isAction: + action: Null + - isAction: + action: Synchronize + - isAction: + action: Null + then: + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Pull_Request_Review + - hasLabel: + label: no-recent-activity + - isOpen + then: + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Issue_Comment + - isAction: + action: Created + - hasLabel: + label: no-recent-activity + - isOpen + - and: + - not: + commentContains: + pattern: What is Check Enforcer? + isRegex: False + - not: + commentContains: + pattern: Since there hasn't been recent engagement, this is being closed out. + isRegex: False + then: + - removeLabel: + label: no-recent-activity + description: + - if: + - payloadType: Issue_Comment + - not: isOpen + - commentContains: + pattern: /reopen + isRegex: False + - hasLabel: + label: no-recent-activity + - or: + - isActivitySender: + issueAuthor: True + - activitySenderHasPermission: + permission: Admin + - activitySenderHasPermission: + permission: Write + then: + - reopenIssue + - removeLabel: + label: no-recent-activity + description: +onFailure: +onSuccess: diff --git a/eng/pipelines/ci-template.yml b/eng/pipelines/ci-template.yml index f27da67075f..f474bfc6d36 100644 --- a/eng/pipelines/ci-template.yml +++ b/eng/pipelines/ci-template.yml @@ -1,147 +1,147 @@ parameters: - installAutorest: false - installTypeSpec: false - installCadlRanch: false - folderName: "" - regenerate: false - checkChange: true - updateToLatestTypespec: false - unitTest: false - skipWarning: false + installAutorest: false + installTypeSpec: false + installCadlRanch: false + folderName: "" + regenerate: false + checkChange: true + updateToLatestTypespec: false + unitTest: false + skipWarning: false steps: - - checkout: self - - checkout: azure-sdk-tools - - template: eng/common/testproxy/test-proxy-tool.yml@azure-sdk-tools - parameters: - TestProxy: true - templateRoot: azure-sdk-tools - - task: NodeTool@0 - displayName: "Install Node.js 20.x" - inputs: - versionSpec: "20.x" - - - task: UsePythonVersion@0 - displayName: "Use Python $(PythonVersion)" - inputs: - versionSpec: $(PythonVersion) - - - script: npm install -g pnpm@9.5.0 - displayName: Install pnpm 9.5.0 - - - script: npm install -g autorest - displayName: Install autorest - condition: and(succeeded(), ${{ parameters.installAutorest }}) - - - script: npm install -g @typespec/compiler - displayName: Install TypeSpec - condition: and(succeeded(), ${{ parameters.installTypeSpec }}) - - - script: npm install -g @typespec/compiler@next - displayName: Install TypeSpec Next - condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) - - - script: npm install -g @azure-tools/typespec-bump-deps@latest - displayName: Install @azure-tools/typespec-bump-deps - condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) - - - 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/ - condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) - - - script: pnpm install --no-frozen-lockfile - displayName: Pnpm install no frozen lockfile - workingDirectory: $(Build.SourcesDirectory)/autorest.python/ - condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) - - - script: pnpm install - displayName: Pnpm install - workingDirectory: $(Build.SourcesDirectory)/autorest.python/ - condition: and(succeeded(), eq(${{ parameters.updateToLatestTypespec }}, false)) - - - script: pnpm list - displayName: Pnpm list - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python - - - script: pnpm run build - displayName: Build project - workingDirectory: $(Build.SourcesDirectory)/autorest.python/ - - - script: pip list - displayName: List installed packages - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pip install -r dev_requirements.txt - displayName: Pip install dev requirements - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pip list - displayName: List installed packages - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pnpm run cspell - displayName: Cspell - workingDirectory: $(Build.SourcesDirectory)/autorest.python/ - - - script: pnpm run lint --command eslint --skipWarning ${{ parameters.skipWarning }} - displayName: Eslint - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pnpm run lint --command pylint - displayName: Pylint - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pnpm run lint --command mypy - displayName: Mypy - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pnpm run lint --command pyright - displayName: Pyright - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: pnpm run format - displayName: Black - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} - - - script: node ./eng/scripts/check-for-changed-files.js - displayName: Fail on black diff of root folder - workingDirectory: $(Build.SourcesDirectory)/autorest.python/ - condition: and(succeeded(), ${{ parameters.checkChange }}) - - - script: | - cd test/unittests - tox run -e ci - displayName: Unit tests - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ - condition: and(succeeded(), ${{ parameters.unitTest }}) - - - script: inv regenerate - displayName: "Regenerate Code(autorest)" - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ - condition: and(succeeded(), ${{ parameters.regenerate }}, eq('${{parameters.folderName}}', 'autorest.python')) - - - script: | - rm -rf test/azure/generated test/unbranded/generated - npm run regenerate - displayName: "Regenerate Code(typespec)" - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ - condition: and(succeeded(), ${{ parameters.regenerate }}, eq('${{parameters.folderName}}', 'typespec-python')) - - - 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 - condition: and(succeeded(), ${{ parameters.regenerate }}, ${{ parameters.checkChange }}) - - - script: node ../../../eng/scripts/check-for-changed-files.js - displayName: Fail on regeneration diff in Autorest - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/autorest.python/test - condition: and(succeeded(), ${{ parameters.regenerate }}, ${{ parameters.checkChange }}) - - - script: | - pnpm pack - AbsolutePkgPath=$(find "$(pwd)" -name "autorest-python-*" -maxdepth 1) - cd ../.. - pnpm install $AbsolutePkgPath -w --verbose - displayName: Test tarball - workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ + - checkout: self + - checkout: azure-sdk-tools + - template: eng/common/testproxy/test-proxy-tool.yml@azure-sdk-tools + parameters: + TestProxy: true + templateRoot: azure-sdk-tools + - task: NodeTool@0 + displayName: "Install Node.js 20.x" + inputs: + versionSpec: "20.x" + + - task: UsePythonVersion@0 + displayName: "Use Python $(PythonVersion)" + inputs: + versionSpec: $(PythonVersion) + + - script: npm install -g pnpm@9.5.0 + displayName: Install pnpm 9.5.0 + + - script: npm install -g autorest + displayName: Install autorest + condition: and(succeeded(), ${{ parameters.installAutorest }}) + + - script: npm install -g @typespec/compiler + displayName: Install TypeSpec + condition: and(succeeded(), ${{ parameters.installTypeSpec }}) + + - script: npm install -g @typespec/compiler@next + displayName: Install TypeSpec Next + condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) + + - script: npm install -g @azure-tools/typespec-bump-deps@latest + displayName: Install @azure-tools/typespec-bump-deps + condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) + + - 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/ + condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) + + - script: pnpm install --no-frozen-lockfile + displayName: Pnpm install no frozen lockfile + workingDirectory: $(Build.SourcesDirectory)/autorest.python/ + condition: and(succeeded(), ${{ parameters.updateToLatestTypespec }}) + + - script: pnpm install + displayName: Pnpm install + workingDirectory: $(Build.SourcesDirectory)/autorest.python/ + condition: and(succeeded(), eq(${{ parameters.updateToLatestTypespec }}, false)) + + - script: pnpm list + displayName: Pnpm list + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python + + - script: pnpm run build + displayName: Build project + workingDirectory: $(Build.SourcesDirectory)/autorest.python/ + + - script: pip list + displayName: List installed packages + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pip install -r dev_requirements.txt + displayName: Pip install dev requirements + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pip list + displayName: List installed packages + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pnpm run cspell + displayName: Cspell + workingDirectory: $(Build.SourcesDirectory)/autorest.python/ + + - script: pnpm run lint --command eslint --skipWarning ${{ parameters.skipWarning }} + displayName: Eslint + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pnpm run lint --command pylint + displayName: Pylint + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pnpm run lint --command mypy + displayName: Mypy + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pnpm run lint --command pyright + displayName: Pyright + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: pnpm run format + displayName: Black + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}} + + - script: node ./eng/scripts/check-for-changed-files.js + displayName: Fail on black diff of root folder + workingDirectory: $(Build.SourcesDirectory)/autorest.python/ + condition: and(succeeded(), ${{ parameters.checkChange }}, eq(variables['Agent.OS'], 'Linux')) + + - script: | + cd test/unittests + tox run -e ci + displayName: Unit tests + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ + condition: and(succeeded(), ${{ parameters.unitTest }}) + + - script: inv regenerate + displayName: "Regenerate Code(autorest)" + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ + condition: and(succeeded(), ${{ parameters.regenerate }}, eq('${{parameters.folderName}}', 'autorest.python')) + + - script: | + rm -rf test/azure/generated test/unbranded/generated + npm run regenerate + displayName: "Regenerate Code(typespec)" + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ + condition: and(succeeded(), ${{ parameters.regenerate }}, eq('${{parameters.folderName}}', 'typespec-python')) + + - 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 + condition: and(succeeded(), ${{ parameters.regenerate }}, ${{ parameters.checkChange }}, eq(variables['Agent.OS'], 'Linux')) + + - script: node ../../../eng/scripts/check-for-changed-files.js + displayName: Fail on regeneration diff in Autorest + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/autorest.python/test + condition: and(succeeded(), ${{ parameters.regenerate }}, ${{ parameters.checkChange }}, eq(variables['Agent.OS'], 'Linux')) + + - script: | + pnpm pack + AbsolutePkgPath=$(find "$(pwd)" -name "autorest-python-*" -maxdepth 1) + cd ../.. + pnpm install $AbsolutePkgPath -w --verbose + displayName: Test tarball + workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/${{parameters.folderName}}/ diff --git a/eng/pipelines/ci.yml b/eng/pipelines/ci.yml index 56c8b5d51ee..18509b2181e 100644 --- a/eng/pipelines/ci.yml +++ b/eng/pipelines/ci.yml @@ -56,9 +56,8 @@ jobs: PythonVersion: "3.9" Windows_Python3.9: OSName: "Windows" - # TODO: Update to WINDOWSPOOL and WINDOWSVMIMAGE once tests pass - Pool: ${{ variables.LINUXPOOL }} - OSVmImage: ${{ variables.LINUXVMIMAGE}} + Pool: ${{ variables.WINDOWSPOOL }} + OSVmImage: ${{ variables.WINDOWSVMIMAGE}} PythonVersion: "3.9" Linux_Python3.10: OSName: "Linux" @@ -77,9 +76,8 @@ jobs: PythonVersion: "3.12" Windows_Python3.12: OSName: "Windows" - # TODO: Update to WINDOWSPOOL and WINDOWSVMIMAGE once tests pass - Pool: ${{ variables.LINUXPOOL }} - OSVmImage: ${{ variables.LINUXVMIMAGE}} + Pool: ${{ variables.WINDOWSPOOL }} + OSVmImage: ${{ variables.WINDOWSVMIMAGE}} PythonVersion: "3.12" pool: @@ -157,9 +155,8 @@ jobs: PythonVersion: "3.9" Windows_Python3.9: OSName: "Windows" - # TODO: Update to WINDOWSPOOL and WINDOWSVMIMAGE once tests pass - Pool: ${{ variables.LINUXPOOL }} - OSVmImage: ${{ variables.LINUXVMIMAGE}} + Pool: ${{ variables.WINDOWSPOOL }} + OSVmImage: ${{ variables.WINDOWSVMIMAGE}} PythonVersion: "3.9" Linux_Python310: OSName: "Linux" @@ -178,9 +175,8 @@ jobs: PythonVersion: "3.12" Windows_Python312: OSName: "Windows" - # TODO: Update to WINDOWSPOOL and WINDOWSVMIMAGE once tests pass - Pool: ${{ variables.LINUXPOOL }} - OSVmImage: ${{ variables.LINUXVMIMAGE}} + Pool: ${{ variables.WINDOWSPOOL }} + OSVmImage: ${{ variables.WINDOWSVMIMAGE}} PythonVersion: "3.12" pool: diff --git a/packages/autorest.python/scripts/eng/run-tests.ts b/packages/autorest.python/scripts/eng/run-tests.ts index 35237ada63b..a5ca1b3701c 100644 --- a/packages/autorest.python/scripts/eng/run-tests.ts +++ b/packages/autorest.python/scripts/eng/run-tests.ts @@ -46,7 +46,20 @@ const commandToRun = argv.command || "all"; function getCommand(command: string, folder: string, name?: string): string { if (!validCommands.includes(command)) throw new Error(`Unknown command '${command}'.`); - const retval = `FOLDER=${folder} tox -c ./test/${folder}/tox.ini -e ${command}`; + + // Check if running on Windows + const isWindows = process.platform === "win32"; + const baseCommand = `tox -c ./test/${folder}/tox.ini -e ${command}`; + + let retval: string; + if (isWindows) { + // Windows command format: set FOLDER=value && command + retval = `set FOLDER=${folder} && ${baseCommand}`; + } else { + // Unix/Linux/macOS format: FOLDER=value command + retval = `FOLDER=${folder} ${baseCommand}`; + } + if (name) { return `${retval} -- -f ${name}`; } diff --git a/packages/typespec-python/scripts/eng/run-tests.ts b/packages/typespec-python/scripts/eng/run-tests.ts index 35237ada63b..893e09e9f8b 100644 --- a/packages/typespec-python/scripts/eng/run-tests.ts +++ b/packages/typespec-python/scripts/eng/run-tests.ts @@ -46,7 +46,18 @@ const commandToRun = argv.command || "all"; function getCommand(command: string, folder: string, name?: string): string { if (!validCommands.includes(command)) throw new Error(`Unknown command '${command}'.`); - const retval = `FOLDER=${folder} tox -c ./test/${folder}/tox.ini -e ${command}`; + // Check if running on Windows + const isWindows = process.platform === "win32"; + const baseCommand = `tox -c ./test/${folder}/tox.ini -e ${command}`; + + let retval: string; + if (isWindows) { + // Windows command format: set FOLDER=value && command + retval = `set FOLDER=${folder} && ${baseCommand}`; + } else { + // Unix/Linux/macOS format: FOLDER=value command + retval = `FOLDER=${folder} ${baseCommand}`; + } if (name) { return `${retval} -- -f ${name}`; }