From 79df3079f70b6f21d05e6cdfec469a715553a89e Mon Sep 17 00:00:00 2001 From: Eli <78963198+niceEli@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:44:43 -0400 Subject: [PATCH] faster tests :D --- .github/workflows/test.yml | 2 +- examples/ciTest.json | 57 ++++++++++++++++++++++++++++++++++++++ scripts/test.js | 23 +++++++++++---- 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 examples/ciTest.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0a95068..420f2d8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,4 +23,4 @@ jobs: - name: Run Checker run: pnpm run check - name: Run tests - run: pnpm run test + run: pnpm run test -c diff --git a/examples/ciTest.json b/examples/ciTest.json new file mode 100644 index 00000000..0af133af --- /dev/null +++ b/examples/ciTest.json @@ -0,0 +1,57 @@ +{ + "order": [ + "add", + "movement", + "collision", + "gravity", + "sprite", + "fadeIn", + "text", + "audio", + "level", + "scenes", + "timer", + "component", + "layer", + "layers", + "query", + "camera", + "ai", + "loader", + "button", + "dialog", + "draw", + "shader", + "children", + "concert", + "doublejump", + "drag", + "hover", + "largeTexture", + "maze", + "mazeRaycastedLight", + "multiboom", + "multigamepad", + "out", + "overlap", + "pauseMenu", + "polygon", + "polygonuv", + "linecap", + "linejoin", + "postEffect", + "rect", + "transformShape", + "raycastShape", + "raycastObject", + "curves", + "size", + "slice9", + "spriteatlas", + "tween", + "easing", + "bench", + "gamepad", + "binding" + ] +} diff --git a/scripts/test.js b/scripts/test.js index 452fe63a..5362eca2 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -2,6 +2,11 @@ import fs from "fs/promises"; import path from "path"; import puppeteer from "puppeteer"; import { build, serve, wait } from "./lib.js"; +const exampleCI = JSON.parse( + await fs.readFile( + new URL('../examples/ciTest.json', import.meta.url) + ) +); await build(); const port = process.env.PORT || 8001; @@ -11,12 +16,20 @@ let failed = false; console.log("launching browser"); const browser = await puppeteer.launch(); console.log("getting examples list"); -const examples = (await fs.readdir("examples")) - .filter((p) => !p.startsWith(".") && p.endsWith(".js")) - .map((d) => path.basename(d, ".js")) - // particle example crashes puppeteer in github action for some reason - .filter((e) => e !== "particle"); +let examples +if (process.argv[2] === "--ci" || process.argv[2] === "-c") { + console.log("Testing For Github CI"); + examples = exampleCI.order; +} +else{ + console.log("Testing For Local Development"); + examples = (await fs.readdir("examples")) + .filter((p) => !p.startsWith(".") && p.endsWith(".js")) + .map((d) => path.basename(d, ".js")) + // particle example crashes puppeteer in github action for some reason + .filter((e) => e !== "particle"); +} for (const example of examples) { console.log(`testing example "${example}"`); const page = await browser.newPage();