1
+ # Pass/fail checks for continuous integration testing.
2
+ # Webhook events: Pull requests
1
3
name : CI
2
- on : pull_request
4
+ on :
5
+ pull_request :
6
+ paths :
7
+ - " site/en/**"
3
8
4
9
jobs :
5
- notebook_format :
10
+ nbfmt :
6
11
name : Notebook format
7
12
runs-on : ubuntu-latest
8
13
steps :
@@ -15,10 +20,34 @@ jobs:
15
20
- name : Check notebook formatting
16
21
run : |
17
22
# 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
22
27
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
23
47
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[@]}"
24
53
fi
0 commit comments