CI #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI | |
# 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 | |
env: | |
NODE_VERSION: "22.4.1" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Build | |
run: yarn build | |
lint: | |
name: Check linting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Check linting | |
run: yarn run lint | |
format: | |
name: Check formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Check formatting | |
run: yarn run format:check | |
test: | |
name: Unit Tests | |
strategy: | |
matrix: | |
# See Node.js release schedule at https://nodejs.org/en/about/releases/ | |
os: [ubuntu-latest] | |
node-version: [18.x, 20.x, "22.4.1"] | |
include: | |
- os: windows-latest | |
node-version: "22.4.1" | |
- os: macos-latest | |
node-version: "22.4.1" | |
runs-on: ${{ matrix.os }} | |
env: | |
PUPPETEER_SKIP_DOWNLOAD: "true" | |
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" | |
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: Test | |
run: yarn run test | |
check-readmes-synced: | |
# This checks that the repo README.md is identical to the libs/langgraph/README.md | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Check README.md is in sync | |
run: | | |
if ! diff -q README.md libs/langgraph/README.md >/dev/null; then | |
echo "README.md is out of sync with langgraph/README.md" | |
diff -C 3 README.md langgraph/README.md | |
exit 1 | |
fi | |
validate-dep-files: | |
name: Validate Deno and Node dependencies in sync | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v44 | |
- name: Check for deno.json changes | |
id: check_deno_json | |
run: | | |
deno_json=$(echo '${{ steps.changed_files.outputs.all_changed_files }}' | tr ' ' '\n' | grep -E '^./deno.json$' || true) | |
echo "has_deno_json_changes=$([ -n "$deno_json" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
if: steps.check_deno_json.outputs.has_deno_json_changes == 'true' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Install dependencies | |
if: steps.check_deno_json.outputs.has_deno_json_changes == 'true' | |
run: yarn install --immutable | |
- name: Validate | |
if: steps.check_deno_json.outputs.has_deno_json_changes == 'true' | |
run: yarn tsx --experimental-wasm-modules ./scripts/validate_deps_sync.ts | |
validate-new-notebooks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Use Node.js ${{ env.NODE_VERSION }} | |
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Install dependencies | |
if: steps.check_notebooks.outputs.has_affected_notebooks == 'true' | |
run: yarn install --immutable | |
- 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 ./libs/langgraph | |
for notebook in $notebooks; do | |
absolute_path="$GITHUB_WORKSPACE/$notebook" | |
yarn notebook_validate "$absolute_path" | |
done | |
else | |
echo "No notebooks to validate." | |
fi |