diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml new file mode 100644 index 000000000..bf5bb8508 --- /dev/null +++ b/.github/workflows/notebooks.yml @@ -0,0 +1,71 @@ +# Notebook-related checks + +name: Notebooks + +on: + # Relevant PRs + pull_request: + paths: + - "site/en/**" + # Allow manual runs + workflow_dispatch: + +jobs: + nbfmt: + name: Notebook format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - name: Install tensorflow-docs + run: python3 -m pip install -U git+https://github.com/tensorflow/docs + - name: Fetch master branch + run: git fetch -u origin main:main + - name: Check notebook formatting + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + # Only check notebooks modified in this pull request + readarray -t changed_notebooks < <(git diff --name-only main | grep '\.ipynb$' || true) + else + # Manual run, check everything + readarray -t changed_notebooks < <(find -name '*.ipynb') + fi + if [[ ${#changed_notebooks[@]} == 0 ]]; then + echo "No notebooks modified in this pull request." + exit 0 + else + echo "Check formatting with nbfmt:" + python3 -m tensorflow_docs.tools.nbfmt --test "${changed_notebooks[@]}" + fi + + nblint: + name: Notebook lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - name: Install tensorflow-docs + run: python3 -m pip install -U git+https://github.com/tensorflow/docs + - name: Fetch main branch + run: git fetch -u origin main:main + - name: Lint notebooks + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + # Only check notebooks modified in this pull request + readarray -t changed_notebooks < <(git diff --name-only main | grep '\.ipynb$' || true) + else + # Manual run, check everything + readarray -t changed_notebooks < <(find -name '*.ipynb') + fi + if [[ ${#changed_notebooks[@]} == 0 ]]; then + echo "No notebooks modified in this pull request." + exit 0 + else + echo "Lint check with nblint:" + python3 -m tensorflow_docs.tools.nblint \ + --styles=google,tensorflow \ + --arg=repo:google/generative-ai-docs --arg=branch:main \ + --exclude_lint=tensorflow::button_download \ + --exclude_lint=tensorflow::button_website \ + "${changed_notebooks[@]}" + fi diff --git a/site/en/examples/chat_calculator.ipynb b/site/en/examples/chat_calculator.ipynb index be3b4a8b9..d232e41d7 100644 --- a/site/en/examples/chat_calculator.ipynb +++ b/site/en/examples/chat_calculator.ipynb @@ -6,7 +6,7 @@ "id": "FS9T8jTqkZWI" }, "source": [ - "## Chat calculator" + "## Chat calculator [macd waz ere]" ] }, { diff --git a/site/en/examples/vectordb_with_chroma.ipynb b/site/en/examples/vectordb_with_chroma.ipynb index 3757bff29..513896352 100644 --- a/site/en/examples/vectordb_with_chroma.ipynb +++ b/site/en/examples/vectordb_with_chroma.ipynb @@ -6,7 +6,7 @@ "id": "Tce3stUlHN0L" }, "source": [ - "##### Copyright 2023 Google LLC." + "##### Copyright nobody, nowhere. TESTING TO SEE IF COPYRIGHT LINE IS DETECTED" ] }, {