Development and CI/CD¶
This guide is the contributor/operator reference for running, testing and deploying the LeaveMaster monorepo.
Local development¶
Prerequisites¶
- Java 25
- Node.js 22+
- npm
- Git
Optional depending on task:
- Docker / Docker Compose
- Google Cloud CLI
- Terraform >= 1.8
- Firebase CLI for manual Hosting inspection
Backend¶
The backend lives under backend/ and uses the included Gradle wrapper.
Run locally with H2:
Build and test:
build includes the configured JaCoCo coverage verification gate.
Useful endpoints while running locally:
http://localhost:8080/swagger-ui.html
http://localhost:8080/api-docs
http://localhost:8080/h2-console
The local H2 database uses:
Backend configuration¶
Local configuration defaults are in backend/src/main/resources/application.yaml. The production-specific Cloud Run profile is in application-cloudrun.yaml.
Secrets should be provided through process environment variables locally and Secret Manager in production. Do not commit local secret files or place credentials in YAML.
Important local-only or optional variables include:
PLATFORM_ADMIN_PASSWORD
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET
MICROSOFT_CLIENT_ID / MICROSOFT_CLIENT_SECRET / MICROSOFT_TENANT_ID
GH_CLIENT_ID / GH_CLIENT_SECRET
FACEBOOK_CLIENT_ID / FACEBOOK_CLIENT_SECRET
ASSISTANT_ENABLED
SPRING_AI_MODEL_CHAT
OPENAI_API_KEY
OPENAI_MODEL
The assistant is disabled by default.
Frontend¶
The frontend lives under frontend/.
First setup:
Run development server:
The local frontend runs at http://localhost:5173 and .env.example points VITE_API_URL at http://localhost:8080.
Frontend scripts¶
npm run dev
npm run lint
npm run typecheck
npm test
npm run coverage
npm run build
npm run preview
npm run format
npm run build runs TypeScript project compilation before Vite and emits production assets to frontend/dist.
Frontend architecture¶
The SPA uses:
- React 18 and React Router;
- Refine core for resources/data/auth/access-control orchestration;
- Ant Design for the UI;
- a custom credentialed/CSRF-aware HTTP layer;
- Vitest + Testing Library for frontend tests.
Production should normally leave VITE_API_URL unset so API requests remain relative to the Firebase Hosting origin and are rewritten to Cloud Run.
Never put secrets in VITE_*; Vite compiles those values into browser-visible JavaScript.
Running backend + frontend together¶
Terminal 1:
Terminal 2:
Then open:
The local CORS allowlist defaults to that frontend origin.
Docker Compose option¶
To exercise the backend with PostgreSQL locally:
Do not treat Docker Compose credentials as production secrets.
Tests and quality gates¶
Backend gate¶
The Gradle build validates:
- compilation;
- unit/integration/Spring Security tests;
- JUnit platform execution;
- JaCoCo report generation;
- JaCoCo coverage verification.
Changes that affect authentication, RBAC, assistant security, tenant isolation or migrations should include focused tests in addition to general build coverage.
Frontend gate¶
The frontend CI gate runs:
Coverage uses the configured Vitest/V8 thresholds. Do not lower thresholds simply to make a change pass; add tests for the changed behavior.
Important frontend test areas include:
- API/data-provider mappings;
- CSRF/session HTTP behavior;
- authentication/session expiry;
- RBAC/access-control decisions;
- leave workflows;
- Ask LeaveMaster structured reads and confirmation behavior.
GitHub Actions model¶
The workflows are path-aware.
Java CI with Gradle¶
Triggered by backend changes. Responsibilities include:
- Java 25 setup;
- Gradle build/test/coverage;
- JaCoCo artifact/report handling;
- dependency graph submission.
Frontend-only changes should not run this workflow.
Frontend CI and Firebase Hosting¶
Triggered by frontend changes.
On pull requests it validates quality and produces the exact frontend/dist artifact, but it does not deploy production.
On an eligible main push it:
- runs the full frontend quality gate;
- authenticates to Google Cloud through the existing WIF identity;
- deploys the validated build to the configured Firebase Hosting site.
No legacy Firebase token or service-account JSON key is required.
Terraform Validate¶
Triggered for Terraform/infrastructure changes. It verifies formatting/init/validation independently from the production deployment workflow.
Deploy to Cloud Run¶
Triggered by backend, Terraform, Docker/container or deployment-workflow changes on main, and can also be started manually.
High-level flow:
flowchart TD
Start[Push to main / manual run]
Auth[WIF authentication]
Init[Terraform init with production GCS backend]
Validate[fmt + validate]
Prereq[Targeted prerequisite provisioning]
Jar[Gradle bootJar]
Build[Cloud Build image tagged current Git SHA]
Plan[Full Terraform plan deploy_service=true]
Protect[Protected-resource plan check]
Apply[Terraform apply]
Run[Cloud Run revision]
Start --> Auth --> Init --> Validate --> Prereq --> Jar --> Build --> Plan --> Protect --> Apply --> Run
The current image URI is constructed from the deployment variables and current Git SHA rather than read from a potentially stale state output after targeted Terraform operations.
The protected-plan check refuses Terraform plans that would delete/replace critical backend resources such as Cloud Run, service accounts, Artifact Registry, storage buckets or managed secrets.
Terraform working model¶
Terraform lives under infra/terraform/.
Production state is remote in GCS. GitHub Actions initializes the backend with the production bucket and prefix before planning/applying.
Terraform manages infrastructure declarations and Secret Manager bindings, not plaintext secret values.
Typical local validation:
For actual production state/plan work, use the documented remote backend and production variables rather than a local ad-hoc state.
Production GitHub environment¶
Production deployment settings belong in the GitHub production environment. Current core variables include GCP project/region, Supabase host/user, Terraform state bucket, WIF provider/service account, Firebase settings and runtime feature toggles.
See docs/environments-and-domains.md for the authoritative list and meanings.
Secret values do not belong in GitHub environment variables. Database, PlatformAdmin and OpenAI secret values belong in Google Secret Manager.
Production deployment ownership¶
| Concern | Owner |
|---|---|
| Frontend static release | Firebase Hosting workflow |
| Backend image build | Cloud Build through Cloud Run workflow |
| Backend runtime | Terraform / Cloud Run |
| Database schema | Flyway at backend startup |
| Runtime secret values | Google Secret Manager |
| Runtime secret bindings/IAM | Terraform |
| DNS for custom domain | Domain/DNS provider + Firebase verification |
| TLS for Firebase custom domain | Firebase Hosting |
| OAuth callback registration | External IdP configuration |
Safe contribution workflow¶
- Branch from current
main. - Make the smallest coherent change.
- Run relevant local checks where practical.
- Open a PR.
- Let path-specific CI finish.
- Review any infrastructure plan implications separately from application tests.
- Merge only after required checks pass.
- For runtime/configuration work, observe the corresponding
maindeployment workflow and verify production behavior.
Related guides¶
docs/architecture.mddocs/environments-and-domains.mddocs/cloudrun-deployment.mddocs/assistant-security.mddocs/troubleshooting.md