Add serverless guide with function template example: hamiltonian simu… #1968
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/**/*" | |
- "scripts/nb-tester/**/*" | |
workflow_dispatch: | |
jobs: | |
execute: | |
name: Execute notebooks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get relevant changed files | |
id: all-changed | |
uses: tj-actions/changed-files@af2816c65436325c50621100d67f6e853cd1b0f1 | |
with: | |
files: "{docs/**/*.ipynb,scripts/nb-tester/**/*}" | |
separator: "\n" | |
write_output_files: true | |
- name: Check if extra linux deps needed | |
id: check-deps | |
shell: python | |
run: | | |
# Add your notebook to this list if it needs latex or graphviz to run | |
EXTRA_DEPS_NOTEBOOKS = """\ | |
docs/guides/visualize-circuits.ipynb | |
docs/guides/custom-backend.ipynb | |
docs/guides/transpiler-stages.ipynb | |
docs/guides/represent-quantum-computers.ipynb | |
docs/guides/common-parameters.ipynb | |
""".strip().split("\n") | |
import os | |
github_output = os.getenv("GITHUB_OUTPUT") | |
all_files = """${{ steps.all-changed.outputs.all_changed_files }}""".split("\n") | |
config_changed = any(path.startswith("scripts/") for path in all_files) | |
extra_deps = config_changed or any(path in EXTRA_DEPS_NOTEBOOKS for path in all_files) | |
with open(github_output, "a") as output: | |
output.write(f"NEEDS_EXTRA_DEPS={str(extra_deps).lower()}") | |
- name: Setup environment | |
uses: ./.github/actions/set-up-notebook-testing | |
with: | |
# Install Linux deps if the specific guides were changed, or | |
# if all files are being tested. | |
install-linux-deps: ${{ steps.check-deps.outputs.NEEDS_EXTRA_DEPS }} | |
ibm-quantum-token: ${{ secrets.IBM_QUANTUM_TEST_TOKEN }} | |
- name: Execute notebooks | |
env: | |
PR_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} | |
run: python scripts/ci/pr-execute-notebooks.py | |
- name: Detect changed notebooks | |
id: changed-notebooks | |
run: | | |
echo "CHANGED_NOTEBOOKS<<EOF" >> $GITHUB_OUTPUT | |
git diff --name-only >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Upload executed notebooks | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Executed notebooks | |
path: ${{ steps.changed-notebooks.outputs.CHANGED_NOTEBOOKS || 'no-changes' }} |