-
Notifications
You must be signed in to change notification settings - Fork 85
92 lines (85 loc) · 3.26 KB
/
notebook-test-cron.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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"
install-linux-deps: true
- name: Execute notebooks
timeout-minutes: 350
run: tox -- --write --test-strategy hardware
- 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,
labels: ["needs triage 🤔"],
})