From c6f6dc64a215ae4c227d688ca0fdf556eb173c11 Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Thu, 16 May 2024 14:21:09 +0100 Subject: [PATCH] Exit notebook tests early on forks (#1363) Suggestion on how to handle notebook testing on forks. Resolves #967. This PR proposes always failing the test on forks, with advice to merge to another branch in this repo to test it before merging to the main branch. While a little clunky, we very rarely get PRs from forks so this is probably simplest for now. We can review the process if it starts becoming a problem. --------- Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --- .github/workflows/notebook-test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml index 65403479c67..d96e3c6bc7f 100644 --- a/.github/workflows/notebook-test.yml +++ b/.github/workflows/notebook-test.yml @@ -25,6 +25,24 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Exit early on forks + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + shell: python + run: | + raise SystemExit( + "We can't run this test on pull requests from forks." + "\n\n" + "If you have write access to Qiskit/documentation, push to a new " + "branch there and make your pull request from that branch instead." + "\n\n" + "If you don't have write access, you must test out the notebook " + "locally using the instructions in " + "https://github.com/Qiskit/documentation#execute-notebooks." + "When this PR is approved, a maintainer will merge it to a new " + "branch in Qiskit/documentation, then make a PR from that branch " + "into main so it can pass CI." + ) + - name: Get all changed files id: all-changed-files uses: tj-actions/changed-files@af2816c65436325c50621100d67f6e853cd1b0f1