diff --git a/.coverage/lcov.info b/.coverage/lcov.info new file mode 100644 index 0000000..c50cc30 --- /dev/null +++ b/.coverage/lcov.info @@ -0,0 +1,7 @@ +f +fabf +fabf +fabf +fabd +sliders +dartf \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 0548ea4..6299f2c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -113816,27 +113816,45 @@ const push = async (coverageDirectory) => { console.error("Unable to check if there are changes", e); } (0, core_1.endGroup)(); - /// If `stdout` is empty, there are no changes - if (stdout != "") { + (0, core_1.startGroup)("Parse changes and remove coverage directory"); + const changes = stdout.split("\n").filter((line) => line.trim() !== ""); + if (changes.length === 1 && changes[0].includes(coverageDirectory)) { + changes.pop(); + } + (0, core_1.endGroup)(); + if (changes.length > 0) { try { - (0, core_1.startGroup)("Push changes"); + (0, core_1.startGroup)("Set up git"); await (0, exec_1.exec)('git config --global user.name "github-actions"'); await (0, exec_1.exec)('git config --global user.email "github-actions@github.com"'); - await (0, exec_1.exec)(`git add -A -- ':!${coverageDirectory}'`); + (0, core_1.endGroup)(); + try { + (0, core_1.startGroup)("Stage files"); + await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/`); + await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/*`); + } + catch (e) { + console.error("Unable to add files", e); + } + finally { + (0, core_1.endGroup)(); + } + (0, core_1.startGroup)("Commit changes"); (0, child_process_1.execSync)(`git commit -m 'chore(automated): Lint commit and format' `); + (0, core_1.endGroup)(); + (0, core_1.startGroup)("Push changes"); await (0, exec_1.exec)("git push -f"); (0, core_2.debug)("Changes pushed onto branch"); + (0, core_1.endGroup)(); } catch (e) { console.error("Unable to push changes", e); (0, core_1.setFailed)("Unable to push changes to branch"); } - finally { - (0, core_1.endGroup)(); - } } }; exports.push = push; +(0, exports.push)(".coverage"); /***/ }), diff --git a/src/scripts/push.ts b/src/scripts/push.ts index 6ab6932..cf34f02 100644 --- a/src/scripts/push.ts +++ b/src/scripts/push.ts @@ -2,6 +2,7 @@ import { endGroup, setFailed, setOutput, startGroup } from "@actions/core"; import { exec } from "@actions/exec"; import { execSync } from "child_process"; import { debug } from "@actions/core"; +import { start } from "repl"; /** * Push changes to the branch @@ -17,22 +18,42 @@ export const push = async (coverageDirectory: string) => { console.error("Unable to check if there are changes", e); } endGroup(); + startGroup("Parse changes and remove coverage directory"); + const changes = stdout.split("\n").filter((line) => line.trim() !== ""); + if (changes.length === 1 && changes[0].includes(coverageDirectory)) { + changes.pop(); + } + endGroup(); - /// If `stdout` is empty, there are no changes - if (stdout != "") { + if (changes.length > 0) { try { - startGroup("Push changes"); + startGroup("Set up git"); await exec('git config --global user.name "github-actions"'); await exec('git config --global user.email "github-actions@github.com"'); - await exec(`git add -A -- ':!${coverageDirectory}'`); + endGroup(); + + try { + startGroup("Stage files"); + await exec(`git add -A -- :!${coverageDirectory}/`); + await exec(`git add -A -- :!${coverageDirectory}/*`); + } catch (e) { + console.error("Unable to add files", e); + } finally { + endGroup(); + } + startGroup("Commit changes"); execSync(`git commit -m 'chore(automated): Lint commit and format' `); + endGroup(); + startGroup("Push changes"); await exec("git push -f"); + debug("Changes pushed onto branch"); + endGroup(); } catch (e) { console.error("Unable to push changes", e); setFailed("Unable to push changes to branch"); - } finally { - endGroup(); } } }; + +push(".coverage");