Skip to content

Commit 58f95db

Browse files
committed
Update CI workflow for nbfmt and nblint
1 parent f339bf4 commit 58f95db

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
# Pass/fail checks for continuous integration testing.
2+
# Webhook events: Pull requests
13
name: CI
2-
on: pull_request
4+
on:
5+
pull_request:
6+
paths:
7+
- "site/en/**"
38

49
jobs:
5-
notebook_format:
10+
nbfmt:
611
name: Notebook format
712
runs-on: ubuntu-latest
813
steps:
@@ -15,10 +20,34 @@ jobs:
1520
- name: Check notebook formatting
1621
run: |
1722
# Only check notebooks modified in this pull request.
18-
notebooks="$(git diff --name-only master | grep '\.ipynb$' || true)"
19-
if [[ -n "$notebooks" ]]; then
20-
echo "Check formatting with nbfmt:"
21-
python3 -m tensorflow_docs.tools.nbfmt --test $notebooks
23+
readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true)
24+
if [[ ${#changed_notebooks[@]} == 0 ]]; then
25+
echo "No notebooks modified in this pull request."
26+
exit 0
2227
else
28+
echo "Check formatting with nbfmt:"
29+
python3 -m tensorflow_docs.tools.nbfmt --test "${changed_notebooks[@]}"
30+
fi
31+
32+
nblint:
33+
name: Notebook lint
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/setup-python@v1
37+
- uses: actions/checkout@v2
38+
- name: Fetch master branch
39+
run: git fetch -u origin master:master
40+
- name: Install tensorflow-docs
41+
run: python3 -m pip install -U git+https://github.com/tensorflow/docs
42+
- name: Lint notebooks
43+
run: |
44+
# Only check notebooks modified in this pull request. (Ignore en-snapshot)
45+
readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true)
46+
if [[ ${#changed_notebooks[@]} == 0 ]]; then
2347
echo "No notebooks modified in this pull request."
48+
exit 0
49+
else
50+
echo "Lint check with nblint:"
51+
python3 -m tensorflow_docs.tools.nblint \
52+
--arg=repo:tensorflow/docs "${changed_notebooks[@]}"
2453
fi

0 commit comments

Comments
 (0)