From 3c5fd3f3120c8f729804ccec6e1e288d8cedbc9f Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Fri, 7 Nov 2025 18:30:50 +0100 Subject: [PATCH 1/8] Add action Test in workflow Fix action multiline output undefined debug fix Remove debug Install Wasp from linked PR Fix step Case insensitive --- .github/actions/get-linked-pr/action.yml | 80 ++++++++++++++++++++++++ .github/workflows/e2e-tests.yml | 8 ++- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .github/actions/get-linked-pr/action.yml diff --git a/.github/actions/get-linked-pr/action.yml b/.github/actions/get-linked-pr/action.yml new file mode 100644 index 000000000..56d81bb0f --- /dev/null +++ b/.github/actions/get-linked-pr/action.yml @@ -0,0 +1,80 @@ +name: Get linked PR +description: Get the PR linked to this one, if any. + +inputs: + github-token: + description: GitHub token to use for API requests + default: ${{ github.token }} + target-repo: + description: Repository in which the PR should exist (e.g. "wasp-lang/wasp") + required: true + source-repo: + description: Repository in which the current PR exists (e.g. "wasp-lang/open-saas") + default: ${{ github.repository }} + source-pr: + description: Current PR number + default: ${{ github.event.pull_request.number }} + +runs: + using: composite + steps: + - name: Get source PR + id: source-pr + env: + GH_TOKEN: ${{ inputs.github-token }} + SOURCE_REPO: ${{ inputs.source-repo }} + SOURCE_PR: ${{ inputs.source-pr }} + shell: bash + run: | + { + echo 'pr-body<> "$GITHUB_OUTPUT" + + - name: Get linked PR URL + id: get-url + env: + PR_BODY: ${{ steps.source-pr.outputs.pr-body }} + TARGET_REPO: ${{ inputs.target-repo }} + uses: actions/github-script@v8 + with: + script: | + const prBody = process.env.PR_BODY; + const targetRepo = process.env.TARGET_REPO; + + const prUrlPrefix = RegExp.escape(`https://github.com/${targetRepo}/pull`); + + // Captures the PR URL in a "link to ..." phrase. + const prUrlRegex = new RegExp(`\\blink to (${prUrlPrefix}\/\\d+)\/?`, "i"); + + const prUrl = prBody.match(prUrlRegex)?.[1]; + return prUrl || ""; + result-encoding: string + + - name: Get linked PR branch + if: steps.get-url.outputs.result + id: get-branch + env: + GH_TOKEN: ${{ inputs.github-token }} + PR_URL: ${{ steps.get-url.outputs.result }} + shell: bash + run: | + pr_branch=$( + gh pr view "$PR_URL" \ + --json headRefName \ + --jq '.headRefName' + ) + echo "pr-branch=$pr_branch" >> "$GITHUB_OUTPUT" + +outputs: + pr-url: + description: URL of the linked PR, or empty if none found + value: ${{ steps.get-url.outputs.result }} + + pr-branch: + description: Branch name of the linked PR, or empty if none found + value: ${{ steps.get-branch.outputs.pr-branch }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 3ad340e7d..bcfbaed65 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -29,11 +29,17 @@ jobs: - name: Docker setup uses: docker/setup-buildx-action@v3 + - name: Get linked PR branch + id: get-linked-pr-branch + uses: ./.github/actions/get-linked-pr + with: + target-repo: wasp-lang/wasp + - name: Download Wasp build artifacts from linked PR uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@main with: output-dir: ${{ runner.temp }}/wasp-cli - branch: main + branch: ${{ steps.get-linked-pr-branch.outputs.pr-branch || 'main' }} - name: Install Wasp run: > From b0e09aaa6b75e1976284f883237f891bd039a8f5 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 12:22:53 +0100 Subject: [PATCH 2/8] Test --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index bcfbaed65..f6886e0fd 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -36,7 +36,7 @@ jobs: target-repo: wasp-lang/wasp - name: Download Wasp build artifacts from linked PR - uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@main + uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@cprecioso/add-error-to-action with: output-dir: ${{ runner.temp }}/wasp-cli branch: ${{ steps.get-linked-pr-branch.outputs.pr-branch || 'main' }} From 7bceae2eec35fa380df1b6212fb96d72080c85b8 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 12:40:47 +0100 Subject: [PATCH 3/8] Add note --- .github/workflows/e2e-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 82a8d0de6..8bae26a26 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -34,6 +34,7 @@ jobs: target-repo: wasp-lang/wasp - name: Download Wasp build artifacts from linked PR + # TODO: Change to `main` branch once https://github.com/wasp-lang/wasp/pull/3335 is merged. uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@cprecioso/add-error-to-action with: output-dir: ${{ runner.temp }}/wasp-cli From 0ba29ef344adb26d0423efa38ee85307758f2e22 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 13:15:05 +0100 Subject: [PATCH 4/8] Add automation --- .../workflows/automation-check-linked-pr.yml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/automation-check-linked-pr.yml diff --git a/.github/workflows/automation-check-linked-pr.yml b/.github/workflows/automation-check-linked-pr.yml new file mode 100644 index 000000000..9c6a3d9d8 --- /dev/null +++ b/.github/workflows/automation-check-linked-pr.yml @@ -0,0 +1,30 @@ +name: Check linked PR + +on: + pull_request: + types: + - opened + - reopened + - edited + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Get linked PR + id: get-linked-pr + uses: ./.github/actions/get-linked-pr + with: + target-repo: wasp-lang/wasp + + - name: Block the PR if it is linked to a PR + if: steps.get-linked-pr.outputs.pr-url + run: | + echo "::notice::$MESSAGE" + exit 1 + env: + MESSAGE: > + This PR is linked to ${{ steps.get-linked-pr.outputs.pr-url }}. + Please make sure to review and merge that PR first. + If it is already merged, remove the link to allow merging. From ef025c379f2d73458147cbe41d8e109694d2b297 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 13:17:09 +0100 Subject: [PATCH 5/8] Better --- .../workflows/automation-check-linked-pr.yml | 30 ------------------- .github/workflows/e2e-tests.yml | 21 +++++++++++++ 2 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/automation-check-linked-pr.yml diff --git a/.github/workflows/automation-check-linked-pr.yml b/.github/workflows/automation-check-linked-pr.yml deleted file mode 100644 index 9c6a3d9d8..000000000 --- a/.github/workflows/automation-check-linked-pr.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Check linked PR - -on: - pull_request: - types: - - opened - - reopened - - edited - -jobs: - check: - runs-on: ubuntu-latest - - steps: - - name: Get linked PR - id: get-linked-pr - uses: ./.github/actions/get-linked-pr - with: - target-repo: wasp-lang/wasp - - - name: Block the PR if it is linked to a PR - if: steps.get-linked-pr.outputs.pr-url - run: | - echo "::notice::$MESSAGE" - exit 1 - env: - MESSAGE: > - This PR is linked to ${{ steps.get-linked-pr.outputs.pr-url }}. - Please make sure to review and merge that PR first. - If it is already merged, remove the link to allow merging. diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8bae26a26..045b5d69f 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -132,3 +132,24 @@ jobs: run: | cd e2e-tests npm run e2e:playwright + + check-if-linked-pr: + runs-on: ubuntu-latest + + steps: + - name: Get linked PR + id: get-linked-pr + uses: ./.github/actions/get-linked-pr + with: + target-repo: wasp-lang/wasp + + - name: Block the PR if it is linked to a PR + if: steps.get-linked-pr.outputs.pr-url + run: | + echo "::notice::$MESSAGE" + exit 1 + env: + MESSAGE: > + This PR is linked to ${{ steps.get-linked-pr.outputs.pr-url }}. + Please make sure to review and merge that PR first. + If it is already merged, remove the link and re-trigger the CI. From 27b058a2acb6401a0ea0c1a171de0989cde201cc Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 13:30:03 +0100 Subject: [PATCH 6/8] Missing --- .github/workflows/e2e-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 045b5d69f..4dbb80790 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -137,6 +137,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout the repo + uses: actions/checkout@v4 + - name: Get linked PR id: get-linked-pr uses: ./.github/actions/get-linked-pr From d2617f2e429f85cac31e30391b92a43fdeb5fecb Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 13:42:52 +0100 Subject: [PATCH 7/8] Merged --- .github/workflows/e2e-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4dbb80790..ce4939346 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -34,8 +34,7 @@ jobs: target-repo: wasp-lang/wasp - name: Download Wasp build artifacts from linked PR - # TODO: Change to `main` branch once https://github.com/wasp-lang/wasp/pull/3335 is merged. - uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@cprecioso/add-error-to-action + uses: wasp-lang/wasp/.github/actions/fetch-nightly-cli@main with: output-dir: ${{ runner.temp }}/wasp-cli branch: ${{ steps.get-linked-pr-branch.outputs.pr-branch || 'main' }} From 2cf8f6d94be4fa120b04b0ad32dac91d6bb7251d Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 10 Nov 2025 13:45:28 +0100 Subject: [PATCH 8/8] Remove other check --- .github/workflows/e2e-tests.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ce4939346..39145de4c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -131,27 +131,3 @@ jobs: run: | cd e2e-tests npm run e2e:playwright - - check-if-linked-pr: - runs-on: ubuntu-latest - - steps: - - name: Checkout the repo - uses: actions/checkout@v4 - - - name: Get linked PR - id: get-linked-pr - uses: ./.github/actions/get-linked-pr - with: - target-repo: wasp-lang/wasp - - - name: Block the PR if it is linked to a PR - if: steps.get-linked-pr.outputs.pr-url - run: | - echo "::notice::$MESSAGE" - exit 1 - env: - MESSAGE: > - This PR is linked to ${{ steps.get-linked-pr.outputs.pr-url }}. - Please make sure to review and merge that PR first. - If it is already merged, remove the link and re-trigger the CI.