From c19282ec73b3a3a7cd1c7641fd2bb8eff43c8e92 Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Wed, 6 Dec 2023 13:33:44 +0000 Subject: [PATCH 1/4] Add action --- .github/workflows/notebook-test.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/notebook-test.yml diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml new file mode 100644 index 00000000000..5b5b8a2361c --- /dev/null +++ b/.github/workflows/notebook-test.yml @@ -0,0 +1,33 @@ +# This code is a Qiskit project. +# +# (C) Copyright IBM 2023. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +name: Test notebooks +on: + pull_request: + paths: + - "docs/**/*.ipynb" + - "!docs/api/**/*" + workflow_dispatch: +jobs: + execute: + name: Execute notebooks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Run tox + uses: lsst-sqre/run-tox@97818256d9fa3c72d0c12f31660718adb495a1cb + with: + python-version: "3.11" + tox-envs: "py311" From 825d88ee81e4c3d62c5b6cc9da3de2a9e67a4c3a Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Wed, 6 Dec 2023 14:00:58 +0000 Subject: [PATCH 2/4] Save account to get backend information --- .github/workflows/notebook-test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml index 5b5b8a2361c..cdd4f96af47 100644 --- a/.github/workflows/notebook-test.yml +++ b/.github/workflows/notebook-test.yml @@ -26,6 +26,16 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.11" + - name: Save IBM Quantum account + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + shell: python + run: | + from qiskit_ibm_runtime import QiskitRuntimeService + QiskitRuntimeService.save_account( + channel="ibm_quantum", + token="${{ secrets.IBM_QUANTUM_TEST_TOKEN }}", + set_as_default=True + ) - name: Run tox uses: lsst-sqre/run-tox@97818256d9fa3c72d0c12f31660718adb495a1cb with: From e346d08e5664a3f056d6a3758c8ea0ab9b256406 Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Wed, 6 Dec 2023 14:01:34 +0000 Subject: [PATCH 3/4] Edit notebook to test action --- docs/build/circuit-library.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/circuit-library.ipynb b/docs/build/circuit-library.ipynb index 67f6849703e..857a9a96f85 100644 --- a/docs/build/circuit-library.ipynb +++ b/docs/build/circuit-library.ipynb @@ -52,7 +52,7 @@ } ], "source": [ - "from qiskit.circuit.library import TwoLocal\n", + "from qiskit.circuit.library import TwoLocals\n", "two_local = TwoLocal(3, 'rx', 'cz')\n", "two_local.decompose().draw('mpl')" ] From 87743458a9e4807e1c2779a5429c42ea71c65b8f Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Wed, 6 Dec 2023 14:03:27 +0000 Subject: [PATCH 4/4] Install runtime first --- .github/workflows/notebook-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml index cdd4f96af47..8f2932f1f6d 100644 --- a/.github/workflows/notebook-test.yml +++ b/.github/workflows/notebook-test.yml @@ -26,6 +26,8 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.11" + - name: Install Qiskit IBM Runtime to save account + run: pip install qiskit-ibm-runtime - name: Save IBM Quantum account if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} shell: python