Test notebooks that submit jobs #20
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 2024. | |
# | |
# 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 that submit jobs | |
on: | |
schedule: | |
- cron: "0 7 1,15 * *" # At 07:00 on day-of-month 1 and 15. | |
workflow_dispatch: | |
jobs: | |
execute: | |
name: Execute notebooks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup environment | |
uses: ./.github/actions/set-up-notebook-testing | |
with: | |
ibm-quantum-token: ${{ secrets.IBM_QUANTUM_TEST_TOKEN }} | |
instance: "client-enablement/documentation/qiskit-documenta" | |
- name: Execute notebooks | |
timeout-minutes: 350 | |
run: tox -- --write --only-submit-jobs | |
- name: Detect changed notebooks | |
id: changed-notebooks | |
if: "!cancelled()" | |
run: | | |
echo "CHANGED_NOTEBOOKS<<EOF" >> $GITHUB_OUTPUT | |
git diff --name-only >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Make pull request with notebook outputs | |
if: "!cancelled()" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git switch -c actions/cron-${{ github.run_id }} | |
git commit -am "Re-run notebooks" | |
git push origin actions/cron-${{ github.run_id }} | |
gh pr create \ | |
-B main \ | |
-H actions/cron-${{ github.run_id }} \ | |
--title "Update notebook outputs" \ | |
--body "An action recently executed the notebooks in this repo. \ | |
This PR updates all notebooks that ran successfully with the new cell outputs. | |
> [!NOTE] | |
> This pull request was created by a GitHub action." \ | |
--reviewer frankharkins | |
- name: Upload executed notebooks | |
if: "!cancelled()" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Executed notebooks | |
path: ${{ steps.changed-notebooks.outputs.CHANGED_NOTEBOOKS || 'no-changes' }} | |
make_issue: | |
name: Make issue on failure | |
needs: [execute] | |
if: ${{ failure() && github.event_name == 'schedule' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Post issue | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const message = `Today's scheduled test of notebooks that submit jobs failed. | |
Please [check the logs](https://github.com/Qiskit/documentation/actions/runs/${{ github.run_id }}/). | |
> [!NOTE] | |
> This issue was created by a GitHub action. | |
` | |
github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: "Weekly notebook test failed", | |
body: message, | |
assignees: ["frankharkins", "javabster",] | |
}) |