add an all-in-one script for running tests; format and fix some code; add ci.yml
CI / main-server (RSpec + audits) (push) Failing after 1m12s
CI / game-server (go vet + go test -race) (push) Successful in 1m1s
CI / frontend (build + tests) (push) Successful in 9s

This commit is contained in:
2026-11-29 16:46:27 +03:00
parent a91eccbeaa
commit e52178c929
14 changed files with 474 additions and 139 deletions
+68
View File
@@ -0,0 +1,68 @@
name: CI
on:
push:
branches: [master, main]
pull_request:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
main-server:
name: main-server (RSpec + audits)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
# Runs `bundle install` + caches gems; resolves the Gemfile
# and .ruby-version inside main-server/.
- uses: ruby/setup-ruby@v1
with:
working-directory: main-server
bundler-cache: true
# The spec suite talks to a real Redis: test runs are forced onto
# logical database 15 (config/initializers/redis.rb) and FLUSHDB it.
- name: Start Redis
run: |
if ! command -v redis-server >/dev/null 2>&1; then
sudo apt-get update -qq
sudo apt-get install -y -qq redis-server
fi
redis-server --daemonize yes
redis-cli -n 15 ping
- name: db:prepare, rubocop, bundler-audit, brakeman, rspec
run: scripts/test.sh main
game-server:
name: game-server (go vet + go test -race)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: game-server/go.mod
cache-dependency-path: game-server/go.sum
- run: scripts/test.sh game
frontend:
name: frontend (build + tests)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: scripts/test.sh frontend --install
+139
View File
@@ -22,7 +22,146 @@ The repository's directory structure is simple: there are 3 directories for each
- [ ] Additional in-game features: chat, reactions, live connection status
- [ ] Profile customization
## Testing
Every part of the project is tested differently. There is a single entry point for all of it — `scripts/test.sh` — and the same script is what `.github/workflows/ci.yml` runs, so local and CI results cannot drift apart.
| Part | Suite | Single part | Script (from the repo root) | External requirements |
|---------------|--------------------------------|-------------------------------------|-----------------------------|-----------------------|
| `main-server` | RSpec (17 spec files) + audits | `cd main-server && bundle exec rspec` | `scripts/test.sh main` | Redis on `localhost:6379` |
| `game-server` | Go `testing` + httptest | `cd game-server && go test -race ./...` | `scripts/test.sh game` | none |
| `frontend` | no automated tests | `cd frontend && npm run build` | `scripts/test.sh frontend` | none |
Quick run of everything (`all` is the default):
```bash
scripts/test.sh # all three parts
scripts/test.sh main # only one part
scripts/test.sh frontend --install # force `npm ci` first
scripts/test.sh --help
```
The script fails fast (`set -euo pipefail`), checks Redis before touching `main-server`, and prints one `==>` line per step. CI (`.github/workflows/ci.yml`) runs it in three parallel jobs: `scripts/test.sh main` (with a Redis service installed by the job), `scripts/test.sh game`, and `scripts/test.sh frontend --install`. The workflow is written for Gitea Actions as well as GitHub Actions; Gitea picks it up from `.github/workflows` and needs an `act_runner` built for node24 actions (`>= v2.327.1`), because `actions/checkout@v5` and `actions/setup-node@v5` require it.
> If `.gitea/workflows` is ever created, Gitea ignores `.github/workflows` completely — keep one copy, not two.
### main-server (Ruby on Rails / RSpec)
Setup (idempotent):
```bash
cd main-server
bundle install
bin/rails db:prepare # creates/updates storage/development.sqlite3 and storage/test.sqlite3
```
Run:
```bash
bundle exec rspec # full suite
bundle exec rspec spec/models # a directory
bundle exec rspec spec/models/match_spec.rb:12 # a single example
COVERAGE=true bundle exec rspec # SimpleCov report -> main-server/coverage/index.html (git-ignored)
```
Notes:
- **Redis is mandatory** for the suite: `MatchmakingService`, the channel and the sweep job specs talk to a real Redis. `config/initializers/redis.rb` forces `Rails.env.test?` onto logical database **15** and the specs run `FLUSHDB` there, so never point `REDIS_URL` in tests at a DB that holds data you care about. A local `redis-server` (or `docker run -d -p 6379:6379 redis`) is enough.
- The test database is SQLite (`storage/test.sqlite3`) plus a separate Solid Queue DB; both are recreated from `db/schema.rb` by `maintain_test_schema!`. Pending migrations abort the suite with an explicit message.
- Coverage by area: `spec/models`, `spec/services` (`JwtService`, `MatchmakingService`, `InternalSignatureService`), `spec/controllers`, `spec/requests` (including `api/internal/match_results_spec.rb`), `spec/channels`, `spec/jobs`.
Static checks / audits (all run from `main-server`, and all are steps of `scripts/test.sh main`):
```bash
bundle exec rubocop # style (rubocop-rails-omakase)
bundle exec bundler-audit check --update # known CVEs in gems
bundle exec brakeman --quiet --no-pager --exit-on-warn --exit-on-error --ensure-ignore-notes
```
Use the `bundle exec` forms: the bare `bin/rubocop`, `bin/brakeman` and `bin/bundler-audit` wrappers put the active Ruby's gem path ahead of Bundler's (`bundle exec ruby -e 'puts Gem.path'` fails on a multi-Ruby-machine), so the wrappers can fail with `Bundler::GemNotFound` even when `bundle exec` works.
Baseline (verified 2026-11-29): 155 examples green, `rubocop` clean, `bundler-audit` clean, `brakeman` clean. The single security finding — **Ruby2Shell (CVE-2026-132825) on Ruby 4.0.0** — is recorded with an explanation in `main-server/config/brakeman.ignore` (brakeman auto-loads it); Ruby 4.0.10 fixes it but is not installable on this machine yet (no ruby-build definition, and the Docker tag `ruby:4.0.10-slim` exists but the pin in `Dockerfile` must be bumped together with `.ruby-version`). When you bump Ruby, delete that ignore entry — `--ensure-ignore-notes` will keep you honest about it.
Do **not** use `bin/ci`: it requires `config/ci.rb`, which does not exist in this repo (only the Rails template for it is generated). `scripts/test.sh main` is the replacement.
### game-server (Go)
The Go suite is self-contained: the websocket integration tests use `httptest` and sign their own tokens, and the match-result reporter is tested against an in-process HTTP server, so no Redis, main-server or network access is needed.
```bash
cd game-server
go test ./... # all packages
go test -race ./... # recommended; the CI-equivalent command
go test ./internal/game -run TestFireWinCondition -count=1
go test ./internal/ws -count=1 # end-to-end websocket scenarios (real sockets, ~2s)
gofmt -l . # must print nothing (checked by scripts/test.sh)
go vet ./... # static check (also in scripts/test.sh)
go build -o /tmp/game-server ./cmd/server # compile check (cmd/server has no tests)
```
The `gofmt` check is part of `scripts/test.sh game` (and therefore of CI), so format before pushing. Note that parts of the tree were not gofmt-clean when this check was introduced; they have been reformatted once and the check keeps them that way.
Covered: JWT claims validation (`internal/auth`), message encoding/parsing incl. ship placement (`internal/protocol`), match manager scenarios (join/timeout/reconnect/ACK/placement/fire/win/reporting — `internal/game`), HMAC signing and the HTTP reporter with retries (`internal/mainserver`), and full end-to-end games over a real websocket (`internal/ws`).
### frontend (React + Vite)
There is **no test runner installed** (no vitest/jest/playwright/testing-library in `package.json` or `node_modules`), and no lint/format config. `shipLogic.js` exposes pure helpers (`canPlaceShip`, `randomFleet`, …) which are the natural candidates if a suite is ever added; until then verification is a build plus the manual end-to-end scenario below.
```bash
cd frontend
npm ci # deterministic install from package-lock.json
npm run dev # Vite dev server on http://localhost:5173
npm run build # build check -> dist/ (git-ignored)
npm run preview # serve the built bundle
```
`scripts/test.sh frontend` runs `npm ci` (only when `node_modules` is missing or `--install` is passed) and then `npm run build`. It also runs `npm test` **if** a `test` script exists in `package.json` — the hook is already in place for when a runner is added.
The API base URL defaults to `http://localhost:3000` and can be overridden with `VITE_API_URL` (see `src/api.js`); Action Cable and the game server URLs are derived from it / from the `matched` payload. `http://localhost:5173/uikit.html` renders the UI-kit reference page (a second Vite entry point).
### Shared cross-part contract
`contracts/test_signature_vectors.json` is the single source of truth for the HMAC wire format of the internal `game-server -> main-server` report. **Both** suites read it — `main-server/spec/services/internal_signature_service_spec.rb` and `game-server/internal/mainserver/reporter_test.go` (which also reuses its secret for JWT signing in `internal/ws/handler_game_test.go`). If the signature formula changes, update the implementation on both sides and regenerate the vectors; never edit a vector just to make a test pass (the other part will then fail).
### End-to-end manual test (all three parts together)
The three processes must agree on two values, otherwise matchmaking succeeds but the game never starts:
- `main-server` `SECRET_KEY_BASE` **=** `game-server` `JWT_SECRET` (JWT signing and report HMAC share one secret);
- `main-server` `GAME_SERVER_URL` **=** `game-server` `PUBLIC_ADDR`, compared byte-for-byte (default `ws://localhost:8081/ws`).
1. Start Redis: `redis-server` (or `docker run -d -p 6379:6379 redis`).
2. Start the main server: `cd main-server && bin/rails server` (Puma on `:3000`); check `curl localhost:3000/up`.
3. Start the game server:
```bash
cd game-server
go build -o /tmp/game-server ./cmd/server
LISTEN_ADDR=:8081 PUBLIC_ADDR=ws://localhost:8081/ws JWT_SECRET=4 \
MAIN_SERVER_URL=http://localhost:3000 /tmp/game-server
```
(`game-server/.env` already carries `PUBLIC_ADDR`/`JWT_SECRET=4` and is auto-loaded by `godotenv/autoload`; `main-server/.env` sets `SECRET_KEY_BASE=4` and `GAME_SERVER_URL`. Check `curl localhost:8081/healthz`.)
4. Start the frontend: `cd frontend && npm run dev`, open `http://localhost:5173`.
5. Register two players (two browsers or a normal + private window), then either press "random battle" in both windows, or use the invite flow: `create_invite` → the code comes back as `invite_created` → the second player enters it and gets `matched`.
6. Play through the whole loop: ship placement → turns (`STATE` 4/5, `FIRE_RESULT` 1–4) → `END` (code 1 victory / 2 defeat / -1 join timeout). Note `MATCHMAKING_TOKEN_TTL` is 120 s, so a match must be joined soon after `matched`.
7. Verify the result travelled back: `GET http://localhost:3000/api/matches/:uuid` (bearer token of a participant) should show the finished status, `finished_at` and `duration_seconds`. This is the same data the game server posts to the internal endpoint, which can also be exercised directly from the shell:
```bash
UUID=<match uuid>; BODY='{"status":"player1_won","duration_seconds":125}'; TS=$(date +%s)
SIG=$(printf '%s.%s.%s' "$TS" "/api/internal/matches/$UUID/result" "$BODY" \
| openssl dgst -sha256 -hmac "$SECRET_KEY_BASE" -hex | sed 's/^.* //')
curl -X POST "http://localhost:3000/api/internal/matches/$UUID/result" \
-H 'Content-Type: application/json' \
-H "X-Request-Timestamp: $TS" -H "X-Request-Signature: sha256=$SIG" -d "$BODY"
```
(idempotent for an already finished match; a `409` means it was closed with a different outcome).
Match history is visible in the UI (`GET /api/matches`) once the report has been processed; `rating_change` values stay zero until rating recalculation is implemented on `main-server`.
Quick protocol poke without the UI (the game server speaks raw JSON opcode arrays from `game-server/README.md`): take the `game_token` from the `matched` message and connect with `websocat`/"wscat", send `[1, "<game_token>", "<user_token>"]`, ACK each `seq` with `[4, <seq>]`, then `[5, ...30 ship args]` and `[6, x, y]`. Without `websocat` installed, `go test -race ./internal/ws` covers exactly these flows.
## Guidelines
- The mentioned documentation files should be kept up-to-date and updated in the same language. The formatting can be changed, though, if it could improve readability.
- Whenever you change business logic, update (and run) the corresponding suites listed in **Testing** — RSpec for `main-server`, `go test -race ./...` for `game-server`, and keep `contracts/test_signature_vectors.json` in sync if the HMAC format is touched.
- Before pushing, run `scripts/test.sh` (or at least the parts you touched). It is the same script CI runs, so a green local run means a green pipeline; do not rely on the bare `bin/*` wrappers of `main-server`, which break on a machine with several Ruby installs.
- When adding a check to CI, add the corresponding step to `scripts/test.sh` instead of inlining it in the workflow, otherwise local and CI runs drift apart.
- The Ruby backend should be written with Rails principles in mind. The tasks performed by this backend are going to be relatively simple (especially at earlier stages of this project), so the focus should be on clean code and best practices, not unnecessary complexity.
- The methods in the Ruby backend comprising the business-logic should be covered with unit-tests after being implemented.
@@ -327,4 +327,3 @@ func ParseFireResult(args []json.RawMessage) (seq int64, result int, err error)
func BuildFireResult(seq int64, result int) []byte {
return build([]any{OpFireResult, seq, result})
}
@@ -348,4 +348,3 @@ func TestParseFireResultErrors(t *testing.T) {
}
})
}
-2
View File
@@ -584,5 +584,3 @@ func TestFireWinOverWebSocket(t *testing.T) {
t.Fatalf("late join want END victory, got %v", lateEnd)
}
}
+1 -1
View File
@@ -52,4 +52,4 @@ group :test do
gem "simplecov", require: false
end
gem "dotenv-rails", "~> 3.2", groups: [:development, :test]
gem "dotenv-rails", "~> 3.2", groups: [ :development, :test ]
+117 -116
View File
@@ -3,29 +3,29 @@ GEM
specs:
action_text-trix (2.1.19)
railties
actioncable (8.1.3.1)
actionpack (= 8.1.3.1)
activesupport (= 8.1.3.1)
actioncable (8.1.4.1)
actionpack (= 8.1.4.1)
activesupport (= 8.1.4.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.1.3.1)
actionpack (= 8.1.3.1)
activejob (= 8.1.3.1)
activerecord (= 8.1.3.1)
activestorage (= 8.1.3.1)
activesupport (= 8.1.3.1)
actionmailbox (8.1.4.1)
actionpack (= 8.1.4.1)
activejob (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
mail (>= 2.8.0)
actionmailer (8.1.3.1)
actionpack (= 8.1.3.1)
actionview (= 8.1.3.1)
activejob (= 8.1.3.1)
activesupport (= 8.1.3.1)
actionmailer (8.1.4.1)
actionpack (= 8.1.4.1)
actionview (= 8.1.4.1)
activejob (= 8.1.4.1)
activesupport (= 8.1.4.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.3.1)
actionview (= 8.1.3.1)
activesupport (= 8.1.3.1)
actionpack (8.1.4.1)
actionview (= 8.1.4.1)
activesupport (= 8.1.4.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
@@ -33,36 +33,36 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.3.1)
actiontext (8.1.4.1)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.3.1)
activerecord (= 8.1.3.1)
activestorage (= 8.1.3.1)
activesupport (= 8.1.3.1)
actionpack (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.3.1)
activesupport (= 8.1.3.1)
actionview (8.1.4.1)
activesupport (= 8.1.4.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.1.3.1)
activesupport (= 8.1.3.1)
rails-html-sanitizer (~> 1.6, >= 1.7.2)
activejob (8.1.4.1)
activesupport (= 8.1.4.1)
globalid (>= 0.3.6)
activemodel (8.1.3.1)
activesupport (= 8.1.3.1)
activerecord (8.1.3.1)
activemodel (= 8.1.3.1)
activesupport (= 8.1.3.1)
activemodel (8.1.4.1)
activesupport (= 8.1.4.1)
activerecord (8.1.4.1)
activemodel (= 8.1.4.1)
activesupport (= 8.1.4.1)
timeout (>= 0.4.0)
activestorage (8.1.3.1)
actionpack (= 8.1.3.1)
activejob (= 8.1.3.1)
activerecord (= 8.1.3.1)
activesupport (= 8.1.3.1)
activestorage (8.1.4.1)
actionpack (= 8.1.4.1)
activejob (= 8.1.4.1)
activerecord (= 8.1.4.1)
activesupport (= 8.1.4.1)
marcel (~> 1.0)
activesupport (8.1.3.1)
activesupport (8.1.4.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -82,15 +82,15 @@ GEM
bigdecimal (4.1.3)
bootsnap (1.26.0)
msgpack (~> 1.5)
brakeman (8.0.6)
brakeman (8.1.1)
racc
builder (3.3.0)
bundler-audit (0.9.3)
bundler (>= 1.2.0)
thor (~> 1.0)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
crass (1.0.7)
connection_pool (3.0.3)
crass (1.0.8)
date (3.5.1)
debug (1.11.1)
irb (~> 1.10)
@@ -145,9 +145,9 @@ GEM
language_server-protocol (3.17.0.6)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.25.2)
loofah (2.25.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
nokogiri (>= 1.19.5)
mail (2.9.1)
logger
mini_mime (>= 0.1.1)
@@ -158,10 +158,10 @@ GEM
mini_magick (5.4.0)
logger
mini_mime (1.1.5)
minitest (6.0.6)
minitest (6.1.0)
drb (~> 2.0)
prism (~> 1.5)
msgpack (1.8.5)
prism (>= 1.5, < 3)
msgpack (1.8.7)
net-imap (0.6.7)
date
net-protocol
@@ -175,19 +175,20 @@ GEM
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.1)
net-protocol
net-ssh (7.3.3)
net-ssh (7.3.10)
logger
nio4r (2.7.5)
nokogiri (1.19.4-aarch64-linux-gnu)
nokogiri (1.19.7-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-aarch64-linux-musl)
nokogiri (1.19.7-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.4-arm-linux-gnu)
nokogiri (1.19.7-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-arm-linux-musl)
nokogiri (1.19.7-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-gnu)
nokogiri (1.19.7-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-musl)
nokogiri (1.19.7-x86_64-linux-musl)
racc (~> 1.4)
ostruct (0.6.3)
parallel (2.2.0)
@@ -203,11 +204,11 @@ GEM
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
puma (8.0.2)
puma (8.1.3)
nio4r (~> 2.0)
raabro (1.5.0)
racc (1.8.1)
rack (3.2.7)
rack (3.2.9)
rack-cors (3.0.0)
logger
rack (>= 3.0.14)
@@ -218,30 +219,30 @@ GEM
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (8.1.3.1)
actioncable (= 8.1.3.1)
actionmailbox (= 8.1.3.1)
actionmailer (= 8.1.3.1)
actionpack (= 8.1.3.1)
actiontext (= 8.1.3.1)
actionview (= 8.1.3.1)
activejob (= 8.1.3.1)
activemodel (= 8.1.3.1)
activerecord (= 8.1.3.1)
activestorage (= 8.1.3.1)
activesupport (= 8.1.3.1)
rails (8.1.4.1)
actioncable (= 8.1.4.1)
actionmailbox (= 8.1.4.1)
actionmailer (= 8.1.4.1)
actionpack (= 8.1.4.1)
actiontext (= 8.1.4.1)
actionview (= 8.1.4.1)
activejob (= 8.1.4.1)
activemodel (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
bundler (>= 1.15.0)
railties (= 8.1.3.1)
railties (= 8.1.4.1)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.7.1)
loofah (~> 2.25, >= 2.25.2)
rails-html-sanitizer (1.7.2)
loofah (~> 2.25, >= 2.25.3)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.3.1)
actionpack (= 8.1.3.1)
activesupport (= 8.1.3.1)
railties (8.1.4.1)
actionpack (= 8.1.4.1)
activesupport (= 8.1.4.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
@@ -333,12 +334,12 @@ GEM
fugit (~> 1.11)
railties (>= 7.1)
thor (>= 1.3.1)
sqlite3 (2.9.6-aarch64-linux-gnu)
sqlite3 (2.9.6-aarch64-linux-musl)
sqlite3 (2.9.6-arm-linux-gnu)
sqlite3 (2.9.6-arm-linux-musl)
sqlite3 (2.9.6-x86_64-linux-gnu)
sqlite3 (2.9.6-x86_64-linux-musl)
sqlite3 (2.10.2-aarch64-linux-gnu)
sqlite3 (2.10.2-aarch64-linux-musl)
sqlite3 (2.10.2-arm-linux-gnu)
sqlite3 (2.10.2-arm-linux-musl)
sqlite3 (2.10.2-x86_64-linux-gnu)
sqlite3 (2.10.2-x86_64-linux-musl)
sshkit (1.25.1)
base64
logger
@@ -357,7 +358,7 @@ GEM
unicode-display_width (3.3.0)
unicode-emoji (~> 4.3)
unicode-emoji (4.3.0)
uri (1.1.1)
uri (1.1.2)
useragent (0.16.11)
websocket-driver (0.8.2)
base64
@@ -403,29 +404,29 @@ DEPENDENCIES
CHECKSUMS
action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009
actioncable (8.1.3.1) sha256=e318528295c878a3efdfe25f0f2267c80cb7a76eba41bb5f64d44aa380a3d91b
actionmailbox (8.1.3.1) sha256=5f704972097d843ade8e435e93694a1dac732b926df1717aceba1f3840082b1c
actionmailer (8.1.3.1) sha256=88ea441b28ff02a0c6c006468892642a3d9942affce9d294e81a74504aa5c43c
actionpack (8.1.3.1) sha256=974cb7154548e81f470b1b0f247b99cb38e87825899dca58610596e2817723d0
actiontext (8.1.3.1) sha256=5da729d833d1a29cddb1eee938878e55e503d2613e00e735f5daf58c2ba98af2
actionview (8.1.3.1) sha256=2da68b8414c47b43bfbed1ce69c5afe1c04f78c267aacb5660a4cab5ca12cfb6
activejob (8.1.3.1) sha256=1c8dd275df930df40deecffec63d913a550a33fd94bd298f69721dd96939954a
activemodel (8.1.3.1) sha256=99cc02ce2faec371d14440949d85787ebd23a907c9baef0a9d4bcd4d21888f88
activerecord (8.1.3.1) sha256=0a2fb6c28f4938f6b013a3a549bec0a7e37d535f3dc8990e804bcc3258c0403b
activestorage (8.1.3.1) sha256=f555254f387b1cffa499d2fd3115d12635eadc5b15206a8534316a67036163ef
activesupport (8.1.3.1) sha256=85458765f25ea48b9019c46b6bb3fa5683197bf4280d9f06710a6e8d7a831376
actioncable (8.1.4.1) sha256=007670f7297973e94809e9f32a56624a7aa60b6e9d6696cd078064ce86d1c7fc
actionmailbox (8.1.4.1) sha256=18b43dd842bf3a3e31b8e38b7917c21e48c128fc8b263c893481cc66ee1a8f78
actionmailer (8.1.4.1) sha256=a7b71dedf744e48dd6751e97350634edce9a2f7beeceac332dcccb91729ad066
actionpack (8.1.4.1) sha256=8c6f2e7cbd2653ef0539bde1ff20eb3e2e264e366affe56f0ba7f06d3670cb4b
actiontext (8.1.4.1) sha256=fb59611dc16e2b6bbfcec66793acfae6cdd64b1e35ef3f9175424f31e62c38da
actionview (8.1.4.1) sha256=d25b4d9cf8d0c0195ffcfe8b2cf3fcbe6fea54fd7c17f1a9cb8182881463f12b
activejob (8.1.4.1) sha256=82c4c9311ea1016d5f7f134a0c5f9b6527cad5a6237f5f3f60aa17984ef36229
activemodel (8.1.4.1) sha256=063caf105372fbc98b2d789e4be23de63ac5c043f7d9330f04e2caddb7012805
activerecord (8.1.4.1) sha256=bd65599ca0b5d210937f835d42c7aff69d271741c75aab022730be6cbce67e87
activestorage (8.1.4.1) sha256=0f4e2f114f3584723a80a2c089aacc6170e765a0b2c385c9782e26ed78f05c66
activesupport (8.1.4.1) sha256=16ac4f341ca65c85a1fcdb8ac73f68891aae9e3c4a6f9c3a27daed8b00017ed7
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032
bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6
bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
bootsnap (1.26.0) sha256=ca96237015e6cd74a02963d5821cf00ac5ea134653b323e8cd6d702a7718bf1b
brakeman (8.0.6) sha256=759cc69341115e6c2dcd47b6fd8649a0b9bd540e3585ac8a0a94e31c66fee386
brakeman (8.1.1) sha256=a038d25ef911be910171222d2355e11ff5b5048cc4e2f08e7a4c11eccd4f418a
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9
concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
crass (1.0.7) sha256=94868719948664c89ddcaf0a37c65048413dfcb1c869470a5f7a7ceb5390b295
connection_pool (3.0.3) sha256=e0f8ee3ee0039396753e06e8a2dde0ef028e40f7df29e97f57da7577c489cb5e
crass (1.0.8) sha256=7a0145c7a2c59f8e7923b3a69ce819c444823a00a5127d805298fea13be24efe
date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
@@ -454,27 +455,27 @@ CHECKSUMS
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
loofah (2.25.2) sha256=2007f746959ac65552456e04b433e83deb22759ab38c838b4445c70e43425918
loofah (2.25.3) sha256=545f14eef0cc2a7de80df560530d593232b7c07e515c5c4e37532d9cb5b0185c
mail (2.9.1) sha256=06574eca475253d6c18145dd70af80d0eb970182d55053497c5f4d797ea160e8
marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f
mini_magick (5.4.0) sha256=f120af581d9ed4ec52c57f35a67a605d112bb1d8f582d1415b147fda42d11d78
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
msgpack (1.8.5) sha256=97419eaa7b35dfe3e462c0e6c1a3dfdcbfc8756605c09e46e4c6daef127517ba
minitest (6.1.0) sha256=ff373595aa8888631e8a5463986a76b3845346ae6d7fa46e139c1633d418076e
msgpack (1.8.7) sha256=dfefec761b5f9047e6e8d95d2c7f8af4b3725d984a01942adc533aa819a2df33
net-imap (0.6.7) sha256=b5c9573be975d856de252ee851871724da66aa2d449b2482d5690bd12bc23660
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
net-protocol (0.4.0) sha256=f9f90c8c6f64794a45160bf422177a336db12809de3beeeaa26b88fcd2e8c853
net-scp (4.1.0) sha256=a99b0b92a1e5d360b0de4ffbf2dc0c91531502d3d4f56c28b0139a7c093d1a5d
net-sftp (4.0.0) sha256=65bb91c859c2f93b09826757af11b69af931a3a9155050f50d1b06d384526364
net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736
net-ssh (7.3.3) sha256=831def58b2c51dcef66ec00d29397d4f210de89c19fe78f95873ca30f386e86a
net-ssh (7.3.10) sha256=8b54591acc8f9dbb63cd906add66a816c302f950cf92137b14155e809abea472
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
nokogiri (1.19.4-aarch64-linux-gnu) sha256=1269fb644a6de405057a53dd5c762b1209b43ca7424f839454d3dbc677c31a8f
nokogiri (1.19.4-aarch64-linux-musl) sha256=35c65b9ce72b3bb03207bdbe7067915019dc18c1b9b59139684bd6690fdd01af
nokogiri (1.19.4-arm-linux-gnu) sha256=a301313e38bb065d68239e79734bcd6f56fb6efaacebde29e9abf2a4735340ca
nokogiri (1.19.4-arm-linux-musl) sha256=588923c101bcfa78869734d247d25b598674323e7f22474fc468f6e5647311eb
nokogiri (1.19.4-x86_64-linux-gnu) sha256=379fae440b28915e3f19d752ce2dcf8465ed2b2fbefd2a7ca0dd497bc981a06a
nokogiri (1.19.4-x86_64-linux-musl) sha256=17dfb7c1fa194ae02fbf7c51a7afc8d278045ab3fdacfd86f91d02d7b274470b
nokogiri (1.19.7-aarch64-linux-gnu) sha256=8f5e15d299602456406e1f03a9f3456cceb33a0722811e818d2ee2214eb4c84a
nokogiri (1.19.7-aarch64-linux-musl) sha256=efe0c3602e6e54521bc21c681930ce5568e2d11203de17400710b2b3ca2e4cb4
nokogiri (1.19.7-arm-linux-gnu) sha256=7fd1907125691aa89e838cc91161761c758b4e17bb32f0dd9b5515a82cc759af
nokogiri (1.19.7-arm-linux-musl) sha256=28d0ff0c87b6bb2e56580323a6fb049d5d4a02b94f0958fdd47e9ac146991c77
nokogiri (1.19.7-x86_64-linux-gnu) sha256=25865ccb462f714e712fdf8906fde07849cb6704a808e3d629d75baa5af5dd3b
nokogiri (1.19.7-x86_64-linux-musl) sha256=464d1f3dfb0d53cf54c0c6a7e23e8e91cf68ec3cafc2b27dc4a7682f2d9bf546
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
parallel (2.2.0) sha256=e1059c5fd7b649558a0aec38a769f06a42942bdb40503d005a59c352fe011cd8
parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
@@ -486,18 +487,18 @@ CHECKSUMS
pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570
prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
puma (8.0.2) sha256=c8ed871dfbbe66448ea9ffd46692342d9804d4071522b52b5331b7b6e7b686fb
puma (8.1.3) sha256=a12de11fb2f20f8a3ef25a5b1447eabe7142846719eeb9672ee8ec0705b8c3a8
raabro (1.5.0) sha256=3f998a7bc84f9c84df3ab580634d2e0a5bda4f0841168d56035f529c9877440a
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
rack (3.2.9) sha256=8235c1d08f0c461bedcff4413bbeba888173e5b09e1332ae951c98f0ee460dcc
rack-cors (3.0.0) sha256=7b95be61db39606906b61b83bd7203fa802b0ceaaad8fcb2fef39e097bf53f68
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868
rails (8.1.3.1) sha256=ccd11a36bfc171bf9c66d585d14c0ece91c0c9dde840aae60c0118d6f5c9c52a
rails (8.1.4.1) sha256=365c3a0ad2713bd6e60628e5e826622d4ca8dee60b5a7e560e9b20844e9650bc
rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
rails-html-sanitizer (1.7.1) sha256=e797a7c9b01e567307e317c576b49ab4168017e63eea4dba9ce3cb587e2f22c2
railties (8.1.3.1) sha256=2388a232579a00cefea4487de66c8553c3408c1300abdc6cf1799d86ffb04487
rails-html-sanitizer (1.7.2) sha256=a21ef45b7a6639fc8e2282473c547514cb86ae271616162a946bf89148fa2424
railties (8.1.4.1) sha256=ff2ef4b5a62cbc89811f88be11c776e2ed71b14dd012eae6a494d37994aa9782
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
rbs (4.2.0) sha256=51f7b886dcc05bc09e10b901daa6a81829f6adc03101d6ca9ea4aac6103e0674
@@ -523,12 +524,12 @@ CHECKSUMS
solid_cable (4.0.2) sha256=084636a67679ad00d23088b33c84047e614bcf41ee559db24b414d83cdc42d03
solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41
solid_queue (1.7.0) sha256=6566b70b801d1c317c81bba7bcdd5677c019afac584a30374b4164002ca356d3
sqlite3 (2.9.6-aarch64-linux-gnu) sha256=d8b1f7d23efd7abac285775a9566562fc7debfef79d594e3a20354406fb7907c
sqlite3 (2.9.6-aarch64-linux-musl) sha256=3579e1c98cdc7ff5c3722847bb63ed4e1efb7ff675cb5e1e48ef2d4da5fb3bc9
sqlite3 (2.9.6-arm-linux-gnu) sha256=33541500e3615da02afe54a9cc38b17a6985d3cf9d8b76d6d0a83002f114e7ec
sqlite3 (2.9.6-arm-linux-musl) sha256=c5490af48bb228fefa54314e9541375c3907e70f8109f3881b5ff97e1c93ae33
sqlite3 (2.9.6-x86_64-linux-gnu) sha256=613188ce02f614126ddbc38c5e217ccffd6306d0dcd9adca9764547aa890a634
sqlite3 (2.9.6-x86_64-linux-musl) sha256=d493b11818a3573387a1d56e1ee8fa00da23a683a7a1cc063e7a0feeed843abf
sqlite3 (2.10.2-aarch64-linux-gnu) sha256=e9aea2c2b3476fc875dd8a89313a9a2862818519c0186bfb5b56d6f57bb08d98
sqlite3 (2.10.2-aarch64-linux-musl) sha256=4986fc40cdf21342362b72a941df28e95cfe0e644f3ad2532d948b157c39dbee
sqlite3 (2.10.2-arm-linux-gnu) sha256=762f609ef891463226b472d3df66aea84d5466ff4376d3ccf4a059718c4ce9c9
sqlite3 (2.10.2-arm-linux-musl) sha256=833623eaf1157b1b85d1c0830e3e8f9beb3bb95a9bec3d252f20557a50e9803a
sqlite3 (2.10.2-x86_64-linux-gnu) sha256=ca92731ab464df9cae503fa1a439a549e2724f6953c8c05a7769b59366e38f15
sqlite3 (2.10.2-x86_64-linux-musl) sha256=b9f8fc62f3e0eb8966b41de251b492b4c8e9d1b23559beb6e150ad7f8d590941
sshkit (1.25.1) sha256=be3f10b9d6eb0b44d5eaba3f7cbe41bc6bb894bce4339688ac20124391455b78
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
thruster (0.1.26) sha256=6e45e807086b29d51404841bd1ad493b67cd95892fd65dc5afcdd32e82e94ce8
@@ -539,7 +540,7 @@ CHECKSUMS
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613
unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
uri (1.1.2) sha256=89292e98eabbef6248b0a0ed5e7e398e152f83f17560023a6d94a7f492b169fb
useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844
websocket-driver (0.8.2) sha256=97c556b019bf3410b4961002ac501621e9322d3f8a7bc02161a09301cc4c4146
websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241
@@ -1,5 +1,5 @@
class Api::RegistrationsController < ApplicationController
skip_before_action :authenticate_request!, only: [:create]
skip_before_action :authenticate_request!, only: [ :create ]
def create
user = User.new(registration_params)
@@ -1,5 +1,5 @@
class Api::SessionsController < ApplicationController
skip_before_action :authenticate_request!, only: [:create]
skip_before_action :authenticate_request!, only: [ :create ]
def create
user = if params[:nickname].present? && params[:password].present?
+8
View File
@@ -0,0 +1,8 @@
{
"ignored_warnings": [
{
"fingerprint": "b2ef9ca037e09c20a8a7b7aec14bd62b16fb830e3723adf3b6936529ed347bde",
"note": "Ruby2Shell (CVE-2026-132825): .ruby-version pins 4.0.0, which is in the vulnerable 4.0.0..4.0.9 range. Ruby 4.0.10 is the fixed release but is not yet installable here (ruby-build defs / image tags lag); remove this entry as soon as .ruby-version is bumped to >= 4.0.10."
}
]
}
+2 -2
View File
@@ -3,7 +3,7 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do
origins ENV.fetch("CORS_ORIGINS", "*").split(",")
resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head],
expose: ["Authorization"]
methods: [ :get, :post, :put, :patch, :delete, :options, :head ],
expose: [ "Authorization" ]
end
end
+123
View File
@@ -0,0 +1,123 @@
#!/usr/bin/env bash
# Single entry point for all project checks (local and CI).
#
# Usage:
# scripts/test.sh [main|game|frontend|all] [--install]
#
# main - main-server: db:prepare, rubocop, bundler-audit, brakeman, rspec
# game - game-server: gofmt check, go vet, go test -race
# frontend - frontend: npm ci (if needed), npm run build, npm test (if present)
# all - all of the above (default)
#
# --install - force `npm ci` even if node_modules already exists
#
# Requirements: Ruby (bundle), Go, Node/npm; Redis on localhost:6379 for main.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TARGET="all"
INSTALL="no"
for arg in "$@"; do
case "$arg" in
main | game | frontend | all) TARGET="$arg" ;;
--install) INSTALL="yes" ;;
-h | --help)
sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//'
exit 0
;;
*)
echo "Unknown argument: $arg (see --help)" >&2
exit 2
;;
esac
done
log() { printf '\n\033[1;35m==> %s\033[0m\n' "$*"; }
ok() { printf '\033[1;32m ok: %s\033[0m\n' "$*"; }
die() {
printf '\033[1;31mERROR: %s\033[0m\n' "$*" >&2
exit 1
}
require_redis() {
command -v redis-cli >/dev/null 2>&1 || die "redis-cli not found; install Redis"
redis-cli -n 15 ping >/dev/null 2>&1 ||
die "Redis is not reachable on localhost:6379 (start it with: redis-server)"
}
main_server() {
cd "$ROOT/main-server"
require_redis
log "main-server: dependencies"
bundle check >/dev/null 2>&1 || bundle install
log "main-server: db:prepare (test)"
RAILS_ENV=test bundle exec rails db:prepare
log "main-server: rubocop"
bundle exec rubocop
log "main-server: bundler-audit"
bundle exec bundler-audit check --update
log "main-server: brakeman"
# config/brakeman.ignore holds one documented exception (Ruby2Shell on
# Ruby 4.0.0); --ensure-ignore-notes keeps every entry justified.
bundle exec brakeman --quiet --no-pager --exit-on-warn --exit-on-error --ensure-ignore-notes
log "main-server: rspec"
bundle exec rspec
}
game_server() {
cd "$ROOT/game-server"
log "game-server: gofmt"
unformatted="$(gofmt -l .)"
[ -z "$unformatted" ] || die "gofmt: these files are not formatted:
$unformatted"
log "game-server: go vet"
go vet ./...
log "game-server: go test -race"
go test -race ./...
}
frontend() {
cd "$ROOT/frontend"
if [ "$INSTALL" = "yes" ] || [ ! -d node_modules ]; then
log "frontend: npm ci"
npm ci
else
log "frontend: dependencies already installed (use --install to refresh)"
fi
log "frontend: build"
npm run build
has_test="$(node -e "process.stdout.write(require('./package.json').scripts?.test ? 'yes' : 'no')")"
if [ "$has_test" = "yes" ]; then
log "frontend: npm test"
npm test
else
log "frontend: no npm test script; build is the only automated check (see AGENTS.md)"
fi
}
case "$TARGET" in
main) main_server ;;
game) game_server ;;
frontend) frontend ;;
all)
main_server
game_server
frontend
;;
esac
log "done: $TARGET"