-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·42 lines (35 loc) · 1.2 KB
/
test.sh
File metadata and controls
executable file
·42 lines (35 loc) · 1.2 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
#!/bin/bash
# Collect converted ipynb files to clean up at the end.
notebook_files=()
# Find Markdown files convert.
all_markdown_files=$(find tutorials -type f -name "*.md")
if [ $# -gt 0 ]; then
files_to_process="$@"
else
files_to_process=$all_markdown_files
fi
# Identify Markdown files that are Jupytext and convert them all.
for file in ${files_to_process}; do
echo loop in $file
# Extract the kernel information from the Jupytext Markdown file.
kernel_info=$(grep -A 10 '^---$' "$file" | grep -E 'kernelspec')
# Skip if no kernel information was found.
if [ -z "$kernel_info" ]; then
continue
fi
# Convert to ipynb format, to be consumed by pytest nbval plugin.
jupytext --to ipynb "$file"
notebook_file="${file%.md}.ipynb"
# Stash file in array to be cleaned up at the end.
notebook_files+=("${notebook_file}")
done
pytest --nbval-lax -vv --suppress-no-test-exit-code --durations=10
_exitval="$?"
if [[ $_exitval > 0 ]]; then
exit $_exitval
fi
# Clean up ipynb files that were converted. Any stray ipynb files that were
# _not_ the result of conversion from Markdown will be left alone.
for file in "${notebook_files[@]}"; do
rm -v "$file"
done