From 948c3510d9fbf183c6bea8fd47c6a54f847f5926 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Mon, 23 Sep 2024 23:43:59 -0400 Subject: [PATCH] Add CI action to run tests on push (#26) * Add CI action to run tests on push * Import syntax highlights from cjs instead of esm directory Fixes jest syntax errors See https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/230#issuecomment-568377353 --- .github/workflows/test.yml | 26 ++++++++++++++++++++++++++ src/ui/command/CommandGroupEditor.tsx | 2 +- src/ui/robot/Robot.tsx | 2 +- src/ui/subsystem/Subsystem.tsx | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3b058e8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Tests + +on: + - push + +jobs: + Test: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install Nodejs + uses: actions/setup-node@v4 + with: + node-version-file: '.tool-versions' + cache: 'npm' + cache-dependency-path: 'package-lock.json' + + - name: Install Packages + run: | + npm ci + + - name: Run Tests + run: | + npm run test diff --git a/src/ui/command/CommandGroupEditor.tsx b/src/ui/command/CommandGroupEditor.tsx index 8fb0dd7..9e647c2 100644 --- a/src/ui/command/CommandGroupEditor.tsx +++ b/src/ui/command/CommandGroupEditor.tsx @@ -4,7 +4,7 @@ import { Button } from "@mui/material" import { entryType } from "./groupeditor/StageEditor" import EditableLabel from "../EditableLabel" import SyntaxHighlighter from "react-syntax-highlighter" -import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/esm/styles/hljs" +import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/cjs/styles/hljs" import { commandMethod } from "../../codegen/java/CommandGroupGenerator" import { editorGroupToIR } from "./Commands" import * as IR from "../../bindings/ir" diff --git a/src/ui/robot/Robot.tsx b/src/ui/robot/Robot.tsx index 613feee..f8da74e 100644 --- a/src/ui/robot/Robot.tsx +++ b/src/ui/robot/Robot.tsx @@ -3,7 +3,7 @@ import { Project } from "../../bindings/Project" import { generateRobotClass } from "../../codegen/java/RobotGenerator" import { Box } from "@mui/material" import SyntaxHighlighter from "react-syntax-highlighter" -import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/esm/styles/hljs" +import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/cjs/styles/hljs" export function Robot({ project }: { project: Project }) { const [generatedCode, setGeneratedCode] = useState(generateRobotClass(project)) diff --git a/src/ui/subsystem/Subsystem.tsx b/src/ui/subsystem/Subsystem.tsx index 5aa6a4c..9209d30 100644 --- a/src/ui/subsystem/Subsystem.tsx +++ b/src/ui/subsystem/Subsystem.tsx @@ -39,7 +39,7 @@ import React, { CSSProperties, useEffect, useState } from "react" import Menu from "@mui/material/Menu" import MenuItem from "@mui/material/MenuItem" import SyntaxHighlighter from "react-syntax-highlighter" -import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/esm/styles/hljs" +import * as SyntaxHighlightStyles from "react-syntax-highlighter/dist/cjs/styles/hljs" import { ComponentDefinition, MethodDefinition, ParameterDefinition } from "../../components/ComponentDefinition" import { generateCommand } from "../../codegen/java/CommandGenerator" import { generateSubsystem } from "../../codegen/java/SubsystemGenerator"