From 94cdeb9818be062442a2fe6b084b42361af3435b Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 19 Apr 2022 09:29:35 -0700 Subject: [PATCH] Fix issue with detecting existing comment for tryit url (#458) --- CONTRIBUTING.md | 11 +++++++++++ eng/pipelines/pr-tryit.yaml | 2 +- eng/scripts/check-for-tryit-comment.js | 9 ++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf6ba2879..7a05abb72 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -221,3 +221,14 @@ the command line following the steps above, or build its Release configuration in Visual Studio, then you can install it by double-clicking on packages/cadl-vs/Microsoft.Cadl.VisualStudio.vsix that gets produced. + +# Pull request + +## Trigger Cadl Playground Try It build + +For contributors of the repo the build will trigger automatically but for other's forks it will need a manual trigger from a contributor. +As a contributor you can run the following command to trigger the build and create a cadl playground link for this PR. + +``` +/azp run Cadl Pull Request Try It +``` diff --git a/eng/pipelines/pr-tryit.yaml b/eng/pipelines/pr-tryit.yaml index e83c74648..caf82b333 100644 --- a/eng/pipelines/pr-tryit.yaml +++ b/eng/pipelines/pr-tryit.yaml @@ -37,5 +37,5 @@ jobs: inputs: gitHubConnection: "internal (1)" repositoryName: "$(Build.Repository.Name)" - comment: "You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/$(System.PullRequest.PullRequestNumber)/" + comment: "\nYou can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/$(System.PullRequest.PullRequestNumber)/" condition: and(succeeded(), ne(variables['SKIP_COMMENT'], 'true')) diff --git a/eng/scripts/check-for-tryit-comment.js b/eng/scripts/check-for-tryit-comment.js index 44075312d..f2a64a751 100644 --- a/eng/scripts/check-for-tryit-comment.js +++ b/eng/scripts/check-for-tryit-comment.js @@ -17,8 +17,11 @@ async function main() { const result = await request("GET", url); const data = JSON.parse(result); const azoComments = data.filter((x) => x.user?.login === AZP_USERID); - console.log(`Found ${azoComments.length} comments from Azure Pipelines.`); - if (azoComments.length > 0) { + console.log(`Found ${azoComments.length} comment(s) from Azure Pipelines.`); + + const tryItComments = data.filter((x) => x.body.includes("_CADL_TRYIT_COMMENT_")); + console.log(`Found ${azoComments.length} Cadl Try It comment(s)`); + if (tryItComments.length > 0) { console.log("##vso[task.setvariable variable=SKIP_COMMENT;]true"); } } @@ -37,7 +40,7 @@ async function request(method, url, postData) { "User-Agent": "nodejs", }, }; - console.log("P", params); + console.log("Params", params); return new Promise((resolve, reject) => { const req = lib.request(params, (res) => {