Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Merge upstream/main into main

gerrydoroa50a4a4eaefa
diff --cc .gitignore
index 91558aebd,41d88171b..75d54b489
--- a/.gitignore
+++ b/.gitignore
@@@ -17,6 -17,7 +17,11 @@@ node_module
.claude/
.agents/
+# Nix build result symlinks
+result
+result-*
++
+ # CI reports (test:* jobs write these next to the suites)
+ junit.xml
+ coverage/
+ frontend/bundle-size.json
diff --cc .gitlab-ci.yml
index 71b72c934,d3b9475d1..6408aabb8
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@@ -30,10 -46,9 +46,13 @@@ stages
variables:
# node:22-alpine in web/Dockerfile and api/Dockerfile — CI must match production.
NODE_IMAGE: "node:22-alpine"
+ # Nix for the flake tests. Pinned, not `latest`: the VM integration test (tests.nix) and the
+ # package builds must be reproducible against a stable toolchain. 2.34.8 matches what the
+ # maintainer builds against locally.
+ NIX_IMAGE: "nixos/nix:2.34.8"
+ DOCKER_IMAGE: "docker:28-cli"
+ DOCKER_DIND_IMAGE: "docker:28-dind"
+ TRIVY_IMAGE: "aquasec/trivy:0.74.0"
# The demo build has no backend and no local media: the exercise images/GIFs (~140 MB)
# are never committed, so it points at the upstream dataset on jsDelivr, pinned to a
# commit so the CDN can cache it forever.
@@@ -103,79 -218,54 +222,120 @@@ test:mcp
# ?raw all resolve happily there. That is how a Vite-only import reached a shared lib
# module with 33 green tests standing over a server that died on startup.
- npm run check:node-loadable
+ coverage: '/Lines\s*:\s*(\d+\.?\d*)%/'
+ artifacts:
+ when: always
+ reports:
+ junit: mcp/junit.xml
+ coverage_report:
+ coverage_format: cobertura
+ path: mcp/coverage/cobertura-coverage.xml
rules:
- # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not
- # re-run the suite or republish the edge images once a month for nothing.
- - if: $CI_PIPELINE_SOURCE == "schedule"
- when: never
+ - !reference [.rules, not_on_schedule]
+ - when: on_success
+
+ test:api:
+ extends: .node
+ stage: test
+ cache:
+ key:
+ files:
+ - api/package-lock.json
+ paths:
+ - api/.npm
+ script:
+ - cd api
+ - npm ci --cache .npm --prefer-offline --omit=optional
+ # The Coach tests run on node:test and drive the in-repo fixture provider plus a local mock
+ # of the Chat Completions shape, so the whole job works without an AI account or the network.
+ # Same suite `npm test` runs, plus the JUnit file and node's own coverage table.
+ - node --experimental-test-coverage --test
+ --test-reporter=spec --test-reporter-destination=stdout
+ --test-reporter=junit --test-reporter-destination=junit.xml
+ test/*.test.js
+ - cd ..
+ # The api's copy of the exercise catalogue and the prompt module are generated and committed.
+ # A dataset or prompt change that forgets to regenerate them would otherwise only surface as
+ # "the Coach can't find that exercise" — or a prompt edit that never reached the model.
+ - node scripts/build-coach-assets.mjs --check
+ # api/coach/core is imported by the server under bare node AND by the phone under Vite.
+ # vitest forgives what node does not (?raw, import.meta.glob); this runs outside vitest.
+ - node api/scripts/check-core-loadable.mjs
+ coverage: '/all files\s*\|\s*(\d+\.?\d*)/'
+ artifacts:
+ when: always
+ reports:
+ junit: api/junit.xml
+ rules:
+ - !reference [.rules, not_on_schedule]
- when: on_success
+# ------------------------------------------------------------------------------ nix
+
+# The Nix flake (flake.nix → nix/) is a first-class packaging path for self-hosters on NixOS,
+# so it gets its own gate. This job:
+# * runs the module-eval check (checks.nixos-module-eval), validating the NixOS module wiring
+# (services/users/systemd/nginx state) against a smoke-test config, and
+# * builds every app package (#opengym-frontend, #opengym-api, #opengym-mcp) — actually
+# building each derivation catches a broken buildPhase/installPhase that eval alone would
+# miss.
+#
+# The full `nix flake check` also runs the NixOS VM integration test (nixosTests.opengym,
+# nix/tests.nix), but that derivation requires the `kvm` system feature, which GitLab shared
+# runners do not provide (their features are: benchmark, big-parallel, nixos-test, uid-range —
+# no kvm). So the VM test is deliberately left out of CI; run `nix flake check` on a
+# KVM-capable self-hosted runner to exercise it.
+#
+# Nix comes from the official nixos/nix image. The store stays at its default /nix/store so the
+# locked nixpkgs derivations resolve straight from the cache.nixos.org binary cache (relocating
+# it under the project dir made Nix rebuild the bootstrap from source — slow gnu.org tarball
+# downloads — which is why it's not cached). sandbox is disabled because a container has no
+# usable kernel sandbox.
+test:nix:
+ stage: test
+ image: $NIX_IMAGE
+ interruptible: true
+ variables:
+ # Keep the *default* store (/nix/store) so the flake's locked nixpkgs derivations resolve
+ # straight from cache.nixos.org. The earlier attempt to relocate the store under the project
+ # dir for GitLab caching backfired: cache.nixos.org only serves /nix/store paths, so a
+ # relocated store built the entire bootstrap toolchain from source (slow gnu.org tarball
+ # downloads, 502s). With the default store the shared runners just substitute from the binary
+ # cache.
+ #
+ # NIX_CONFIG is nix.conf content, one key per line:
+ # * experimental-features — enable `nix flake`.
+ # * sandbox = false — a container has no usable kernel sandbox, and disabling it also
+ # avoids the Nix 2.30+ build-dir check tripping on the world-writable /builds dir
+ # (NixOS/nix#13701) that the default-store build-dir path is unaffected by, but being
+ # explicit here is simplest and matches what Nix-on-GitLab CI does everywhere.
+ NIX_CONFIG: |
+ experimental-features = nix-command flakes
+ sandbox = false
+ script:
+ - |
+ set -euo pipefail
+ SYSTEM="$(nix eval --impure --raw --expr 'builtins.currentSystem')"
+ echo "system: $SYSTEM"
+ # Locked inputs first: `nix develop`/`nix run`/CI must all agree with the committed lock.
+ nix flake lock --no-update-lock-file
+ # The module-eval check validates the NixOS module wiring (services/users/systemd/nginx
+ # state) against a smoke-test config. The full `nix flake check` also runs the NixOS VM
+ # integration test (nixosTests.opengym), which needs the `kvm` system feature — not present
+ # on GitLab shared runners (Available: benchmark, big-parallel, nixos-test, uid-range), so
+ # it would fail here. Run it instead on a KVM-capable self-hosted runner; CI covers
+ # evaluation + every app package here.
+ echo "== module-eval check =="
+ nix build ".#checks.$SYSTEM.nixos-module-eval" --no-link
+ echo "== building packages =="
+ nix build ".#opengym-frontend" ".#opengym-api" ".#opengym-mcp" --no-link
+ rules:
+ # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not
+ # re-run the suite once a month for nothing.
+ - if: $CI_PIPELINE_SOURCE == "schedule"
+ when: never
+ - when: on_success
+
# --------------------------------------------------------------------------- images
# Images land at registry.gitlab.com/duartesantos8/opengym/{api,web} and are what