Skip to content

Chore/deploy readiness - #37

Merged
AsierCL merged 12 commits into
mainfrom
chore/deploy-readiness
Nov 5, 2026
Merged

AsierCL merged 12 commits into
mainfrom
chore/deploy-readiness

Conversation

@AsierCL

@AsierCL AsierCL commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

The pinned lombok 1.18.30 fails on JDK 22+ (NoSuchFieldException
com.sun.tools.javac.code.TypeTag :: UNKNOWN), so the project could only be
built on JDK 21. Spring Boot 3.5.13 already manages lombok 1.18.44, which
supports current JDKs.

Verified: ./mvnw test on JDK 25 -> 123 tests green.
The test profile runs on H2 with Flyway disabled, so a mismatch between
V1..Vn and the JPA mapping only surfaced when production booted with
ddl-auto=validate.

Add PostgresMigrationIT (runs only when POSTGRES_TEST_URL is set) and a CI job
with a postgres:16 service that applies the migrations and validates the
entity mapping against the resulting schema.

Verified RED: a probe migration dropping users.email makes the test fail with
Schema-validation: missing column [email] in table [users].
Verified GREEN: 8 migrations applied, 1 test green.
DataLoader seeded users with known passwords (two of them MASTER) whenever the
local/demo profile was active, reading an env var directly from System.getenv.
A deployment with the wrong profile pointing at a real database could create
those accounts.

The runner bean now only exists when app.demo-seeds.enabled=true
(APP_DEMO_SEEDS_ENABLED=true in the environment); the dev compose files opt in
explicitly.

Verified: DemoSeedsGateTest fails before the change (bean always created) and
passes after it; full suite 126 tests green.
The template defaulted to SPRING_PROFILES_ACTIVE=local and the production
compose propagates that value verbatim, so copying the example and forgetting
one line booted the app with the development profile against a real database
(Swagger public, show-sql, no MASTER bootstrap, demo seeds gated only by env).

Default to prod, document that it must stay prod, drop the legacy POSTGRES_*
variables that prod no longer uses, and make the demo-seed flag explicit.

Verified: docker compose --env-file Docker/.env.example -f
Docker/docker-compose.yml --profile full config --quiet -> OK.
Two problems broke the documented development path:

- minio/minio:latest is no longer pullable from Docker Hub, so
  ./run.sh dev failed before starting. Use pgsty/minio, a drop-in fork of the
  same server (same env vars, CLI and /minio/health/live endpoint).
- Spring Boot does not read .env files and run.sh never sourced gradox2/.env,
  so the local SMTP credentials (and any other local setting) were silently
  ignored. Parse KEY=VALUE without bash , because values such as the
  Gmail app password contain spaces.

Verified: dev stack up (db + minio healthy), ./run.sh run boots with the local
profile, Flyway applies V1..V8, demo seeds create the three files in S3
(bucket gradox2-files created in MinIO), login as the seeded MASTER works.
/admin/** has been implemented (ban/unban, audit, proposals); the inline
comment still claimed otherwise.
- 117 -> 126 tests (123 + DemoSeedsGateTest + PostgresMigrationIT).
- V1..V7 -> V1..V8 (V8 seeds courses and subjects).
- Document the CI migrations job and how to run it locally.
- minio/minio is no longer available; the dev stack uses pgsty/minio.
- run.sh loads gradox2/.env; app.demo-seeds.enabled gates the demo data.
- token_version (V5) does allow revoking issued access tokens.
The .env loader exported every key unconditionally, so a value already set by
the invoking shell was silently overwritten. Concretely: exporting
APP_DEMO_SEEDS_ENABLED=false and having it as true in .env re-enabled demo
seeding, which creates known-password MASTER accounts.

The loader now skips keys already present in the environment, matching Spring
Boot precedence (environment over file).

Verified: bash -n; with APP_DEMO_SEEDS_ENABLED=false in the environment and
true in the file, the exported value stays false; a value with spaces (Gmail
app password) is still parsed correctly.
Main now ships V9__file_original_filename.sql, so the docs that list V1..V8 and
the migration breakdown were one version behind. Also restore the test-suite
sequence in TESTING.md: PostgresMigrationIT and DemoSeedsGateTest were inserted
before EmailServiceAsyncTest, leaving section 15 at the end.

Verified: ./mvnw test -> 126/126 green; PostgresMigrationIT against PostgreSQL 16
-> 9 migrations applied, ddl-auto=validate OK.
TESTING.md claimed 18 test classes; the tree has 17 classes with @test
(TestS3Config is a fixture, not a suite). Found by the previous review pass
(readability advisory).
CI failed on this branch with:
  Referential integrity constraint violation: file_proposal FOREIGN KEY(id)
  REFERENCES proposals(id) ... ; delete from users where id=?

The H2 database of the test profile is shared by every test class of the same
Spring context, so proposals and files created by earlier classes still point
at the users AuthRateLimitIntegrationTest tries to delete. It only survived
because some class with a full cleanup usually ran in between; Surefire's
filesystem order in CI put GovernanceRulesIntegrationTest right before it.

Clean up in dependency order (same list GlobalJourneyIntegrationTest uses).

Reproduced: ./mvnw test -Dtest=GovernanceRulesIntegrationTest,AuthRateLimitIntegrationTest
-Dsurefire.runOrder=reversealphabetical failed with the same FK violation
before the change and passes after it.

Verified: full suite 126/126 in default order and with
-Dsurefire.runOrder=reversealphabetical.
@AsierCL
AsierCL merged commit cb463f3 into main Nov 5, 2026
4 checks passed
@AsierCL
AsierCL deleted the chore/deploy-readiness branch November 5, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant