From 948bf6076d5b5df0108886817ab9331d50bb3db0 Mon Sep 17 00:00:00 2001 From: syldium Date: Sat, 16 Mar 2024 14:07:23 +0100 Subject: [PATCH] build(tests): run them in GHA --- .github/workflows/build.yml | 25 ++++++++++++------------- dprint.json | 2 +- src/main/context/GameRegistry.tsx | 16 +++++++++++----- vite.config.ts | 5 +++-- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07c5ae4..881fcc0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,24 @@ -name: Build and Deploy +name: Build on: push: branches: - - main + - v1 + pull_request: jobs: - build-and-deploy: + build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 with: - persist-credentials: false + version: 8 - name: Install and build run: | - yarn - yarn build + pnpm install + pnpm build - - name: Deploy - uses: JamesIves/github-pages-deploy-action@4.1.4 - with: - branch: gh-pages - folder: dist + - name: Test + run: | + pnpm test run diff --git a/dprint.json b/dprint.json index f6201e7..1812752 100644 --- a/dprint.json +++ b/dprint.json @@ -12,7 +12,7 @@ }, "json": { }, - "includes": ["src/**/*.{ts,tsx,js,jsx,cjs,mjs,json}"], + "includes": ["src/**/*.{ts,tsx,js,jsx,cjs,mjs,json}", "*.js", "*.ts"], "excludes": [ "**/node_modules", "**/*-lock.json", diff --git a/src/main/context/GameRegistry.tsx b/src/main/context/GameRegistry.tsx index 120466a..7bde159 100644 --- a/src/main/context/GameRegistry.tsx +++ b/src/main/context/GameRegistry.tsx @@ -118,6 +118,11 @@ export function GameRegistryProvider({ if (holder && (version === fetched.current || import.meta.env.SSR)) { holder.withVanilla(vanilla); } + if (states) { + const registry = new Registry(Object.keys(states).map(labelizeOption)); + holder!.game.block = registry; + holder!.game.block_state = registry; + } useEffect(() => { if (!window.indexedDB || !holder) { @@ -154,11 +159,12 @@ export function GameRegistryProvider({ const entries: [string, Schema][] = []; for (const [registryKey, registry] of holder.entries) { entries.push( - // @ts-ignore - ...Object.entries(registry.entries).map(([key, schema]) => [ - resourcePath(registryKey, key), - schema - ]) + ...Object.entries(registry.entries).map(([key, schema]) => + [ + resourcePath(registryKey, key), + schema + ] as [string, Schema] + ) ); } setMany(entries).then(() => diff --git a/vite.config.ts b/vite.config.ts index e9c9cd6..4aefc72 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,10 +10,11 @@ export default defineConfig({ test: { globals: true, environment: 'jsdom', - setupFiles: './src/setupTests.ts' + setupFiles: './src/setupTests.ts', + isolate: false }, plugins: [ - react(), + react() ], ssr: { noExternal: [