-
Notifications
You must be signed in to change notification settings - Fork 11
145 lines (129 loc) · 4.38 KB
/
test_notebooks.yml
File metadata and controls
145 lines (129 loc) · 4.38 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test Notebooks
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
discover:
name: Discover notebooks
runs-on: ubuntu-22.04
outputs:
notebooks: ${{ steps.find-notebooks.outputs.notebooks }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Find all notebooks
id: find-notebooks
run: |
echo "=================================================="
echo "Discovering notebooks"
echo "=================================================="
notebooks=$(find . -name "*.ipynb" -type f -not -path "*/venv/*" | jq -R -s -c 'split("\n")[:-1]')
echo "Found notebooks:"
echo "$notebooks" | jq -r '.[]'
echo "notebooks=$notebooks" >> $GITHUB_OUTPUT
test:
name: Test ${{ matrix.notebook }}
needs: discover
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
notebook: ${{ fromJson(needs.discover.outputs.notebooks) }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies with uv
run: |
echo "=================================================="
echo "Installing dependencies for ${{ matrix.notebook }}"
echo "=================================================="
start_time=$(date +%s)
uv pip install --system -e .
end_time=$(date +%s)
elapsed=$((end_time - start_time))
echo "✓ Dependencies installed in ${elapsed}s"
- name: Verify environment
run: |
echo "=================================================="
echo "Verifying environment setup"
echo "=================================================="
echo "✓ Python version:"
python --version
echo ""
echo "✓ uv version:"
uv --version
echo ""
echo "✓ Installed packages:"
uv pip list | grep -E "(jupyter|qiskit|cirq|pennylane|qbraid|cudaq)" || echo " (packages installed)"
echo ""
echo "✓ IONQ_API_KEY status:"
if [ -n "$IONQ_API_KEY" ]; then
echo " API key is set (length: ${#IONQ_API_KEY} characters)"
else
echo " WARNING: API key is not set!"
fi
env:
IONQ_API_KEY: ${{ secrets.IONQ_API_KEY }}
- name: Execute notebook
run: |
echo "=================================================="
echo "Executing: ${{ matrix.notebook }}"
echo "Timeout: 600s"
echo "=================================================="
start_time=$(date +%s)
echo "Starting execution at $(date '+%Y-%m-%d %H:%M:%S')"
python -m jupyter nbconvert \
--to html \
--execute \
--ExecutePreprocessor.timeout=600 \
"${{ matrix.notebook }}"
exit_code=$?
end_time=$(date +%s)
elapsed=$((end_time - start_time))
if [ $exit_code -eq 0 ]; then
echo "✓ PASSED in ${elapsed}s"
echo "Completed at $(date '+%Y-%m-%d %H:%M:%S')"
else
echo "✗ FAILED after ${elapsed}s"
exit $exit_code
fi
env:
IONQ_API_KEY: ${{ secrets.IONQ_API_KEY }}
- name: Upload execution artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: notebook-output-${{ hashFiles(matrix.notebook) }}
path: |
**/*.html
retention-days: 7
summary:
name: Test Summary
needs: test
runs-on: ubuntu-22.04
if: always()
steps:
- name: Summary
run: |
echo "=================================================="
echo "Test Execution Complete"
echo "=================================================="
if [ "${{ needs.test.result }}" == "success" ]; then
echo "✓ All notebook tests passed successfully!"
else
echo "✗ Some tests failed. Check individual job logs for details."
exit 1
fi