From 6f02b4c3622bbe43dc516190f5f2079ce98aac5f Mon Sep 17 00:00:00 2001 From: Tarun Kumar S Date: Tue, 4 Feb 2025 20:54:41 +0530 Subject: [PATCH 1/5] test it --- src/config.js | 27 ++++++++++++++------------- src/index.js | 3 +++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/config.js b/src/config.js index 88cafc5..59ecfb3 100644 --- a/src/config.js +++ b/src/config.js @@ -18,6 +18,9 @@ class Config { key: core.getInput("key"), os: core.getInput("os") || "windows", version: core.getInput("version") || "latest", + cloneRepo: JSON.parse( + core.getInput("clone-repo")?.toLowerCase()?.trim() || "true" + ), createPR, prBase: createPR ? core.getInput("pr-base") || "main" : "", prBranch: createPR ? core.getInput("pr-branch") : "", @@ -26,27 +29,25 @@ class Config { }; let branchInfo = () => { - - let sha = github.context.sha; let ref = github.context.ref; - let context = ''; - + let context = ""; + if (github.context.event_name == "workflow_run") { - context = 'workflow_run'; + context = "workflow_run"; sha = github.context.event.workflow_run.pull_requests[0].head.sha; ref = github.context.event.workflow_run.pull_requests[0].head.ref; } else if (github.context.payload?.pull_request) { - context = 'pull_request'; + context = "pull_request"; sha = github.context.payload.pull_request.head.sha; ref = github.context.payload.pull_request.head.ref; } else { - context = 'default' + context = "default"; sha = github.context.sha; ref = github.context.ref; } - - let res = {sha, ref, context}; + + let res = { sha, ref, context }; console.log(""); console.log(chalk.green("Context")); @@ -55,10 +56,10 @@ class Config { console.log(chalk.yellow("sha:"), sha); return res; - } + }; + + let { sha, ref, context } = branchInfo(); - let {sha, ref, context} = branchInfo(); - // the values of github.context.repo.owner and github.context.repo.repo are taken from // the environment variable GITHUB_REPOSITORY specified in "owner/repo" format and // provided by the GitHub Action on the runtime @@ -71,7 +72,7 @@ class Config { sha, ref, workflow: github.context.workflow, - run_id: github.context.runId + run_id: github.context.runId, }; } } diff --git a/src/index.js b/src/index.js index 424ab7f..3609170 100644 --- a/src/index.js +++ b/src/index.js @@ -72,6 +72,7 @@ axios.interceptors.response.use( let testdriverBranch = config.input.branch; let key = config.input.key; let os = config.input.os; + let cloneRepo = config.input.cloneRepo; let testdriveraiVersion = config.input.version; let createPR = config.input.createPR; let prBranch = config.input.prBranch; @@ -90,6 +91,7 @@ axios.interceptors.response.use( console.log(chalk.yellow("repo:"), repo); console.log(chalk.yellow("branch:"), branch); console.log(chalk.yellow("os:"), os); + console.log(chalk.yellow("cloneRepo:"), cloneRepo); console.log(chalk.yellow("createPR:"), createPR); if (createPR) { if (prBranch) console.log(chalk.yellow("prBranch:"), prBranch); @@ -126,6 +128,7 @@ axios.interceptors.response.use( branch, prompt, os, + cloneRepo, prerun, version: testdriverBranch, key, From 7d5d7ad44959eb4e0e18409c585729859c19fcc7 Mon Sep 17 00:00:00 2001 From: Tarun Kumar S Date: Tue, 4 Feb 2025 21:04:39 +0530 Subject: [PATCH 2/5] update package --- dist/index.js | 4 ++++ src/config.js | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index fa68893..26d27a9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33648,6 +33648,7 @@ class Config { branch: core.getInput("branch") || "main", key: core.getInput("key"), os: core.getInput("os") || "windows", + cloneRepo: core.getInput("clone-repo")?.toLowerCase()?.trim() || "true", version: core.getInput("version") || "latest", createPR, prBase: createPR ? core.getInput("pr-base") || "main" : "", @@ -40082,6 +40083,7 @@ axios.interceptors.response.use( let testdriverBranch = config.input.branch; let key = config.input.key; let os = config.input.os; + let cloneRepo = config.input.cloneRepo; let testdriveraiVersion = config.input.version; let createPR = config.input.createPR; let prBranch = config.input.prBranch; @@ -40100,6 +40102,7 @@ axios.interceptors.response.use( console.log(chalk.yellow("repo:"), repo); console.log(chalk.yellow("branch:"), branch); console.log(chalk.yellow("os:"), os); + console.log(chalk.yellow("cloneRepo:"), cloneRepo); console.log(chalk.yellow("createPR:"), createPR); if (createPR) { if (prBranch) console.log(chalk.yellow("prBranch:"), prBranch); @@ -40136,6 +40139,7 @@ axios.interceptors.response.use( branch, prompt, os, + cloneRepo, prerun, version: testdriverBranch, key, diff --git a/src/config.js b/src/config.js index 59ecfb3..df23898 100644 --- a/src/config.js +++ b/src/config.js @@ -17,10 +17,8 @@ class Config { branch: core.getInput("branch") || "main", key: core.getInput("key"), os: core.getInput("os") || "windows", + cloneRepo: core.getInput("clone-repo")?.toLowerCase()?.trim() || "true", version: core.getInput("version") || "latest", - cloneRepo: JSON.parse( - core.getInput("clone-repo")?.toLowerCase()?.trim() || "true" - ), createPR, prBase: createPR ? core.getInput("pr-base") || "main" : "", prBranch: createPR ? core.getInput("pr-branch") : "", @@ -29,25 +27,27 @@ class Config { }; let branchInfo = () => { + + let sha = github.context.sha; let ref = github.context.ref; - let context = ""; - + let context = ''; + if (github.context.event_name == "workflow_run") { - context = "workflow_run"; + context = 'workflow_run'; sha = github.context.event.workflow_run.pull_requests[0].head.sha; ref = github.context.event.workflow_run.pull_requests[0].head.ref; } else if (github.context.payload?.pull_request) { - context = "pull_request"; + context = 'pull_request'; sha = github.context.payload.pull_request.head.sha; ref = github.context.payload.pull_request.head.ref; } else { - context = "default"; + context = 'default' sha = github.context.sha; ref = github.context.ref; } - - let res = { sha, ref, context }; + + let res = {sha, ref, context}; console.log(""); console.log(chalk.green("Context")); @@ -56,10 +56,10 @@ class Config { console.log(chalk.yellow("sha:"), sha); return res; - }; - - let { sha, ref, context } = branchInfo(); + } + let {sha, ref, context} = branchInfo(); + // the values of github.context.repo.owner and github.context.repo.repo are taken from // the environment variable GITHUB_REPOSITORY specified in "owner/repo" format and // provided by the GitHub Action on the runtime @@ -72,7 +72,7 @@ class Config { sha, ref, workflow: github.context.workflow, - run_id: github.context.runId, + run_id: github.context.runId }; } } From 7866c6259c3af181f6fa9abc6182f5eb6518a89a Mon Sep 17 00:00:00 2001 From: Tarun Kumar Date: Mon, 10 Feb 2025 13:46:38 +0530 Subject: [PATCH 3/5] add to action schema --- .gitignore | 1 + action.yml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 37d7e73..28cde21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules .env +.DS_Store \ No newline at end of file diff --git a/action.yml b/action.yml index d257d4f..078d8ba 100644 --- a/action.yml +++ b/action.yml @@ -39,6 +39,11 @@ inputs: Specify if a PR should be created with the updated test results. Defaults to "false" default: "false" required: false + clone-repo: + description: "Whether to clone the repository" + required: false + default: "true" + type: boolean pr-title: description: >- The title of the PR to be created From 5b5a1c468228e9e7d92dff747d500843253e183f Mon Sep 17 00:00:00 2001 From: Tarun Kumar Date: Mon, 10 Feb 2025 14:18:34 +0530 Subject: [PATCH 4/5] parse the val --- action.yml | 6 ++++-- src/config.js | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 078d8ba..67851e0 100644 --- a/action.yml +++ b/action.yml @@ -40,10 +40,12 @@ inputs: default: "false" required: false clone-repo: - description: "Whether to clone the repository" + type: boolean + description: >- + Whether to clone the repository, defaults to "true" + Used for desktop app testing required: false default: "true" - type: boolean pr-title: description: >- The title of the PR to be created diff --git a/src/config.js b/src/config.js index df23898..0f5f333 100644 --- a/src/config.js +++ b/src/config.js @@ -5,10 +5,12 @@ const chalk = require("chalk"); class Config { constructor() { let createPR = core.getInput("create-pr")?.toLowerCase()?.trim() || "false"; - if (!["true", "false"].includes(createPR)) { - throw new Error("Invalid value for create-pr. It should be a boolean"); + let cloneRepo = core.getInput("clone-repo")?.toLowerCase()?.trim() || "true"; + if (!["true", "false"].includes(createPR) || !["true", "false"].includes(cloneRepo)) { + throw new Error("Invalid value for create-pr or clone-repo. They should be booleans"); } else { createPR = JSON.parse(createPR); + cloneRepo = JSON.parse(cloneRepo); } this.input = { @@ -17,9 +19,9 @@ class Config { branch: core.getInput("branch") || "main", key: core.getInput("key"), os: core.getInput("os") || "windows", - cloneRepo: core.getInput("clone-repo")?.toLowerCase()?.trim() || "true", version: core.getInput("version") || "latest", createPR, + cloneRepo, prBase: createPR ? core.getInput("pr-base") || "main" : "", prBranch: createPR ? core.getInput("pr-branch") : "", prTitle: createPR ? core.getInput("pr-title") : "", From 57655f997cf1c583e1385bb7b49378263d5efbae Mon Sep 17 00:00:00 2001 From: Tarun Kumar Date: Mon, 10 Feb 2025 15:27:10 +0530 Subject: [PATCH 5/5] update dist --- dist/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 26d27a9..532a824 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33636,10 +33636,12 @@ const chalk = __nccwpck_require__(8818); class Config { constructor() { let createPR = core.getInput("create-pr")?.toLowerCase()?.trim() || "false"; - if (!["true", "false"].includes(createPR)) { - throw new Error("Invalid value for create-pr. It should be a boolean"); + let cloneRepo = core.getInput("clone-repo")?.toLowerCase()?.trim() || "true"; + if (!["true", "false"].includes(createPR) || !["true", "false"].includes(cloneRepo)) { + throw new Error("Invalid value for create-pr or clone-repo. They should be booleans"); } else { createPR = JSON.parse(createPR); + cloneRepo = JSON.parse(cloneRepo); } this.input = { @@ -33648,9 +33650,9 @@ class Config { branch: core.getInput("branch") || "main", key: core.getInput("key"), os: core.getInput("os") || "windows", - cloneRepo: core.getInput("clone-repo")?.toLowerCase()?.trim() || "true", version: core.getInput("version") || "latest", createPR, + cloneRepo, prBase: createPR ? core.getInput("pr-base") || "main" : "", prBranch: createPR ? core.getInput("pr-branch") : "", prTitle: createPR ? core.getInput("pr-title") : "",