diff --git a/.github/renovate.json5 b/.github/renovate.json5 index aedaed4..527d9c9 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -75,7 +75,7 @@ groupName: "Bun", sourceUrl: "https://github.com/oven-sh/bun", prBodyNotes: [ - "The image (`oven/bun:-slim` in docker/Dockerfile, the backend runs on it) and `packageManager` in `backend/package.json`, `frontend/package.json` and `e2e/package.json` (CI's `bun-version-file`, which also builds the standalone binary, and the screenshots job's `npm install bun@…`) move together. Bun runs the backend and its tests, installs, runs Vite and Vitest (`bun --bun`) and compiles the binary; Playwright's test runner still runs on Node. Check the backend and frontend jobs and the end-to-end tests against the local build, the image and the binary.", + "The image (`oven/bun:-slim` in docker/Dockerfile, the backend runs on it) and `packageManager` in `backend/package.json`, `frontend/package.json` and `e2e/package.json` (CI's `bun-version-file`, which also builds the standalone binary, and the screenshots job's `npm install bun@…`) move together. Bun runs the backend and its tests, installs, runs Vite and Vitest (`bun --bun`) and compiles the binary, and runs Playwright's test runner (`bun --bun playwright test`). Check the backend and frontend jobs and the end-to-end tests against the local build, the image and the binary.", ], schedule: ["at any time"], automerge: false, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 983465f..591d0ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,7 +138,7 @@ jobs: E2E_BINARY: ${{ matrix.target == 'binary' && '../dist/snapraid-ui-linux-x86_64' || '' }} steps: - uses: actions/checkout@v7 - # Bun installs, builds and runs the backend; Playwright's test runner runs on the runner's Node + # Bun installs, builds and runs the backend, and runs Playwright's test runner (bun --bun) - uses: oven-sh/setup-bun@v2 with: bun-version-file: e2e/package.json @@ -156,7 +156,7 @@ jobs: run: bun run setup - run: bun install --frozen-lockfile - run: bun run typecheck - - run: bunx playwright install --with-deps chromium + - run: bun --bun playwright install --with-deps chromium - name: Install the frontend, the tests or the binary build it if: matrix.target != 'image' working-directory: frontend diff --git a/README.md b/README.md index 5338d60..26fa237 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,7 @@ December 23. ## 🛠️ Development Requires Bun (the version in `frontend/package.json`) and the fish shell for `start.sh`; -Node.js 22+ only for the end-to-end tests. +the end-to-end tests run on Bun too. ```bash git clone https://github.com/firsttris/snapraid-ui && cd snapraid-ui diff --git a/docs/development.md b/docs/development.md index 0d94068..caf903b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -6,8 +6,7 @@ This page gets you from a fresh clone to a running development setup, and covers | Tool | Version | Needed for | |---|---|---| -| [Bun](https://bun.com/) | the version in `packageManager` of `backend/package.json` and `frontend/package.json` (1.4.4) | Everything JavaScript: runs the backend and its tests, installs the packages, runs Vite and Vitest, compiles the standalone binary (CI and the image use the same version) | -| [Node.js](https://nodejs.org/) | 22 or newer | Only for the end-to-end tests: Playwright's test runner runs on Node | +| [Bun](https://bun.com/) | the version in `packageManager` of `backend/package.json` and `frontend/package.json` (1.4.4) | Everything JavaScript: runs the backend and its tests, installs the packages, runs Vite and Vitest and Playwright's test runner (`bun --bun playwright test`), compiles the standalone binary (CI and the image use the same version) | | [fish](https://fishshell.com/) | | `start.sh` is a fish script | | `curl`, `tar`, `gcc`, `make` | | Building SnapRAID for the demo sandbox (`dev/setup.sh`) | | SnapRAID | 14.0 or newer | Only for running against a real array without `--demo`; it has to be on your `PATH` or set via `SNAPRAID_BIN` | @@ -189,11 +188,11 @@ The test adds files to the array's first data disk. In `snapraidd.conf` set `net ```bash cd e2e bun install -bunx playwright install chromium # once -bun run setup # builds the tools into e2e/.tools, needs autoconf, automake, zlib1g-dev -bun run test # builds the frontend, starts everything, runs the tests (about 2 min); - # the backend runs with the packages of backend/ (bun install there first) -bun run test:image # the same tests against the Docker image built from docker/Dockerfile +bun --bun playwright install chromium # once +bun run setup # builds the tools into e2e/.tools, needs autoconf, automake, zlib1g-dev +bun run test # builds the frontend, starts everything, runs the tests (about 2 min); + # the backend runs with the packages of backend/ (bun install there first) +bun run test:image # the same tests against the Docker image built from docker/Dockerfile E2E_BINARY=../dist/snapraid-ui-linux-x86_64 bun run test # against the standalone binary, see below ``` @@ -201,7 +200,7 @@ E2E_BINARY=../dist/snapraid-ui-linux-x86_64 bun run test # against the standal The global setup (`e2e/harness/global-setup.ts`) recreates `e2e/.run/` on every run: the backend's data directory, the arrays and a log per server. It starts snapraid-daemon on its own array, the backend (with `PORT`, `SNAPRAID_BASE_PATH` and `SNAPRAID_BIN` pointing into `e2e/`), which serves the production build of the frontend as in the image. Each test creates its own array, adds it through the API and opens it; the `app` fixture removes it, and the schedules, afterwards. Tests run one after the other, the backend runs one job at a time. -With `E2E_IMAGE=` the container takes the place of the backend: started as in `docker/docker-compose.yml`, with the data directory in `/app/snapraid`, the arrays at the same paths as on the host and the Docker socket mounted. It shares the host's network (the UI on port 80), so the backend reaches snapraid-daemon and the webhook receiver on `127.0.0.1`. With `E2E_BINARY=` the standalone binary takes the place of the backend's sources, with the same environment; it carries its own frontend, so nothing is built. `E2E_SKIP_BUILD=1` skips the frontend build of a local run. A failed test leaves a trace (`bunx playwright show-trace e2e/test-results/…/trace.zip`) and the server logs in `e2e/.run/*.log`; CI uploads both. +With `E2E_IMAGE=` the container takes the place of the backend: started as in `docker/docker-compose.yml`, with the data directory in `/app/snapraid`, the arrays at the same paths as on the host and the Docker socket mounted. It shares the host's network (the UI on port 80), so the backend reaches snapraid-daemon and the webhook receiver on `127.0.0.1`. With `E2E_BINARY=` the standalone binary takes the place of the backend's sources, with the same environment; it carries its own frontend, so nothing is built. `E2E_SKIP_BUILD=1` skips the frontend build of a local run. A failed test leaves a trace (`bun --bun playwright show-trace e2e/test-results/…/trace.zip`) and the server logs in `e2e/.run/*.log`; CI uploads both. ## Linting and type checking diff --git a/e2e/package.json b/e2e/package.json index 4c9eee7..f9f78fe 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -5,10 +5,10 @@ "type": "module", "scripts": { "setup": "bash scripts/setup-tools.sh", - "test": "playwright test", + "test": "bun --bun playwright test", "test:image": "bash scripts/image-test.sh", "typecheck": "tsc -p .", - "screenshots": "playwright test -c playwright.screenshots.config.ts" + "screenshots": "bun --bun playwright test -c playwright.screenshots.config.ts" }, "devDependencies": { "@playwright/test": "1.64.1", diff --git a/e2e/scripts/image-test.sh b/e2e/scripts/image-test.sh index 9d38694..097fcf9 100755 --- a/e2e/scripts/image-test.sh +++ b/e2e/scripts/image-test.sh @@ -14,4 +14,4 @@ if [[ -z "${E2E_IMAGE:-}" ]]; then fi cd "$E2E_DIR" -bunx playwright test "$@" +bun --bun playwright test "$@"