Adding table for failed rebase

This commit is contained in:
2025-02-08 15:41:26 +01:00
parent 6bc610e67f
commit f2e5577475
4 changed files with 178 additions and 30 deletions

28
app.ts
View File

@@ -1,7 +1,7 @@
import { spawn } from "child_process";
import { ChildProcess, SpawnOptions } from "node:child_process";
import * as core from '@actions/core';
import { LogLevel, writeConsole } from "@skydust/toolkit";
import { LogLevel, styledTable, writeConsole } from "@skydust/toolkit";
// Ignored branches
const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required: false }).split(",");
@@ -172,13 +172,16 @@ const rebaseOrder = (branchesWithDependencies: Record<string, BranchWithDependen
}
const rebaseBranch = async ({
const rebaseBranch = async (rebaseAction: RebaseAction): Promise<RebaseAction & { success: boolean }> => {
let {
branch,
onBranch,
action
}: RebaseAction) => {
} = rebaseAction;
writeConsole(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`);
let doneWithSucess = false;
await runGitCommand([
"checkout",
branch.replace("origin/", "")
@@ -195,6 +198,7 @@ const rebaseBranch = async ({
"rebase",
"--abort"
])
doneWithSucess = true;
});
} else if(action === Action.Reset) {
await runGitCommand([
@@ -208,6 +212,8 @@ const rebaseBranch = async ({
"push",
"--force-with-lease"
]);
return { ...rebaseAction, success: doneWithSucess };
}
const setupCIToken = async () => {
@@ -285,8 +291,22 @@ const main = async (): Promise<void> => {
}
// Step 4: Rebase branches
const rebasedBranches: (RebaseAction & { success: boolean })[] = [];
for (const rebaseAction of order) {
await rebaseBranch(rebaseAction);
rebasedBranches.push(await rebaseBranch(rebaseAction));
}
const failedRebase = rebasedBranches.filter(rebased => !rebased.success)
.map(rebased => [rebased.branch, rebased.onBranch, rebased.action] as string[]);
if(failedRebase.length == 0) {
writeConsole("All rebase where done successfully", LogLevel.INFO);
} else {
writeConsole("Some rebase failed", LogLevel.WARNING);
styledTable([
["Branch", "Action", "Onto branch"],
...failedRebase
]);
}
} catch (error) {
writeConsole("Error during workflow execution", LogLevel.ERROR);

41
dist/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -13,7 +13,7 @@
"license": "ISC",
"dependencies": {
"@actions/core": "^1.11.1",
"@skydust/toolkit": "^1.2.1"
"@skydust/toolkit": "^1.3.2"
},
"devDependencies": {
"@types/node": "^22.10.0",

131
pnpm-lock.yaml generated
View File

@@ -12,8 +12,8 @@ importers:
specifier: ^1.11.1
version: 1.11.1
'@skydust/toolkit':
specifier: ^1.2.1
version: 1.2.3
specifier: ^1.3.2
version: 1.3.2
devDependencies:
'@types/node':
specifier: ^22.10.0
@@ -268,8 +268,8 @@ packages:
cpu: [x64]
os: [win32]
'@skydust/toolkit@1.2.3':
resolution: {integrity: sha512-1ksOp66zgkFnNRtPDAKz9UP8L4oJ+f1qq8SIONWNExVPrBy8mApU1Mw6vOHSlNDiJkn4233oomba8bb33ceFJA==, tarball: https://gitea.skydust.fr/api/packages/Skydust/npm/%40skydust%2Ftoolkit/-/1.2.3/toolkit-1.2.3.tgz}
'@skydust/toolkit@1.3.2':
resolution: {integrity: sha512-TOupR4CzN4+bM7jj8SKOFGk+e0L6Bx/KbYwb95vDdmfvbpQYlzypPnO/CgWj90T8aFhniAXuh+O/RrVJ5i9Nlg==, tarball: https://gitea.skydust.fr/api/packages/Skydust/npm/%40skydust%2Ftoolkit/-/1.3.2/toolkit-1.3.2.tgz}
hasBin: true
'@tybys/wasm-util@0.9.0':
@@ -283,15 +283,46 @@ packages:
peerDependencies:
valibot: ^1.0.0 || ^1.0.0-beta.5 || ^1.0.0-rc
ajv@8.17.1:
resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==}
ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'}
ansi-styles@4.3.0:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
astral-regex@2.0.0:
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
engines: {node: '>=8'}
chalk@5.4.1:
resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
color-convert@2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
engines: {node: '>=7.0.0'}
color-name@1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
esbuild@0.23.1:
resolution: {integrity: sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==}
engines: {node: '>=18'}
hasBin: true
fast-deep-equal@3.1.3:
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
fast-uri@3.0.6:
resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==}
fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
@@ -305,6 +336,20 @@ packages:
engines: {node: '>=18'}
hasBin: true
is-fullwidth-code-point@3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
json-schema-traverse@1.0.0:
resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==}
lodash.truncate@4.4.2:
resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==}
require-from-string@2.0.2:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
resolve-pkg-maps@1.0.0:
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
@@ -317,6 +362,22 @@ packages:
'@babel/runtime':
optional: true
slice-ansi@4.0.0:
resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==}
engines: {node: '>=10'}
string-width@4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
strip-ansi@6.0.1:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
table@6.9.0:
resolution: {integrity: sha512-9kY+CygyYM6j02t5YFHbNz2FN5QmYGv9zAjVp4lCDjlCw7amdckXlEt/bjMhUIfj4ThGRE4gCUH5+yGnNuPo5A==}
engines: {node: '>=10.0.0'}
tslib@2.8.1:
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -504,9 +565,10 @@ snapshots:
'@rolldown/binding-win32-x64-msvc@1.0.0-beta.3':
optional: true
'@skydust/toolkit@1.2.3':
'@skydust/toolkit@1.3.2':
dependencies:
chalk: 5.4.1
table: 6.9.0
'@tybys/wasm-util@0.9.0':
dependencies:
@@ -521,8 +583,31 @@ snapshots:
dependencies:
valibot: 1.0.0-beta.12(typescript@5.7.3)
ajv@8.17.1:
dependencies:
fast-deep-equal: 3.1.3
fast-uri: 3.0.6
json-schema-traverse: 1.0.0
require-from-string: 2.0.2
ansi-regex@5.0.1: {}
ansi-styles@4.3.0:
dependencies:
color-convert: 2.0.1
astral-regex@2.0.0: {}
chalk@5.4.1: {}
color-convert@2.0.1:
dependencies:
color-name: 1.1.4
color-name@1.1.4: {}
emoji-regex@8.0.0: {}
esbuild@0.23.1:
optionalDependencies:
'@esbuild/aix-ppc64': 0.23.1
@@ -550,6 +635,10 @@ snapshots:
'@esbuild/win32-ia32': 0.23.1
'@esbuild/win32-x64': 0.23.1
fast-deep-equal@3.1.3: {}
fast-uri@3.0.6: {}
fsevents@2.3.3:
optional: true
@@ -559,6 +648,14 @@ snapshots:
husky@9.1.7: {}
is-fullwidth-code-point@3.0.0: {}
json-schema-traverse@1.0.0: {}
lodash.truncate@4.4.2: {}
require-from-string@2.0.2: {}
resolve-pkg-maps@1.0.0: {}
rolldown@1.0.0-beta.3(typescript@5.7.3):
@@ -582,6 +679,30 @@ snapshots:
transitivePeerDependencies:
- typescript
slice-ansi@4.0.0:
dependencies:
ansi-styles: 4.3.0
astral-regex: 2.0.0
is-fullwidth-code-point: 3.0.0
string-width@4.2.3:
dependencies:
emoji-regex: 8.0.0
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.1
strip-ansi@6.0.1:
dependencies:
ansi-regex: 5.0.1
table@6.9.0:
dependencies:
ajv: 8.17.1
lodash.truncate: 4.4.2
slice-ansi: 4.0.0
string-width: 4.2.3
strip-ansi: 6.0.1
tslib@2.8.1:
optional: true