Commit graph

44 commits

Author SHA1 Message Date
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
bda0c703d2
ci: install postgresql-client for pg_isready command
- Add postgresql-client to system dependencies
- Fixes 'pg_isready: command not found' error in CI
- Required for database readiness check before tests
2026-03-05 10:20:55 -06:00
21572d8873
fix: use service hostname instead of localhost for PostgreSQL
- Remove port mapping (5432:5432) to avoid port conflicts on runner
- Use 'postgres' hostname instead of 'localhost' to access service
- Service containers in Actions are accessible via their service name
- Fixes 'port is already allocated' error on self-hosted runners
2026-03-05 10:04:56 -06:00
996790bebf
perf: optimize CI caching for faster builds
- Split deps and _build into separate caches for better granularity
- Add Elixir/OTP version to cache keys for version-specific builds
- Include lib/**/*.ex hash in build cache for change detection
- Add apt package caching to skip redundant system dependency installs
- Use version-type: strict in setup-beam for consistent versions
- Improves cache hit rate and reduces build times significantly
2026-03-05 10:03:45 -06:00
56d9878130
ci: add explicit wait for PostgreSQL and database creation step
- Add pg_isready wait loop to ensure PostgreSQL service is fully ready
- Run mix ecto.create explicitly before tests to prevent connection errors
- Fixes 'connection refused' errors when database service is still starting
2026-03-05 10:02:39 -06:00
ee4a7b8040
ci: upgrade to Elixir 1.19.5 and OTP 28.3 to match .tool-versions 2026-03-05 09:32:24 -06:00
88ead53d80
ci: update to ubuntu-22.04 from deprecated ubuntu-20.04
Ubuntu 20.04 is deprecated and has limited support.
Using ubuntu-22.04 for better compatibility and support.
2026-03-05 09:24:17 -06:00
079c47198f
fix: use GitHub URL for erlef/setup-beam action
Forgejo doesn't have this action in its registry, so we need to
use the full GitHub URL to fetch it from GitHub's action registry.
2026-03-05 09:21:28 -06:00
c225078668
ci: add comprehensive quality checks before Docker build
Added test job that must pass before building Docker image:
- Code formatting check (mix format --check-formatted)
- Compilation with warnings as errors
- Credo static analysis (--strict mode)
- Full test suite with PostgreSQL + TimescaleDB

Build job now depends on test job passing (needs: test).

This prevents broken code from being deployed to production.
2026-03-05 09:14:23 -06:00
f1b61513d6
fix: handle concurrent pushes in build workflow
Add git pull --rebase before pushing deployment.yaml update
to handle race conditions when multiple builds run.
2026-03-04 17:33:26 -06:00
044e21a823
fix: downgrade checkout to v4 and add Docker mirror to build.yaml
- Use actions/checkout@v4 to avoid punycode deprecation warning
- Add docker-mirror.mcintire.me configuration for faster builds
2026-03-04 17:30:48 -06:00
afafe3fa09
chore: remove redundant build-deploy.yml workflow
Keep build.yaml which updates k8s/deployment.yaml for FluxCD GitOps.
2026-03-04 17:30:34 -06:00
e29981b307
Revert "feat: migrate deployment to Forgejo Actions from GitLab CI"
This reverts commit 27261f107b.
2026-03-04 17:29:36 -06:00
27261f107b
feat: migrate deployment to Forgejo Actions from GitLab CI
Consolidated build and deployment into Forgejo Actions workflow:
- Added deployment job that runs after successful build
- Uses kubectl to deploy to Kubernetes cluster
- Sets image and deployment timestamp
- Removed GitLab CI configuration

Required setup:
- Add KUBECONFIG secret to Forgejo (base64 encoded kubeconfig file)
- Secret should contain context: towerops/towerops:home-cluster-agent
2026-03-04 17:27:38 -06:00
49d11b601b
fix: downgrade checkout action to v4 to avoid punycode deprecation
The punycode module deprecation warning in Node.js is coming from
actions/checkout@v6. Downgrading to v4 which is more stable and
doesn't use the deprecated punycode module.
2026-03-04 17:16:05 -06:00
0a07d6e09e
Revert "fix: resolve Forgejo CI Docker daemon access issues"
This reverts commit 54280fd733.
2026-03-04 17:11:52 -06:00
54280fd733
fix: resolve Forgejo CI Docker daemon access issues
Fixed two CI/CD issues:

1. Docker daemon not accessible
   - Added explicit dockerd startup step
   - Configured buildx to use docker-container driver
   - Driver creates its own buildkitd instance

2. Node.js punycode deprecation warning
   - Downgraded actions/checkout from v6 to v4
   - v4 is more stable and doesn't use deprecated punycode module

Changes ensure the workflow runs successfully in Forgejo Actions runners
that may not have Docker socket access by default.
2026-03-04 17:09:28 -06:00
f761290ed7
chore(config): add Renovate and build workflows 2026-03-03 16:54:19 -06:00
b7e866e560
Route BuildKit pulls through docker-mirror for caching 2026-02-14 15:50:20 -06:00
24d6a2fd44
Add Docker Hub login to CI for BuildKit rate limit avoidance 2026-02-14 15:49:17 -06:00
4610d86043
Use docker-mirror.mcintire.me as pull-through cache for CI builds 2026-02-14 15:28:32 -06:00
8d00a04187
feat: add FluxCD image automation, fix Preseem duplicate AP crash
Switch deployment pipeline from GitLab Agent kubectl to FluxCD image
automation. CI now only builds and pushes tagged images to Forgejo
registry; FluxCD detects new tags and updates the deployment manifest.

Fix Ecto.MultipleResultsError on /dashboard when a device has multiple
Preseem access point records by using limit(1) instead of Repo.get_by.
2026-02-14 10:30:12 -06:00
ab8f0e472d
fix: use registry cache with mode=max for full build stage caching
Replace inline cache with dedicated buildcache tag that stores all
intermediate builder layers. Unchanged stages like deps and compile
will be pulled from cache instead of rebuilt.
2026-02-13 17:41:55 -06:00
62b1487936
fix: remove container spec, let runner provide Node.js and Docker
Runner v12.6.4 defaults to node:lts image which includes Node.js.
The explicit container block prevented Docker socket access needed
for image builds.
2026-02-13 17:09:20 -06:00
549498b48f
fix: add node container and update actions for Forgejo CI
Add node:22-bookworm container image since ubuntu:latest lacks Node.js
required by JavaScript-based actions. Update checkout to v6 and
build-push-action to v6.
2026-02-13 16:44:53 -06:00
891fb04f5a
change runner for forgejo 2026-02-03 14:06:24 -06:00
7c5493b31f
forejo ci update 2026-02-03 14:04:55 -06:00
6505e958cb
add forgejo ci 2026-02-03 13:55:19 -06:00