From f72159f4f731deb4bfa0caa91dceb31757178651 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 19 Apr 2024 09:18:08 -0700 Subject: [PATCH 01/11] Fix password flow --- docs/libraries/http/reference/data-types.md | 12 ++++++------ packages/http/lib/auth.tsp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/libraries/http/reference/data-types.md b/docs/libraries/http/reference/data-types.md index 35dfc10b30..109a8f8373 100644 --- a/docs/libraries/http/reference/data-types.md +++ b/docs/libraries/http/reference/data-types.md @@ -416,12 +416,12 @@ model TypeSpec.Http.PasswordFlow #### Properties -| Name | Type | Description | -| ---------------- | --------------------------------------- | --------------------------------- | -| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow | -| authorizationUrl | `string` | the authorization URL | -| refreshUrl? | `string` | the refresh URL | -| scopes? | `string[]` | list of scopes for the credential | +| Name | Type | Description | +| ----------- | --------------------------------------- | --------------------------------- | +| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow | +| tokenUrl | `string` | the token URL | +| refreshUrl? | `string` | the refresh URL | +| scopes? | `string[]` | list of scopes for the credential | ### `PlainData` {#TypeSpec.Http.PlainData} diff --git a/packages/http/lib/auth.tsp b/packages/http/lib/auth.tsp index ec4a39ba4f..2fdc29f843 100644 --- a/packages/http/lib/auth.tsp +++ b/packages/http/lib/auth.tsp @@ -177,8 +177,8 @@ model PasswordFlow { @doc("password flow") type: OAuth2FlowType.password; - @doc("the authorization URL") - authorizationUrl: string; + @doc("the token URL") + tokenUrl: string; @doc("the refresh URL") refreshUrl?: string; From 7faa8b8af08a9b2945c57971372dae6e6b525c65 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 19 Apr 2024 09:44:20 -0700 Subject: [PATCH 02/11] Create fix-password-flow-2024-3-19-16-22-3.md --- .chronus/changes/fix-password-flow-2024-3-19-16-22-3.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/fix-password-flow-2024-3-19-16-22-3.md diff --git a/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md b/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md new file mode 100644 index 0000000000..435e17e523 --- /dev/null +++ b/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/http" +--- + +Fix password flow defining `authorizationUrl` instead of `tokenUrl` From 4b43fb9a740f0b1a0d3ce3f3c05d4d4176c20fbc Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 16:16:45 -0700 Subject: [PATCH 03/11] fix --- eng/common/pipelines/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index 91b0e00ed7..a0d86e9f3d 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -1,9 +1,12 @@ -trigger: none +trigger: + branches: + include: + - gh-readonly-queue/* + pr: branches: include: - main - - gh-readonly-queue/* extends: template: /eng/common/pipelines/templates/1es-redirect.yml From ff665205bedb1ad0efee7bd055b9fa6e129fb6ab Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 16:28:41 -0700 Subject: [PATCH 04/11] Fix docs --- eng/common/pipelines/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index a0d86e9f3d..4e712187a1 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -22,6 +22,9 @@ extends: - job: InitJob displayName: Initialize steps: + - script: node /eng/common/scripts/resolve-target-branch.js + displayName: Resolve target branch + - task: PowerShell@2 displayName: "Analyze PR changes" name: InitStep From a082998e0355a9e854a0be330fb8b38e43fca787 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 16:28:48 -0700 Subject: [PATCH 05/11] missing --- eng/common/scripts/resolve-target-branch.js | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 eng/common/scripts/resolve-target-branch.js diff --git a/eng/common/scripts/resolve-target-branch.js b/eng/common/scripts/resolve-target-branch.js new file mode 100644 index 0000000000..c28c2b11a8 --- /dev/null +++ b/eng/common/scripts/resolve-target-branch.js @@ -0,0 +1,25 @@ +// @ts-check +console.log("Process", process.env); + +const prTargetBranch = process.env["System_PullRequest_TargetBranch"]; +const currentBranch = process.env["Build_SourceBranch"]; + +console.log("Branches:", { + prTargetBranch, + currentBranch, +}); + +if (prTargetBranch !== undefined) { + console.log("Target branch is", prTargetBranch); + console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`); +} else if (currentBranch) { + const segments = currentBranch.split("/"); + if (segments[0] === "github-readonly-queue") { + const targetBranch = segments.slice(1, segments.length - 2).join("/"); + console.log("Target branch is", targetBranch); + console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`); + } +} else { + console.log("Failed to resolve target branch."); + process.exit(1); +} From 350b87c508eed601753f15c63af184e7ac8d0698 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 16:31:00 -0700 Subject: [PATCH 06/11] Fix docs --- eng/common/pipelines/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index 4e712187a1..d7f004db6a 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -32,7 +32,7 @@ extends: pwsh: true filePath: $(Build.SourcesDirectory)/eng/common/scripts/Analyze-Changes.ps1 arguments: > - -TargetBranch $(System.PullRequest.TargetBranch) + -TargetBranch $TARGET_BRANCH workingDirectory: $(Build.SourcesDirectory) # Run csharp stages if RunCSharp == true From f7e7556bdee1f314232c897ebd10d7c126136190 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 16:32:44 -0700 Subject: [PATCH 07/11] Fix docs --- eng/common/pipelines/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index d7f004db6a..4f4e4ba31b 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -22,7 +22,7 @@ extends: - job: InitJob displayName: Initialize steps: - - script: node /eng/common/scripts/resolve-target-branch.js + - script: node $(Build.SourcesDirectory)/eng/common/scripts/resolve-target-branch.js displayName: Resolve target branch - task: PowerShell@2 From 3627b3d2bcd10ff95e994f5e407853f1a239965a Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 17:12:04 -0700 Subject: [PATCH 08/11] . --- eng/common/scripts/resolve-target-branch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/resolve-target-branch.js b/eng/common/scripts/resolve-target-branch.js index c28c2b11a8..7b2605ac7e 100644 --- a/eng/common/scripts/resolve-target-branch.js +++ b/eng/common/scripts/resolve-target-branch.js @@ -1,8 +1,8 @@ // @ts-check console.log("Process", process.env); -const prTargetBranch = process.env["System_PullRequest_TargetBranch"]; -const currentBranch = process.env["Build_SourceBranch"]; +const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"]; +const currentBranch = process.env["BUILD_SOURCEBRANCH"]; console.log("Branches:", { prTargetBranch, From 3c54de56ca2da3cf3b239a55a67a9cf98accfdaa Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 17:15:24 -0700 Subject: [PATCH 09/11] . --- eng/common/pipelines/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index 4f4e4ba31b..9a23ebe667 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -32,7 +32,7 @@ extends: pwsh: true filePath: $(Build.SourcesDirectory)/eng/common/scripts/Analyze-Changes.ps1 arguments: > - -TargetBranch $TARGET_BRANCH + -TargetBranch $(TARGET_BRANCH) workingDirectory: $(Build.SourcesDirectory) # Run csharp stages if RunCSharp == true From 200846db33cbe117c846ec8770fce9168138edd5 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 17:33:37 -0700 Subject: [PATCH 10/11] remove console.log of env --- eng/common/scripts/resolve-target-branch.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/common/scripts/resolve-target-branch.js b/eng/common/scripts/resolve-target-branch.js index 7b2605ac7e..f832abfc38 100644 --- a/eng/common/scripts/resolve-target-branch.js +++ b/eng/common/scripts/resolve-target-branch.js @@ -1,6 +1,4 @@ // @ts-check -console.log("Process", process.env); - const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"]; const currentBranch = process.env["BUILD_SOURCEBRANCH"]; From ce47ae8975bbd042bcee1d5e56cacb6373099187 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 22 Apr 2024 17:38:14 -0700 Subject: [PATCH 11/11] Fix docs --- eng/common/scripts/resolve-target-branch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/resolve-target-branch.js b/eng/common/scripts/resolve-target-branch.js index f832abfc38..271876df1d 100644 --- a/eng/common/scripts/resolve-target-branch.js +++ b/eng/common/scripts/resolve-target-branch.js @@ -11,9 +11,9 @@ if (prTargetBranch !== undefined) { console.log("Target branch is", prTargetBranch); console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`); } else if (currentBranch) { - const segments = currentBranch.split("/"); - if (segments[0] === "github-readonly-queue") { - const targetBranch = segments.slice(1, segments.length - 2).join("/"); + const match = currentBranch.match(/refs\/heads\/gh-readonly-queue\/(.*)\/pr-.*/); + if (match !== null) { + const targetBranch = match[1]; console.log("Target branch is", targetBranch); console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`); }