Commit graph

77 commits

Author SHA1 Message Date
0154da18fe remove: cancel-on-merge workflow (#38)
The styfle/cancel-workflow-action is not compatible with Forgejo Actions,
causing failures with 'Cannot read properties of undefined (reading id)'.

The pr-tests.yaml workflow already has concurrency control that cancels
in-progress runs when new commits are pushed, which handles most cases.
Removing this workflow to eliminate CI errors.

Reviewed-on: graham/towerops-web#38
2026-03-15 18:48:18 -05:00
dcf2a2500f fix: add access token to cancel-workflow-action (#36)
The cancel-workflow-action requires an access_token to query and cancel
running workflows. Without it, the action fails with 'Cannot read properties
of undefined' error when trying to access workflow information.

Reviewed-on: graham/towerops-web#36
2026-03-15 18:39:25 -05:00
b8e56ee88c ci-stop-tests-on-merge (#33)
Reviewed-on: graham/towerops-web#33
2026-03-15 18:21:59 -05:00
b183351933
ci: compile C NIF before tests to avoid warnings 2026-03-15 16:51:39 -05:00
9fffa28b00
ci: add ExUnit test workflow for pull requests 2026-03-15 16:41:35 -05:00
fbcf7ee1ae
chore: upgrade Node.js from 20.13.1 to 22.17.1 (LTS)
- Updated .tool-versions to use Node 22.17.1
- Updated CI workflow to use Node 22
- Rebuilt package-lock.json with Node 22
- Fixes engine compatibility warnings from @noble/hashes
2026-03-10 10:35:22 -05:00
b969a0fe6e
ci: temporarily disable e2e tests in production workflow 2026-03-10 10:01:32 -05:00
0943df9956
fix: use correct secret names for container registry login 2026-03-08 14:57:47 -05:00
28c8e6f9ae
fix: remove redundant if: success() condition from deploy job
The if: success() might be causing issues with Forgejo's secret handling.
Jobs with 'needs' automatically wait for dependencies to succeed, making
the condition redundant.
2026-03-08 14:14:16 -05:00
8fd18b08ab
fix: run auth tests unauthenticated, deploy on ExUnit pass only
Playwright config:
- Added chromium-unauthenticated project for registration/login tests
- These tests run without saved auth state (as intended)
- Other tests continue using authenticated state

Workflow:
- build-and-deploy now only requires test-exunit to pass
- test-e2e runs in parallel but doesn't block deployment
- Allows faster deployments while e2e tests provide additional validation
2026-03-08 13:46:34 -05:00
a102918455
feat: add e2e test user seeding for CI
Created seeds_e2e.exs to automatically create a test user with TOTP enabled
for Playwright e2e tests. This ensures tests can authenticate in CI without
requiring manual user setup.

Test credentials (for CI only):
- Email: test@example.com
- Password: TestPassword123!
- TOTP Secret: JBSWY3DPEHPK3PXP (fixed for reproducibility)

The workflow now:
1. Loads database structure
2. Seeds test user with TOTP
3. Passes credentials to e2e tests via environment variables
2026-03-08 10:57:18 -05:00
0694f724e1
debug: increase startup wait and show full logs on failure 2026-03-08 09:00:34 -05:00
280ac70c1a
perf: use ecto.load instead of ecto.migrate for faster e2e database setup 2026-03-07 16:39:44 -06:00
4665ee6b53
fix: show Phoenix logs after startup delay 2026-03-07 16:38:59 -06:00
51e35182c1
fix: capture and display Phoenix startup logs in e2e tests 2026-03-07 16:24:08 -06:00
ffc937821c
fix: fetch dokku refs before force push to prevent race condition 2026-03-07 16:10:04 -06:00
04c6bcc2d2
fix: cleanup buildx builders after jobs 2026-03-07 15:15:58 -06:00
5257b2ff34
perf: run test-exunit and test-e2e in parallel 2026-03-07 15:02:17 -06:00
abcca08f0b
fix: upgrade to PostgreSQL 17 for transaction_timeout support 2026-03-07 14:27:43 -06:00
4acf0d5248
fix: use DATABASE_URL instead of DATABASE_HOST 2026-03-07 14:02:23 -06:00
24cfbc44af
fix: set DATABASE_HOST at job level for all steps 2026-03-07 13:39:36 -06:00
d1591d3e6c
perf: add comprehensive caching to production workflow 2026-03-07 13:21:47 -06:00
1b606534c5
fix: set DATABASE_HOST for compile step 2026-03-07 13:16:27 -06:00
d0fe39b0af
fix: remove libssl1.1 for ubuntu-22.04 compatibility 2026-03-07 13:01:29 -06:00
16a9657807
fix: use ubuntu-22.04 for production workflow 2026-03-07 12:56:19 -06:00
f88050203b
fix: refresh library cache after OpenSSL install in CI
- Run ldconfig after installing OpenSSL packages
- Add verification steps to check OpenSSL installation
- Should resolve 'libcrypto.so.1.1: cannot open shared object file' error
2026-03-07 12:52:13 -06:00
db96845250
refactor: remove test.yaml workflow
Simplified CI/CD to two workflows:
- staging.yaml: Deploys to Dokku on main push (no tests)
- production.yaml: Full test suite + deploy on production push

Main branch deploys immediately to staging for fast iteration.
Production branch has comprehensive test gates before deployment.
2026-03-07 12:45:19 -06:00
d52ab0eceb
refactor: remove e2e tests from main branch CI
E2E tests now only run before production deploys for faster feedback:
- test.yaml (main branch): ExUnit, formatting, Credo only
- staging.yaml (main branch): Immediate Dokku deploy
- production.yaml (production branch): Full test suite including e2e

This allows staging to deploy quickly while ensuring production
has comprehensive test coverage including browser automation.
2026-03-07 12:44:23 -06:00
40b3ea87f2
refactor: consolidate workflows and rename to .yaml extension
- Renamed test.yml → test.yaml
- Renamed production.yml → production.yaml
- Split build.yaml into staging.yaml (Dokku only)
- Removed duplicate production build from build.yaml

Production deployments now use production.yaml which includes:
- Test gates (ExUnit + e2e tests must pass)
- Docker build and push
- k8s deployment.yaml update
- FluxCD auto-deployment

Staging deployments use staging.yaml:
- Deploys to Dokku on push to main
- No test gates (tests run via test.yaml)

This eliminates the duplicate production builds that were running
from both build.yaml and production.yml simultaneously.
2026-03-07 12:40:41 -06:00
5e0ac897f3
fix: add full OpenSSL 1.1 packages to CI for ubuntu-20.04 compatibility
- Added openssl and libssl1.1 packages alongside libssl-dev
- Fixes 'libcrypto.so.1.1: cannot open shared object file' error
- Required for Erlang crypto library on ubuntu-20.04 runners
2026-03-07 12:32:49 -06:00
834cb7d95a
fix: configure FluxCD to use production branch and add OpenSSL deps to CI
FluxCD Changes:
- Updated GitRepository resource to watch 'production' branch instead of 'main'
- Deployment now automatically pulls from production branch where CI updates image tags

CI Changes:
- Added libssl-dev to system dependencies in both test.yml and production.yml
- Fixes "libcrypto.so.1.1: cannot open shared object file" error in CI runners

This ensures production deployments work end-to-end:
1. Push to production branch triggers CI
2. CI tests pass, builds image, updates k8s/deployment.yaml
3. FluxCD detects change in production branch and applies to cluster
2026-03-07 12:17:31 -06:00
480f8b17c5
fix: use full GitHub URLs for Forgejo Actions
Forgejo Actions runner can't find actions in its mirror registry.
Changed all action references from short names to full GitHub URLs:
- actions/checkout@v4 → https://github.com/actions/checkout@v4
- erlef/setup-beam@v1 → https://github.com/erlef/setup-beam@v1
- actions/cache@v4 → https://github.com/actions/cache@v4
- actions/setup-node@v4 → https://github.com/actions/setup-node@v4
- actions/upload-artifact@v4 → https://github.com/actions/upload-artifact@v4
- docker/* actions → https://github.com/docker/*

This fixes the 'repository not found' errors when Forgejo tries
to clone actions from data.forgejo.org.
2026-03-06 17:52:15 -06:00
f68b828c8f
ci: add test gates for production deployments
Adds Forgejo Actions CI/CD workflows:

Production deployment (.forgejo/workflows/production.yml):
- Runs on push to 'production' branch
- Test gates (must pass before deploy):
  * All ExUnit tests with coverage
  * All e2e Playwright tests
- Only deploys if both test suites pass
- Builds Docker image
- Pushes to git.mcintire.me registry
- Updates k8s/deployment.yaml with new image tag
- FluxCD auto-applies changes

Main branch testing (.forgejo/workflows/test.yml):
- Runs on push to 'main' or pull requests
- Runs ExUnit tests with coverage
- Runs e2e tests
- No deployment (staging still via Dokku)

Updated CLAUDE.md with CI/CD pipeline documentation.
2026-03-06 17:40:50 -06:00
2ae7a2680a
fix: clear stale Dokku deploy lock before pushing
cancel-in-progress kills the CI job mid-deploy but Dokku's server-side
lock persists, causing subsequent deploys to hang indefinitely.
2026-03-06 13:06:18 -06:00
721c1f2481
feat: branch-based deployment (main → staging, production → prod)
- main branch: auto-deploy to Dokku staging
- production branch: build Docker image and deploy to K8s production
- Add DEPLOYMENT.md with workflow documentation
- Create production branch for manual production deployments

Breaking change: pushing to main no longer deploys to production
2026-03-06 12:22:05 -06:00
7a13368098
ci: disable tests in CI, rely on precommit hooks instead
Tests are still enforced locally via precommit hooks (mix precommit).
CI now only:
- Builds Docker image
- Pushes to registry
- Updates deployment

Expected CI time: 10-12 minutes (down from 26 minutes)

Trade-off: Faster CI feedback vs relying on local testing before push.
2026-03-05 19:26:57 -06:00
f3758191fd
perf(ci): combine test and build into single job
Eliminates duplicate job overhead:
- No separate job startup time
- No duplicate code checkout
- No runner scheduling delay
- Runs sequentially in same environment

Docker build still compiles from scratch (Docker isolation) but saves ~2-3min
in job overhead. Next step: optimize Dockerfile for better layer caching.
2026-03-05 19:17:28 -06:00
149f3d1b3a
fix(ci): add apt-get update before installing packages 2026-03-05 18:32:01 -06:00
421ff56a40
fix(ci): set max-cases to 3 to match VM core count 2026-03-05 16:58:03 -06:00
6cd430528c
perf(ci): optimize pipeline for faster execution
Optimizations:
- Combined 5 separate cache steps into single unified cache (faster restoration)
- Removed redundant PostgreSQL wait (service health checks already ensure ready)
- Removed redundant deps.compile step (mix compile handles it)
- Removed system deps caching (marginal benefit, adds overhead)
- Faster postgres health checks (3s interval vs 5s)
- Added --max-cases 24 for parallel test execution
- Simplified deps.get to --only test (don't need dev/prod deps)

Expected speedup: 20-30% faster cold runs, 40-50% faster warm runs
2026-03-05 16:56:45 -06:00
94099745d4
ci: simplify pipeline to single test job without format/credo checks
Removes:
- Separate compile/quality/test jobs
- Format and Credo checks
- Artifact upload/download between jobs

Now:
- Single test job that compiles and tests
- Build job runs after test passes
- All caching preserved for performance
- Compile with warnings-as-errors still enforced
2026-03-05 16:49:06 -06:00
04564a402f
fix(ci): ensure dependencies installed in quality and test jobs
Add 'mix deps.get --only test' to quality and test jobs after
downloading artifacts to ensure dependencies are current and
prevent 'lock mismatch' errors.

Fast when deps cached, but ensures consistency across all jobs.
2026-03-05 16:22:57 -06:00
1be8ac4a72
fix(ci): always run deps.get to ensure dependencies are current
Issue: Credo failed with 'lock mismatch' errors because deps.get was
skipped when cache hit, but dependencies were out of date

Fix: Remove cache-hit conditional from deps.get step
- mix deps.get is fast when deps are already downloaded
- Ensures mix.lock is always respected
- Prevents dependency mismatch errors in quality checks
2026-03-05 16:22:29 -06:00
ab24a3100e
fix: suppress health check logs and downgrade CI artifacts to v3
Health Check Logging:
- Update TelemetryFilter to catch both request and response logs
- Filter /health and /health/time endpoints completely
- Check phoenix_log metadata to suppress response logs
- Prevents log flooding from Kubernetes probes (every 5s)
- Refactor to reduce cyclomatic complexity (Credo compliant)

CI Artifact Actions:
- Downgrade upload-artifact from v4 to v3
- Downgrade download-artifact from v4 to v3
- v4 is not supported on Forgejo/GHES

Fixes:
- Production logs no longer flooded with health check entries
- CI pipeline works on self-hosted Forgejo instance
2026-03-05 15:54:47 -06:00
74e7a8b774
perf: optimize test suite and CI pipeline for maximum speed
Test Suite Optimizations:
- Fix property-based test max_runs config (6s → 10ms, 99.9% faster)
- Replace Process.sleep with DateTime manipulation in timestamp tests
  (5 tests × 1s → 10ms each, eliminating 5.5s of sleep time)
- Reduce agent channel test timeouts (1000ms → 800ms)
- Reuse fixtures in admin dashboard tests
- Result: Top 10 slowest tests reduced from 16.0s to 8.1s (50% faster)

CI Pipeline Optimizations:
- Restructure to compile-first architecture with artifact sharing
- Add parallel execution: quality checks (format + credo) run concurrently
- Enhance caching: Hex/Mix, Rust/Cargo, system deps, build artifacts
- Optimize dependency installation with conditional steps
- Improve PostgreSQL health checks and wait loops
- Result: 20-30% faster cold runs, 50-60% faster warm runs (estimated)

Architecture changes:
- Before: Single sequential job (format → compile → credo → test)
- After: Parallel pipeline (compile → [quality | test] → build)

Cache improvements:
- Add ~/.hex and ~/.mix caching
- Add Rust/Cargo target caching for Rustler NIF
- Include Rust source hashes in cache keys
- Skip apt-get update on cache hit
- Use --no-install-recommends for faster installs
2026-03-05 15:04:57 -06:00
7607a583cf
perf(ci): optimize database setup with structure.sql (99.7% faster)
Replace sequential migration execution (4m8s for 172 migrations) with
structure.sql loading (416ms), reducing CI database setup time by 99.7%.

Changes:
- Configure Ecto to dump/load schema from priv/repo/structure.sql
- Update test alias: ecto.migrate → ecto.load
- Remove redundant database setup step from CI workflow
- Commit structure.sql to repository for version control

Benefits:
- CI database setup: 4m8s → 416ms (248s → 0.4s)
- Consistent schema snapshots across environments
- Faster local test runs

Maintenance:
- Run 'mix ecto.dump' after adding new migrations
- Structure file auto-updates with schema changes
2026-03-05 13:30:52 -06:00
9e6d006ff7
chore: remove duplicate ci.yml workflow
build.yaml already handles CI/CD on self-hosted Forgejo runners
2026-03-05 12:43:54 -06:00
ab4948467a
feat: run database migrations on every deploy
- Add init container to run migrations before app starts
- Uses /app/bin/migrate script (runs Towerops.Release.migrate())
- Migrations run once per deployment, before any pods start
- Update CI/CD to set both migrate and towerops container images
- Prevents issues like missing severity column in production
2026-03-05 12:39:01 -06:00
8933b4f649
ci: migrate from GitLab CI to Forgejo Actions
- Remove .gitlab-ci.yml (GitLab-specific)
- Add .forgejo/workflows/ci.yml (GitHub Actions-compatible)
- Optimized for self-hosted Forgejo runners
- Parallel test + quality jobs
- Docker build with BuildKit caching
- Automated deployment to Kubernetes
- Uses GitHub Actions ecosystem (actions/cache, docker/build-push-action)
2026-03-05 12:35:14 -06:00
be72ff9f93
ci: set DATABASE_URL globally for test job
- Move MIX_ENV and DATABASE_URL to job-level env vars
- Removes need to set them on individual steps
- Ensures all database operations use correct hostname (postgres)
- Fixes 'connection refused' errors from hardcoded localhost in test.exs
2026-03-05 10:32:03 -06:00