From f7d9a9cf432fe5d9e41fa7f236437a0a86832fa0 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Mon, 29 Jul 2024 14:45:13 -0700 Subject: [PATCH] Adds CI action validating new notebooks --- .github/workflows/validate_new_notebooks.yml | 29 ++++++++++++++ docs/core_docs/docs/how_to/testing.ipynb | 42 ++++++++++++++++++++ docs/core_docs/scripts/quarto-build.js | 2 +- package.json | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/validate_new_notebooks.yml create mode 100644 docs/core_docs/docs/how_to/testing.ipynb diff --git a/.github/workflows/validate_new_notebooks.yml b/.github/workflows/validate_new_notebooks.yml new file mode 100644 index 000000000000..e1932e8ca7cb --- /dev/null +++ b/.github/workflows/validate_new_notebooks.yml @@ -0,0 +1,29 @@ +name: Validate new notebooks + +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: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + - name: Validate new notebooks + run: | + new_notebooks=$(echo ${{ steps.changed-files.outputs.added_files }} | tr ' ' '\n' | grep '\.ipynb$') + if [ -n "$new_notebooks" ]; then + for notebook in $new_notebooks; do + yarn notebook:validate "$notebook" + done + fi \ No newline at end of file diff --git a/docs/core_docs/docs/how_to/testing.ipynb b/docs/core_docs/docs/how_to/testing.ipynb new file mode 100644 index 000000000000..fc014c0a0c8d --- /dev/null +++ b/docs/core_docs/docs/how_to/testing.ipynb @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "const thingy = \"mabob\";\n", + "\n", + "thingythingy;" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "TypeScript", + "language": "typescript", + "name": "tslab" + }, + "language_info": { + "codemirror_mode": { + "mode": "typescript", + "name": "javascript", + "typescript": true + }, + "file_extension": ".ts", + "mimetype": "text/typescript", + "name": "typescript", + "version": "3.7.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/core_docs/scripts/quarto-build.js b/docs/core_docs/scripts/quarto-build.js index 9397d972b592..e502be91dd7d 100644 --- a/docs/core_docs/scripts/quarto-build.js +++ b/docs/core_docs/scripts/quarto-build.js @@ -2,7 +2,7 @@ const fs = require("node:fs"); const { glob } = require("glob"); const { execSync } = require("node:child_process"); -const IGNORED_CELL_REGEX = /```\w*?\n\/\/ ?@ls-docs-hide-cell\n[\s\S]*?```/g; +const IGNORED_CELL_REGEX = /```\w*?\n\/\/ ?@lc-docs-hide-cell\n[\s\S]*?```/g; async function main() { const allIpynb = await glob("./docs/**/*.ipynb"); diff --git a/package.json b/package.json index 7c45191ba7be..1f8124266a93 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "test:standard:int": "turbo test:standard:int", "test:standard": "yarn test:standard:unit && yarn test:standard:int", "example": "yarn workspace examples start", + "notebook:validate": "yarn workspace core_docs validate", "precommit": "turbo precommit", "docs": "yarn workspace core_docs start", "docs:api_refs": "yarn workspace api_refs start",