Skip to content

[docs] Basic tutorial: Vector stores and retrievers #1322

[docs] Basic tutorial: Vector stores and retrievers

[docs] Basic tutorial: Vector stores and retrievers #1322

name: Validate new notebooks
# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
#
# There's no point in testing an outdated version of the code. GitHub only allows
# a limited number of job runners to be active at the same time, so it's better to cancel
# pointless jobs early so that more useful jobs can run sooner.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- 'docs/core_docs/**'
workflow_dispatch:
jobs:
validate-new-notebooks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
- name: Check for new or modified notebooks in docs/core_docs
id: check_notebooks
run: |
notebooks=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | tr ' ' '\n' | grep '^docs/core_docs/.*\.ipynb$' || true)
echo "Affected notebooks: $notebooks"
echo "has_affected_notebooks=$([ -n "$notebooks" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
- name: Build examples
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true'
run: yarn turbo:command build --filter=examples
- name: Validate affected notebooks in docs/core_docs
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true'
run: |
notebooks=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | tr ' ' '\n' | grep '^docs/core_docs/.*\.ipynb$' || true)
if [ -n "$notebooks" ]; then
failed_notebooks=()
for notebook in $notebooks; do
absolute_path="$GITHUB_WORKSPACE/$notebook"
set +e
yarn workspace @langchain/scripts notebook_validate "$absolute_path"
if [ $? -ne 0 ]; then
failed_notebooks+=("$notebook")
fi
set -e
done
if [ ${#failed_notebooks[@]} -ne 0 ]; then
echo "The following notebooks failed validation:"
printf '%s\n' "${failed_notebooks[@]}"
exit 1
fi
else
echo "No notebooks in docs/core_docs to validate."
fi