Skip to content

Commit

Permalink
ci[minor]: Add validate notebooks GH action (#321)
Browse files Browse the repository at this point in the history
* ci[minor]: Add validate notebooks GH action

* update cmd to look inside examples too

* cr

* add examples package.json

* cr
  • Loading branch information
bracesproul authored Aug 16, 2024
1 parent 35669d8 commit 3ba0a66
Show file tree
Hide file tree
Showing 5 changed files with 953 additions and 53 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/validate-new-notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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/docs/**'
- 'examples/**'
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
id: check_notebooks
run: |
notebooks=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | tr ' ' '\n' | grep -E '^(docs/docs|examples)/.*\.ipynb$' || true)
echo "Affected notebooks: $notebooks"
echo "has_affected_notebooks=$([ -n "$notebooks" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
- name: Build LangGraph
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true'
run: yarn build
- name: Validate affected notebooks
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true'
run: |
notebooks=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | tr ' ' '\n' | grep -E '^(docs/docs|examples)/.*\.ipynb$' || true)
if [ -n "$notebooks" ]; then
cd ./langgraph
for notebook in $notebooks; do
absolute_path="$GITHUB_WORKSPACE/$notebook"
yarn notebook_validate "$absolute_path"
done
else
echo "No notebooks to validate."
fi
24 changes: 24 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "examples",
"description": "Dependencies for LangGraph examples.",
"devDependencies": {
"@langchain/anthropic": "^0.2.15",
"@langchain/cloudflare": "^0.0.7",
"@langchain/community": "^0.2.27",
"@langchain/core": "^0.2.24",
"@langchain/groq": "^0.0.16",
"@langchain/langgraph": "workspace:*",
"@langchain/mistralai": "^0.0.28",
"@langchain/openai": "^0.2.6",
"@xenova/transformers": "2.17.2",
"cheerio": "^1.0.0",
"chromadb": "^1.8.1",
"d3": "^7.9.0",
"dotenv": "^16.4.5",
"langchain": "^0.2.16",
"tslab": "^1.0.22",
"uuid": "^10.0.0",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.2"
}
}
2 changes: 1 addition & 1 deletion langgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@langchain/anthropic": "^0.2.12",
"@langchain/community": "^0.2.25",
"@langchain/openai": "^0.2.4",
"@langchain/scripts": "^0.0.19",
"@langchain/scripts": "^0.0.21",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"url": "[email protected]:langchain-ai/langgraphjs.git"
},
"workspaces": [
"langgraph"
"langgraph",
"examples"
],
"scripts": {
"build": "turbo run build",
Expand Down
Loading

0 comments on commit 3ba0a66

Please sign in to comment.