From d70b8e57efbbe7cc6d1f99d510a19ed44e5dc012 Mon Sep 17 00:00:00 2001 From: Prashant Sawant Date: Tue, 16 Jul 2024 11:18:44 -0400 Subject: [PATCH 1/4] feat: adds working directory - added coverage file as it's needed to run the npm tests --- action.yml | 5 +++++ src/main.ts | 6 ++++++ tests/pass_repo/coverage/lcov.info | 16 ++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/pass_repo/coverage/lcov.info diff --git a/action.yml b/action.yml index c03f450..c55f688 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,11 @@ inputs: description: "Token used for pushing fixes and commenting on PRs" required: true + working-directory: + description: "The working directory" + required: false + default: "." + run-tests: description: "Run tests" required: false diff --git a/src/main.ts b/src/main.ts index 95c1590..0d5c6d2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,6 +13,12 @@ export type stepResponse = { output: string; error: boolean }; const run = async () => { try { + const workingDirectory = getInput('working-directory'); + // Check if the working directory is different from the current directory + if (workingDirectory && workingDirectory !== process.cwd()) { + process.chdir(workingDirectory); + } + const token = process.env.GITHUB_TOKEN || getInput("token"); const runTests = getBooleanInput("run-tests"); const runAnalyze = getBooleanInput("run-analyze"); diff --git a/tests/pass_repo/coverage/lcov.info b/tests/pass_repo/coverage/lcov.info new file mode 100644 index 0000000..9c31854 --- /dev/null +++ b/tests/pass_repo/coverage/lcov.info @@ -0,0 +1,16 @@ +SF:lib/main.dart +DA:3,0 +DA:8,2 +DA:10,1 +DA:17,1 +DA:21,1 +DA:22,1 +DA:28,0 +DA:30,1 +DA:32,1 +DA:33,4 +DA:34,1 +DA:35,1 +LF:12 +LH:10 +end_of_record From b4a6c2a85727a9da1b64e90e53c0ad1e226d3e07 Mon Sep 17 00:00:00 2001 From: Prashant Sawant Date: Tue, 16 Jul 2024 11:26:17 -0400 Subject: [PATCH 2/4] chore: update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 25167c1..d8b5664 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ jobs: | run-coverage | Whether code coverage should be run. | false | true | | run-behind-by | Whether action should check if HEAD branch is behind base branch. | false | true | | create-comment | Whether the action should comment the output status. | false | true | +| working-directory | Working directory to run the action in | false | "." | ## Contributing From 303f044124322e626e38c1e1183cd8cee3eebaaa Mon Sep 17 00:00:00 2001 From: Prashant Sawant Date: Tue, 16 Jul 2024 11:29:15 -0400 Subject: [PATCH 3/4] chore: readme format --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d8b5664..7e0a80a 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,15 @@ jobs: ## Inputs -| Name | Description | Required | default | -| -------------- | ----------------------------------------------------------------- | -------- | ------- | -| token | Token used for pushing fixes and commenting on PRs. | true | | -| run-tests | Whether tests should be run. | false | true | -| run-analysis | Whether static analysis should be run. | false | true | -| run-coverage | Whether code coverage should be run. | false | true | -| run-behind-by | Whether action should check if HEAD branch is behind base branch. | false | true | -| create-comment | Whether the action should comment the output status. | false | true | -| working-directory | Working directory to run the action in | false | "." | +| Name | Description | Required | Default | +| ----------------- | ----------------------------------------------------------------- | -------- | ------- | +| token | Token used for pushing fixes and commenting on PRs. | true | | +| run-tests | Whether tests should be run. | false | true | +| run-analysis | Whether static analysis should be run. | false | true | +| run-coverage | Whether code coverage should be run. | false | true | +| run-behind-by | Whether action should check if HEAD branch is behind base branch. | false | true | +| create-comment | Whether the action should comment the output status. | false | true | +| working-directory | Working directory to run the action in | false | "." | ## Contributing From a8fee0f261a73845c303a5b8ab722e6aab298208 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 16 Jul 2024 15:39:41 +0000 Subject: [PATCH 4/4] ci(automated commit): Build bundled file --- dist/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/index.js b/dist/index.js index 522f0e5..af29b59 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33152,6 +33152,11 @@ const behind_1 = __nccwpck_require__(8890); const push_1 = __nccwpck_require__(3662); const run = async () => { try { + const workingDirectory = (0, core_1.getInput)('working-directory'); + // Check if the working directory is different from the current directory + if (workingDirectory && workingDirectory !== process.cwd()) { + process.chdir(workingDirectory); + } const token = process.env.GITHUB_TOKEN || (0, core_1.getInput)("token"); const runTests = (0, core_1.getBooleanInput)("run-tests"); const runAnalyze = (0, core_1.getBooleanInput)("run-analyze");