-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (63 loc) · 2.05 KB
/
CheckNotebooks.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
name: Check notebooks
on:
push:
branches:
- main
tags: '*'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version: ['lts', '1']
os: [ubuntu-latest]
arch: [x64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Update pip
run: python -m pip install -U pip
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Install nbconvert
run: python -m pip install nbconvert
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
env:
PYTHON: python
# Convert notebooks to .jl files using nbconvert
- name: Convert Notebooks to Julia Scripts
run: |
for notebook in $(find notebooks -name "*.ipynb"); do
echo "Converting $notebook to Julia script"
jupyter nbconvert --to script "$notebook" --output-dir=.
done
# Update HOME variable in nb => .jl scripts
# HOME = "../.." => "."
- name: Update Paths in Converted Julia Scripts
run: |
for script in $(find . -maxdepth 1 -name "*.jl"); do
echo "Updating paths in $script"
sed -i 's|\.\./\.\.|.|g' "$script"
done
# Run converted .jl files using Julia
- name: Run Julia Scripts
run: |
EXIT_CODE=0
for script in $(find . -maxdepth 1 -name "*.jl"); do
echo "Running Julia script: $script"
julia --project=. "$script" || EXIT_CODE=$?
done
exit $EXIT_CODE