From 5b6a8cac71a4e29e491f4fdc48b28b6d6bc403ea Mon Sep 17 00:00:00 2001 From: "Valentin D. Pinkman" Date: Thu, 28 Mar 2024 12:33:55 +0100 Subject: [PATCH] chore(bot): fix git push chore(actions): update git config for forks !drop --- .github/workflows/generate-screenshots.yml | 2 +- .../update-snapshots-desktop/action.yml | 17 +++- tools/github-bot/src/commands/full-suite.ts | 80 ------------------- .../src/commands/generate-screenshots.ts | 14 ++-- tools/github-bot/src/commands/regen-doc.ts | 14 ++-- tools/github-bot/src/commands/regen-pods.ts | 14 ++-- tools/github-bot/src/index.ts | 3 - 7 files changed, 42 insertions(+), 102 deletions(-) delete mode 100644 tools/github-bot/src/commands/full-suite.ts diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index 339300f142f6..2ba68e7f49c7 100644 --- a/.github/workflows/generate-screenshots.yml +++ b/.github/workflows/generate-screenshots.yml @@ -84,7 +84,7 @@ jobs: skip_ruby: true install_playwright: true turborepo-server-port: ${{ steps.toolchain.outputs.port }} - - uses: LedgerHQ/ledger-live/tools/actions/composites/update-snapshots-desktop@develop + - uses: LedgerHQ/ledger-live/tools/actions/composites/update-snapshots-desktop@chore/update-push-on-forks id: update-snapshots with: os: ubuntu-latest diff --git a/tools/actions/composites/update-snapshots-desktop/action.yml b/tools/actions/composites/update-snapshots-desktop/action.yml index 6ab9481b493c..eae3612d799e 100644 --- a/tools/actions/composites/update-snapshots-desktop/action.yml +++ b/tools/actions/composites/update-snapshots-desktop/action.yml @@ -38,13 +38,24 @@ runs: - name: Commit snapshots if: steps.status.outputs.status != 0 || steps.status-windows.outputs.status != 0 run: | + git config branch.autoSetupMerge simple git add ./apps/ledger-live-desktop/tests/specs && git commit -m "test(lld): update screenshots (${{ inputs.os }}) ${{ steps.changes.outputs.changes }} lld, test, screenshot" && git restore . && - git pull --rebase && - git push || - echo "" + git pull --rebase + shell: bash + - name: Push to PR + continue-on-error: true + shell: bash + id: push + run: | + git push orgin HEAD + - name: Push to remote ref shell: bash + id: push-remote + run: | + git push origin HEAD:refs/pull/${{ github.event.number }}/merge || + echo "" - name: Upload playwright results [On Failure] uses: actions/upload-artifact@v3 if: failure() && !cancelled() diff --git a/tools/github-bot/src/commands/full-suite.ts b/tools/github-bot/src/commands/full-suite.ts deleted file mode 100644 index baec039bd4bb..000000000000 --- a/tools/github-bot/src/commands/full-suite.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Probot, Context } from "probot"; -import { monitorWorkflow } from "../tools/monitorWorkflow"; -import { commands } from "./tools"; - -// Keep this in sync with the workflow file -const ACTION_ID = "lld_full_suite"; - -/** - * Slash command `/full-lld-tests` - * Run the full e2e test suite on LLD - * - * @param app The Probot application. - */ -export function runDesktopTestSuite(app: Probot) { - async function triggerWorkflow({ - context, - login, - }: { - context: Context<"issue_comment.created" | "check_run.requested_action">; - login: string; - full?: boolean; - }) { - const { payload } = context; - let ref; - if ("check_run" in payload) { - ref = payload.check_run.pull_requests[0]?.base.ref; - } else { - const { data: prData } = await context.octokit.rest.pulls.get({ - ...context.repo(), - pull_number: payload.issue.number, - }); - ref = prData.head.repo?.fork ? prData.base.ref : prData.head.ref; - } - - return context.octokit.actions.createWorkflowDispatch({ - ...context.repo(), - workflow_id: "test-desktop.yml", - ref, - inputs: { - login, - }, - }); - } - - commands(app, "full-lld-tests", async (context, _data) => { - const { payload } = context; - - if (context.isBot) return; - - await triggerWorkflow({ - context, - login: `${payload.comment.user.login}`, - }); - }); - - app.on("check_run.requested_action", async context => { - const { payload } = context; - - if (payload.requested_action.identifier !== ACTION_ID) return; - - const login = payload.sender.login; - - await triggerWorkflow({ - context, - login, - }); - }); - - monitorWorkflow(app, { - file: "test-desktop.yml", - checkRunName: "@Desktop • Test App", - description: - "Perform [end to end](https://playwright.dev/) and [unit](https://jestjs.io/fr/) tests, [type checks](https://www.typescriptlang.org/) and run the [linter](https://eslint.org/) on the Ledger Live Desktop application.", - summaryFile: "summary.json", - getInputs: payload => ({ - ref: payload.check_run.head_sha, - login: payload.sender.login, - }), - }); -} diff --git a/tools/github-bot/src/commands/generate-screenshots.ts b/tools/github-bot/src/commands/generate-screenshots.ts index 80755140f1e5..acadc904ddcc 100644 --- a/tools/github-bot/src/commands/generate-screenshots.ts +++ b/tools/github-bot/src/commands/generate-screenshots.ts @@ -68,12 +68,16 @@ export function generateScreenshots(app: Probot) { const number = payload.check_run.pull_requests[0]?.number; const login = payload.sender.login; - const res = await context.octokit.orgs.checkMembershipForUser({ - org: "LedgerHQ", - username: login, - }); + try { + const res = await context.octokit.orgs.checkMembershipForUser({ + org: "LedgerHQ", + username: login, + }); - if (res.status >= 300) return; + if (res.status >= 300) return; + } catch (error) { + return; + } if (!number) return; diff --git a/tools/github-bot/src/commands/regen-doc.ts b/tools/github-bot/src/commands/regen-doc.ts index f7870ed8a5e5..6aaa6c85e3d5 100644 --- a/tools/github-bot/src/commands/regen-doc.ts +++ b/tools/github-bot/src/commands/regen-doc.ts @@ -69,12 +69,16 @@ export function regenDoc(app: Probot) { const number = payload.check_run.pull_requests[0]?.number; const login = payload.sender.login; - const res = await context.octokit.orgs.checkMembershipForUser({ - org: "LedgerHQ", - username: login, - }); + try { + const res = await context.octokit.orgs.checkMembershipForUser({ + org: "LedgerHQ", + username: login, + }); - if (res.status >= 300) return; + if (res.status >= 300) return; + } catch (error) { + return; + } if (!number) return; diff --git a/tools/github-bot/src/commands/regen-pods.ts b/tools/github-bot/src/commands/regen-pods.ts index d58c10508db2..7dac421b1307 100644 --- a/tools/github-bot/src/commands/regen-pods.ts +++ b/tools/github-bot/src/commands/regen-pods.ts @@ -69,12 +69,16 @@ export function regenPods(app: Probot) { const number = payload.check_run.pull_requests[0]?.number; const login = payload.sender.login; - const res = await context.octokit.orgs.checkMembershipForUser({ - org: "LedgerHQ", - username: login, - }); + try { + const res = await context.octokit.orgs.checkMembershipForUser({ + org: "LedgerHQ", + username: login, + }); - if (res.status >= 300) return; + if (res.status >= 300) return; + } catch (error) { + return; + } if (!number) return; diff --git a/tools/github-bot/src/index.ts b/tools/github-bot/src/index.ts index 38c9ec2d0745..5e6fa5bdb931 100644 --- a/tools/github-bot/src/index.ts +++ b/tools/github-bot/src/index.ts @@ -3,7 +3,6 @@ import { upToDate } from "./features/upToDate"; import { orchestrator } from "./features/orchestrator"; import { lintCommits } from "./features/lintCommits"; import { generateScreenshots } from "./commands/generate-screenshots"; -import { runDesktopTestSuite } from "./commands/full-suite"; import { regenPods } from "./commands/regen-pods"; import { regenDoc } from "./commands/regen-doc"; import { autoClose } from "./features/autoClose"; @@ -17,8 +16,6 @@ export default (app: Probot) => { regenPods(app); // /regen-doc command regenDoc(app); - // /full-lld-tests - runDesktopTestSuite(app); /* PR stuff */