Skip to content

Commit 08e4a2d

Browse files
Merge pull request #292 from JohnGriffiths/add-smart-ci-buildcache
Add smart ci buildcache
2 parents 8f5dbde + 9ac5509 commit 08e4a2d

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

.github/workflows/docs.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,70 @@ jobs:
1010
build:
1111
runs-on: ubuntu-22.04
1212
steps:
13-
- uses: actions/checkout@v3
13+
- name: Checkout repo
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
1418
- name: Set up Python
1519
uses: actions/setup-python@v4
1620
with:
1721
python-version: 3.8
22+
1823
- name: Install dependencies
1924
run: |
2025
make install-deps-apt
2126
python -m pip install --upgrade pip wheel
2227
python -m pip install attrdict
2328
2429
make install-deps-wxpython
30+
2531
- name: Build project
2632
run: |
2733
make install-docs-build-dependencies
2834
35+
36+
- name: Get list of changed files
37+
id: changes
38+
run: |
39+
git fetch origin master
40+
git diff --name-only origin/master...HEAD > changed_files.txt
41+
cat changed_files.txt
42+
43+
44+
- name: Determine build mode
45+
id: mode
46+
run: |
47+
if grep -vqE '^examples/.*\.py$' changed_files.txt; then
48+
echo "FULL_BUILD=true" >> $GITHUB_ENV
49+
echo "Detected non-example file change. Full build triggered."
50+
else
51+
CHANGED_EXAMPLES=$(grep '^examples/.*\.py$' changed_files.txt | paste -sd '|' -)
52+
echo "FULL_BUILD=false" >> $GITHUB_ENV
53+
echo "CHANGED_EXAMPLES=$CHANGED_EXAMPLES" >> $GITHUB_ENV
54+
echo "Changed examples: $CHANGED_EXAMPLES"
55+
fi
56+
57+
58+
- name: Cache built documentation
59+
id: cache-docs
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
doc/_build/html
64+
key: ${{ runner.os }}-sphinx-${{ hashFiles('examples/**/*.py', 'doc/**/*', 'conf.py') }}
65+
restore-keys: |
66+
${{ runner.os }}-sphinx-
67+
68+
2969
- name: Build docs
3070
run: |
3171
make docs
72+
73+
3274
- name: Deploy Docs
3375
uses: peaceiris/actions-gh-pages@v3
3476
if: github.ref == 'refs/heads/master' # TODO: Deploy seperate develop-version of docs?
3577
with:
3678
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
publish_dir: doc/_build/html
79+
publish_dir: doc/_build/html

doc/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,19 @@ def setup(app):
288288
}
289289
290290
"""
291+
292+
import os
293+
294+
changed_examples = os.getenv('CHANGED_EXAMPLES')
295+
full_build = os.getenv('FULL_BUILD', 'true').lower() == 'true'
296+
297+
if not full_build and changed_examples:
298+
print(f"Only building examples matching: {changed_examples}")
299+
sphinx_gallery_conf.update({
300+
'filename_pattern': changed_examples,
301+
})
302+
else:
303+
print("Building all examples (full build).")
304+
sphinx_gallery_conf.update({
305+
'filename_pattern': '(?=.*r__)(?=.*.py)', # r'.*\.py',
306+
})

examples/visual_n170/01r__n170_viz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
# reordering of epochs.ch_names according to [[0,2],[1,3]] of subplot axes
111111

112112
# Manually adjust the ylims
113-
for i in [0,2]: ax[i].set_ylim([-0.5e6,0.5e6])
114-
for i in [1,3]: ax[i].set_ylim([-1.5e6,2.5e6])
113+
#for i in [0,2]: ax[i].set_ylim([-0.5e6,0.5e6])
114+
#for i in [1,3]: ax[i].set_ylim([-1.5e6,2.5e6])
115115
plt.tight_layout()
116116

0 commit comments

Comments
 (0)