From 4fa98faedc654a8ed5bc3b1380cba6aff17c10fe Mon Sep 17 00:00:00 2001 From: Kevin Barabash Date: Sat, 28 Dec 2024 20:24:54 -0500 Subject: [PATCH 1/3] Create py.yml workflow file --- .github/workflows/pr.yml | 89 ++++++++++++++++++++++++++++++++++++++++ .gitmodules | 3 ++ eslint.config.js | 26 ++++++------ math-blocks | 1 + src/homepage.tsx | 25 +++++++++++ src/index.tsx | 35 ++-------------- src/not-found.tsx | 9 ++++ 7 files changed, 144 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 .gitmodules create mode 160000 math-blocks create mode 100644 src/homepage.tsx create mode 100644 src/not-found.tsx diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..a5e240e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,89 @@ +name: Node CI + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + env: + CI: true + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v4 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Cache node modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-node_modules- + - name: yarn install + run: yarn install + - name: lint + run: yarn lint + + build: + runs-on: ubuntu-latest + env: + CI: true + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v4 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Cache node modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-node_modules- + - name: yarn install + run: yarn install + - name: yarn build + run: yarn build + + docs: + runs-on: ubuntu-latest + env: + CI: true + steps: + - uses: actions/checkout@v4 + with: + submodules: "true" + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + - name: yarn install + working-directory: math-blocks + run: yarn install + - name: yarn typedoc + working-directory: math-blocks + run: yarn typedoc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..df2b9be --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "math-blocks"] + path = math-blocks + url = git@github.com:math-blocks/math-blocks.git diff --git a/eslint.config.js b/eslint.config.js index 092408a..31db88a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,28 +1,28 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; export default tseslint.config( - { ignores: ['dist'] }, + { ignores: ["dist", "math-blocks"] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], + files: ["**/*.{ts,tsx}"], languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, + "react-hooks": reactHooks, + "react-refresh": reactRefresh, }, rules: { ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', + "react-refresh/only-export-components": [ + "warn", { allowConstantExport: true }, ], }, - }, -) + } +); diff --git a/math-blocks b/math-blocks new file mode 160000 index 0000000..71cc61a --- /dev/null +++ b/math-blocks @@ -0,0 +1 @@ +Subproject commit 71cc61aa9db3e4440296550494140d907aa3ba17 diff --git a/src/homepage.tsx b/src/homepage.tsx new file mode 100644 index 0000000..ca4aee4 --- /dev/null +++ b/src/homepage.tsx @@ -0,0 +1,25 @@ +import { Link } from "react-router-dom"; + +const Homepage = () => { + return ( +
+

MathBlocks Demos

+ +
+ ); +}; + +export default Homepage; diff --git a/src/index.tsx b/src/index.tsx index ac1fc9d..aac5d28 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,8 @@ import { createRoot } from "react-dom/client"; -import { createHashRouter, RouterProvider, Link } from "react-router-dom"; +import { createHashRouter, RouterProvider } from "react-router-dom"; + +import Homepage from "./homepage"; +import NotFound from "./not-found"; import BaselinePage from "./baseline/baseline-page"; import EditorPage from "./editor/editor-page"; @@ -12,36 +15,6 @@ if (document.body) { document.body.appendChild(container); } -const Homepage = () => { - return ( -
-

MathBlocks Demos

- -
- ); -}; - -const NotFound = () => { - return ( -
-

404: Not Found

-
- ); -}; - const router = createHashRouter([ { path: "/", diff --git a/src/not-found.tsx b/src/not-found.tsx new file mode 100644 index 0000000..283a33d --- /dev/null +++ b/src/not-found.tsx @@ -0,0 +1,9 @@ +const NotFound = () => { + return ( +
+

404: Not Found

+
+ ); +}; + +export default NotFound; From fe9d49ae424ed8308eb113f49d14752da81d7b48 Mon Sep 17 00:00:00 2001 From: Kevin Barabash Date: Sat, 28 Dec 2024 20:30:15 -0500 Subject: [PATCH 2/3] run build-tsc before running typedoc --- .github/workflows/pr.yml | 3 +++ .gitignore | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a5e240e..860b598 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -84,6 +84,9 @@ jobs: - name: yarn install working-directory: math-blocks run: yarn install + - name: yarn build-tsc + working-directory: math-blocks + run: yarn build-tsc - name: yarn typedoc working-directory: math-blocks run: yarn typedoc diff --git a/.gitignore b/.gitignore index a0b4026..76b35e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules dist +.buildcache .vscode .DS_Store .vite From ef29963b6f36a50855d4a43cf7d5ed0cc93bcaf4 Mon Sep 17 00:00:00 2001 From: Kevin Barabash Date: Sat, 28 Dec 2024 20:42:01 -0500 Subject: [PATCH 3/3] Update deploy.yml to include docs --- .github/workflows/deploy.yml | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c73cc92..2802382 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,7 +4,37 @@ on: - main jobs: + docs: + runs-on: ubuntu-latest + env: + CI: true + steps: + - uses: actions/checkout@v4 + with: + submodules: "true" + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + - name: yarn install + working-directory: math-blocks + run: yarn install + - name: yarn build-tsc + working-directory: math-blocks + run: yarn build-tsc + - name: yarn typedoc + working-directory: math-blocks + run: yarn typedoc + - name: Upload Docs artifact + uses: actions/upload-pages-artifact@v4 + with: + path: ./docs/ + name: docs + build: + needs: docs + permissions: + actions: read # to access artifacts from the build job runs-on: ubuntu-latest env: CI: true @@ -34,8 +64,13 @@ jobs: run: yarn install --frozen-lockfile - name: yarn build run: yarn build + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: docs + path: ./dist/docs - name: Upload Page Artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: ./dist/