Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
groupName: "Bun",
sourceUrl: "https://github.com/oven-sh/bun",
prBodyNotes: [
"The image (`oven/bun:<version>-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:<version>-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,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -189,19 +188,19 @@ 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
```

`bun run setup` builds SnapRAID 15.1 (the version of the image) from the release tarball for the jobs SnapRAID UI runs itself, and SnapRAID from git (`SNAPRAID15_REF`) with snapraid-daemon at the version in `backend/src/engine/REVIEWED_DAEMON_VERSION`. The test disks are directories on one filesystem, so SnapRAID runs with `--test-skip-device`: the backend gets it through `SNAPRAID_EXTRA_ARGS`, the daemon through a small compiled wrapper as `sys_engine`.

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=<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=<path>` 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=<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=<path>` 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

Expand Down
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion e2e/scripts/image-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ if [[ -z "${E2E_IMAGE:-}" ]]; then
fi

cd "$E2E_DIR"
bunx playwright test "$@"
bun --bun playwright test "$@"
Loading