diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..f5aa37b --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,19 @@ +name: Setup +description: pnpm (the version in packageManager), Node 24 and the dependencies, as the lockfile pins them + +runs: + using: composite + steps: + # without `version`, it installs the one in package.json's packageManager + - name: Install pnpm + uses: pnpm/action-setup@v6 + + - name: Use Node.js 24 + uses: actions/setup-node@v7 + with: + node-version: 24 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1909f09 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: [main] + # every base, not only main: in a stack each pull request targets the branch below it + pull_request: + # release.yml runs it before publishing + workflow_call: + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + # a new push replaces the run of a pull request, never one of main + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + verify: + name: Lint, types, unit tests and builds + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/setup + + # `pnpm lint` writes the fixes: here it only checks + - name: Lint and format + run: pnpm exec biome check + + - name: Library (types and build) + run: pnpm build.types && pnpm build.lib + + - name: Unit tests + run: pnpm test.unit + + # the website imports the library built above, as Deno Deploy builds it + - name: Website (types and build) + run: pnpm -C website build.types && pnpm -C website build.client && pnpm -C website build.server + + e2e: + name: Playwright (${{ matrix.browser }}) + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + browser: [chromium, webkit] + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/setup + + - name: Playwright version + id: playwright + run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT" + + - name: Cache the browser + id: cache + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ matrix.browser }}-${{ steps.playwright.outputs.version }} + + - name: Install the browser and its system dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: pnpm exec playwright install --with-deps ${{ matrix.browser }} + + - name: Install the system dependencies of the cached browser + if: steps.cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps ${{ matrix.browser }} + + # the suite starts its own dev server, which renders the library from src/lib: no build needed + - name: Run the e2e tests + run: pnpm exec playwright test --project=${{ matrix.browser }} + + - name: Upload the report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v7 + with: + name: playwright-report-${{ matrix.browser }} + path: playwright-report/ + retention-days: 7 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a94657..fe497de 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,8 +42,8 @@ bite in this repo: - Qwik loads each event handler lazily and doesn't order handlers of different elements, nor, while it loads them and resumes the page, those of consecutive events: wait for one interaction to land before the next one. The calendar's keys don't need it: their `sync$` handlers queue them for `keys$`. -- WebKit, like Safari, only tabs to elements with an explicit `tabindex`, so tab order differs from - Chromium. +- WebKit on macOS, like Safari, only tabs to elements with an explicit `tabindex`, so tab order differs + from Chromium (and from WebKit on Linux, where the CI runs it): don't count Tab presses per browser. - The Qwik v2 dev server hangs on an error thrown while rendering, so cover invalid input with unit tests instead of fixture pages. @@ -63,5 +63,8 @@ pnpm exec biome check # lint and format (`pnpm lint` applies the fi pnpm test ``` +The CI (`.github/workflows/ci.yml`) runs the same on every pull request, whatever its base (in a stack, +each one targets the branch below), and builds the website too. It runs on Linux and in UTC. + Commits follow [Conventional Commits](https://www.conventionalcommits.org/) with a gitmoji, like the history: `fix(styled): 🐛 keep the focus on the month buttons after changing month`. diff --git a/package.json b/package.json index 8fafd7e..d869979 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "engines": { "node": "^20.19.0 || >=22.12.0" }, + "packageManager": "pnpm@12.15.0", "private": false, "type": "module", "scripts": { diff --git a/playwright.config.ts b/playwright.config.ts index a8af6b5..3979882 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -7,7 +7,8 @@ export default defineConfig({ testDir: './tests/e2e', fullyParallel: true, forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 0, + // one retry in CI, for a slow runner: the report marks what only passed on it as flaky, so it doesn't go unseen + retries: process.env.CI ? 1 : 0, reporter: process.env.CI ? [['github'], ['html', { open: 'never' }]] : 'list', use: { baseURL: `http://localhost:${PORT}`, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b0768b5..b5677b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,3 +1,161 @@ +--- +lockfileVersion: '9.0' + +importers: + + .: + configDependencies: {} + packageManagerDependencies: + pnpm: + specifier: 12.15.0 + version: 12.15.0 + +packages: + + '@pnpm/exe.android-arm64@12.15.0': + resolution: {integrity: sha512-eVCqmscY70LGvgRzu3mi8IBWBFGix+a6mNZoWmXxESsBdeiKEF9xQSuaeel10yn+zI7TXy2jlI63vFLzETk+aQ==} + cpu: [arm64] + os: [android] + + '@pnpm/exe.android-x64@12.15.0': + resolution: {integrity: sha512-Gx/WbkFcdUFUg8g8AShezcS9EiQxfYvdAm2hfKLO8sfJmJvKOCt5fzlgHWDzmGhoclibgW+tUGZ/KF4F4wOTCA==} + cpu: [x64] + os: [android] + + '@pnpm/exe.darwin-arm64@12.15.0': + resolution: {integrity: sha512-N0ZykiDWCvqSBJvt71j7cSoBR993FqvYZFtmpCtqvW3pguiI+NAgraLPA5OTwu5mV+/d8hYpVcPktJA3xFDLtA==} + cpu: [arm64] + os: [darwin] + + '@pnpm/exe.darwin-x64@12.15.0': + resolution: {integrity: sha512-7Ntr2HlBUxzwWOg7NwDxCbRW/3vXuqKO+hcXm+w3SBi9rrHY53li1wLqWVT7Gjxd+lVEHM1QJZo6WJEGFU8C6A==} + cpu: [x64] + os: [darwin] + + '@pnpm/exe.freebsd-x64@12.15.0': + resolution: {integrity: sha512-btOiyL7fL7W4uQGH0aqFai2TNC3IoKcZ7gNHBVbEFZt2dWrnrD0SufL3iGs3fLlmb4OtuU35uf4Zpr9V9Jh9mA==} + cpu: [x64] + os: [freebsd] + + '@pnpm/exe.linux-arm64-musl@12.15.0': + resolution: {integrity: sha512-pNC38k+O+90FOjbPNSnw0E7apq1PKTmz3fFe1amn+lys/U5kL++uzir8bRiho8ONcyA3d9EU7wdqcY0DKkj+JA==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-arm64@12.15.0': + resolution: {integrity: sha512-qML/8aCXslh8td/w4U+HJNqUcZ2+m6EfTbWScIzZRmyPsRFN+xB4LP1U/hymxc1iSJiKtG56HJx2fvUErWFIGw==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-ppc64@12.15.0': + resolution: {integrity: sha512-tjRDUUl7RCJ6T/6eoNPxOqkwU4Mzi5RtTXmSAxujyz37OTwwsMU7Ps087Zk4gHcUvRSeyF40ZFsew3vtE+nmUA==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-riscv64@12.15.0': + resolution: {integrity: sha512-bF1uBWEfbwaeryz6lIiaJ8AWD082otZfvzGX5l+6LZRpRwUEpJHUsJrORaYP5/cNMv5ZR2p6TvvcJcQzwtDzmw==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-s390x@12.15.0': + resolution: {integrity: sha512-zKMhIzsexYMToeLmqV5jPsvV/f9vwsJb2kUH2NFYzalbxImeBrlA4kL7GwF8gD4pagV6jYYcJb8RjbZIdjHptg==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-x64-musl@12.15.0': + resolution: {integrity: sha512-A9J0Jg0Rdx+qQU4qXtwyST5tto9IOu1zi4fDk35nbc6DWahggbcKtFvZPKFwL2qgUXGXOX//hXv6z/sp6emO8A==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-x64@12.15.0': + resolution: {integrity: sha512-yc+QlZR+9+nr29J4fRzhMoapgxTBDndq/+peyoq1XUufnQFnfbXUMFudDIKzHi545linGqmOmXfn0NoufNgcOg==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.win32-arm64@12.15.0': + resolution: {integrity: sha512-fPXZxuY1VclkOga9bc53qNCXcegfeoBR8+Ue+AospDwKzuGGSHll0oDxkLfkmpjyRqpe7bH5DyQPYp/xSMaIVA==} + cpu: [arm64] + os: [win32] + + '@pnpm/exe.win32-x64@12.15.0': + resolution: {integrity: sha512-nrd+Tp1We1DGj4DGG5Bea9lZNh9y1PjlLBdEwdInS4D0h0UIDtM7JaGGGDJhNzIwcHASyihWI7HLV+dtG+fhYg==} + cpu: [x64] + os: [win32] + + pnpm@12.15.0: + resolution: {integrity: sha512-s5UdbW/0qfE9x89WzSjSuOs328ycaOUuHhGRhz6p+CoBcoerULqtxczElPA2xnwOR+sTYIwvo29HcRth6hKOYQ==} + engines: {node: '>=18'} + hasBin: true + +snapshots: + + '@pnpm/exe.android-arm64@12.15.0': + optional: true + + '@pnpm/exe.android-x64@12.15.0': + optional: true + + '@pnpm/exe.darwin-arm64@12.15.0': + optional: true + + '@pnpm/exe.darwin-x64@12.15.0': + optional: true + + '@pnpm/exe.freebsd-x64@12.15.0': + optional: true + + '@pnpm/exe.linux-arm64-musl@12.15.0': + optional: true + + '@pnpm/exe.linux-arm64@12.15.0': + optional: true + + '@pnpm/exe.linux-ppc64@12.15.0': + optional: true + + '@pnpm/exe.linux-riscv64@12.15.0': + optional: true + + '@pnpm/exe.linux-s390x@12.15.0': + optional: true + + '@pnpm/exe.linux-x64-musl@12.15.0': + optional: true + + '@pnpm/exe.linux-x64@12.15.0': + optional: true + + '@pnpm/exe.win32-arm64@12.15.0': + optional: true + + '@pnpm/exe.win32-x64@12.15.0': + optional: true + + pnpm@12.15.0: + optionalDependencies: + '@pnpm/exe.android-arm64': 12.15.0 + '@pnpm/exe.android-x64': 12.15.0 + '@pnpm/exe.darwin-arm64': 12.15.0 + '@pnpm/exe.darwin-x64': 12.15.0 + '@pnpm/exe.freebsd-x64': 12.15.0 + '@pnpm/exe.linux-arm64': 12.15.0 + '@pnpm/exe.linux-arm64-musl': 12.15.0 + '@pnpm/exe.linux-ppc64': 12.15.0 + '@pnpm/exe.linux-riscv64': 12.15.0 + '@pnpm/exe.linux-s390x': 12.15.0 + '@pnpm/exe.linux-x64': 12.15.0 + '@pnpm/exe.linux-x64-musl': 12.15.0 + '@pnpm/exe.win32-arm64': 12.15.0 + '@pnpm/exe.win32-x64': 12.15.0 + +--- lockfileVersion: '9.0' settings: diff --git a/tests/e2e/navigation.spec.ts b/tests/e2e/navigation.spec.ts index 48eb276..260310e 100644 --- a/tests/e2e/navigation.spec.ts +++ b/tests/e2e/navigation.spec.ts @@ -24,14 +24,17 @@ test('the header buttons keep the focus, so they can be pressed repeatedly', asy await expect(calendar.locator('[aria-selected="true"]')).toHaveCount(0); }); -test('after changing month, Tab enters the grid on the 1st', async ({ page, browserName }) => { +test('after changing month, Tab enters the grid on the 1st', async ({ page }) => { const calendar = calendarIn(page, 'basic'); await prevButton(calendar).focus(); await page.keyboard.press('Enter'); await expect(title(calendar)).toHaveText('July 2024'); await expect(calendar.locator('button[data-value][tabindex="0"]')).toHaveAttribute('data-value', '2024-07-01'); - // WebKit, like Safari, only tabs to elements with an explicit tabindex, so it skips the title and ">" buttons - for (let i = 0; i < (browserName === 'webkit' ? 1 : 3); i++) await page.keyboard.press('Tab'); + // Tab until the focus enters the grid: how many presses depends on the browser and its platform (WebKit on macOS, + // like Safari, only tabs to elements with an explicit tabindex, so it skips the title and ">" buttons; the CI runs + // it on Linux) + const inGrid = () => page.evaluate(() => !!document.activeElement?.closest('#basic [role="grid"]')); + for (let i = 0; i < 3 && !(await inGrid()); i++) await page.keyboard.press('Tab'); await expect(day(calendar, '2024-07-01')).toBeFocused(); });