diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e89256a..9753e1d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,6 +13,7 @@ permissions: jobs: build: + name: Build Scramjet runs-on: ubuntu-latest steps: @@ -59,11 +60,45 @@ jobs: path: | dist/*.js dist/*.js.map + tests: + name: Run Scramjet Tests + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: latest + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Get artifacts + uses: actions/download-artifact@v4 + with: + name: scramjet + path: dist + + - name: Install Playwright Browsers + run: npx playwright install --with-deps + + - name: Install dependencies + run: pnpm test upload: name: Upload Release runs-on: ubuntu-latest - needs: build + needs: [build, tests] permissions: write-all if: github.ref == 'refs/heads/main' @@ -94,7 +129,7 @@ jobs: pages: name: Upload to Github Pages runs-on: ubuntu-latest - needs: build + needs: [build, tests] if: github.ref == 'refs/heads/main' steps: - name: Checkout code diff --git a/playwright.config.ts b/playwright.config.ts index b7315d6..f945d80 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -8,7 +8,7 @@ export default defineConfig({ fullyParallel: true, forbidOnly: !!process.env.CI, retries: 2, - reporter: "html", + reporter: process.env.CI ? "github" : "html", timeout: 20000, /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { diff --git a/server.js b/server.js index 7ede0ed..b040922 100644 --- a/server.js +++ b/server.js @@ -85,24 +85,25 @@ fastify.listen({ host: "0.0.0.0", }); console.log(`Listening on port ${PORT}`); +if (!process.env.CI) { + try { + writeFileSync( + ".git/hooks/pre-commit", + "pnpm prettier . -w\ngit update-index --again" + ); + chmodSync(".git/hooks/pre-commit", 0o755); + } catch {} -try { - writeFileSync( - ".git/hooks/pre-commit", - "pnpm prettier . -w\ngit update-index --again" - ); - chmodSync(".git/hooks/pre-commit", 0o755); -} catch {} + const watch = spawn("pnpm", ["rspack", "-w"], { + detached: true, + cwd: process.cwd(), + }); -const watch = spawn("pnpm", ["rspack", "-w"], { - detached: true, - cwd: process.cwd(), -}); + watch.stdout.on("data", (data) => { + console.log(`${data}`); + }); -watch.stdout.on("data", (data) => { - console.log(`${data}`); -}); - -watch.stderr.on("data", (data) => { - console.log(`${data}`); -}); + watch.stderr.on("data", (data) => { + console.log(`${data}`); + }); +}