From 5306c7b13949e70c00dd22d1ca861e9454db90d2 Mon Sep 17 00:00:00 2001 From: Walter Poch Date: Mon, 9 Feb 2026 10:52:29 -0500 Subject: [PATCH] Add free GitHub Actions CI for build and e2e tests --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++ package.json | 4 +++- tests/pr-screenshots.spec.js | 5 ++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..629f81d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build-and-e2e: + runs-on: ubuntu-latest + timeout-minutes: 25 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Install Playwright browser + run: npx playwright install --with-deps chromium + + - name: Run integration tests + run: npm run test:e2e:ci + + - name: Upload Playwright artifacts (failure only) + if: failure() + uses: actions/upload-artifact@v4 + with: + name: playwright-artifacts + path: | + playwright-report + test-results + if-no-files-found: ignore diff --git a/package.json b/package.json index 32f3675..7b2521f 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,10 @@ "build": "vite build", "preview": "vite preview", "test:e2e": "playwright test", + "test:e2e:ci": "playwright test tests/odontogram.e2e.spec.js", "test:e2e:headed": "playwright test --headed", - "test:e2e:ui": "playwright test --ui" + "test:e2e:ui": "playwright test --ui", + "screenshots:refresh": "CAPTURE_PR_SCREENSHOTS=1 playwright test tests/pr-screenshots.spec.js" }, "repository": { "type": "git", diff --git a/tests/pr-screenshots.spec.js b/tests/pr-screenshots.spec.js index 567bcd4..84b47de 100644 --- a/tests/pr-screenshots.spec.js +++ b/tests/pr-screenshots.spec.js @@ -1,5 +1,10 @@ import { test } from "@playwright/test"; +test.skip( + !process.env.CAPTURE_PR_SCREENSHOTS, + "Utility test only used when refreshing PR screenshots.", +); + test("capture PR screenshots", async ({ page }) => { await page.addInitScript(() => { window.localStorage.clear();