Commit Graph
30 Commits
Author SHA1 Message Date
maziggy c51a9772cb ci: bump actions to Node-24-compatible majors
GitHub forces Node-20 actions to run on Node 24 starting 2026-06-02 and
  removes Node 20 from the runner on 2026-09-16. Bumping each action to
  its first Node-24 major now gets us ahead of both deadlines and silences
  the deprecation warnings already firing in every CI run.

  Bumps (across ci.yml, security.yml, codeql.yml, auto-label-area.yml,
  issue-closed.yml, stale.yml):
  - actions/checkout         v4 -> v6
  - actions/setup-python     v5 -> v6
  - actions/setup-node       v4 -> v6
  - actions/cache            v4 -> v5
  - actions/upload-artifact  v4 -> v7
  - actions/github-script    v7 -> v9
  - actions/stale            v9 -> v10
  - docker/setup-buildx      v3 -> v4
  - docker/build-push        v5 -> v7

  Verified each major's breaking-change notes against our usage:
  - setup-node v6 limits auto-cache to npm only; we already pass
    cache: 'npm' explicitly, so nothing changes.
  - github-script v9 drops require('@actions/github'); none of our
    scripts use it (only require('fs') and the injected github/context
    globals).
  - setup-buildx v4 removes deprecated inputs; we call it with no
    inputs.
  - build-push v6 enables build summaries by default; informational,
    can disable via DOCKER_BUILD_SUMMARY=false env if it gets noisy.

  codeql-action stays on v4 (already runs on Node 24). Trivy and
  github-repo-stats are Docker actions and aren't affected by the
  Node-20 deprecation.
2026-05-26 12:45:33 +02:00
maziggy b3b37e8f08 ci(docker): full backend suite in Docker, 4-way matrix shard, GHA cache backend
Earlier patch trimmed the duplicate unit-test re-run from docker-test
  to drop a 5-10 min job that wasn't adding coverage. But "wasn't adding
  coverage" only holds for pure-logic tests — system-touching tests
  (ffmpeg version probes, ftp clients, subprocess shell-outs, locale/
  timezone-sensitive assertions, paths) genuinely can pass on the GHA
  host and fail in python:3.13-slim. Curation via a `docker_env`
  marker is fragile (new tests get forgotten); gating on `main` only
  defers the cost without removing it.

  Instead, run the full backend suite IN Docker on every PR but make
  it fast:

  - New docker-backend-tests job runs the same 4-way pytest-split
    matrix as the host backend-tests, just inside the test image.
  - docker/setup-buildx-action + docker/build-push-action@v5 with
    cache-from/cache-to: type=gha,scope=backend-test persist the
    BuildKit cache (pip-install layer included) across CI runs and
    across the 4 sibling shards. Cold build is ~150s/shard; warm
    build drops to ~10s/shard.
  - fail-fast: false so a single failing shard surfaces the rest's
    output too.

  Total CI wall-clock for a PR push is now gated by docker-test (the
  image-build + integration HTTP smoke + integration test suite job)
  at ~3 min, not by the unit-test re-run anymore.

  The earlier ci.yml step that ran `docker compose run --rm
  backend-test` synchronously in the docker-test job stays removed —
  the new docker-backend-tests matrix covers the same ground and is
  much faster.
2026-05-24 13:31:50 +02:00
maziggy ed905d8406 ci(docker): stop re-running unit tests inside the test image
The "Docker Build" job in ci.yml was running the same 5287 backend
  tests + 2022 frontend tests inside the bambuddy-backend-test /
  bambuddy-frontend-test images that the host-side backend-tests and
  frontend-tests jobs had already run. Same test code, same Python
  version (env.PYTHON_VERSION), same requirements.txt the test image
  installs. On 2-vCPU GHA runners that re-run added 5-10 min of
  wall-clock for zero new coverage — and "frontend tests in Docker"
  added another 2-3 min for the same reason.

  Drop both steps from the CI job. Keep everything that validates the
  Docker IMAGE specifically: production image build, backend module
  import verification, static-files-copied check, integration
  container bring-up + health/API/static HTTP smoke checks, and the
  integration test suite (which IS genuinely Docker-specific — it
  runs against the live container via BAMBUDDY_TEST_URL).

  test_docker.sh keeps the unit-test reruns because devs running it
  locally don't have a separate host-side pytest job to compare
  against.

  Combined with the earlier 4-way pytest-split shard on the host
  backend-tests job, expected PR-push wall-clock drops from
  ~10-12 min to ~3 min, gated on max(backend-tests shard, frontend
  tests, docker-image-build+integration).
2026-05-24 13:19:55 +02:00
maziggy 4fac9ff12c fix(test): stop sys.modules-deleting backend.app.main in test_code_quality
+ ci: shard backend tests 4-way + drop -v for ~3.5x wall-clock speedup

  Root cause of the 4 CI failures on PR #1514 (all in
  test_print_start_assigns_printer_id_to_vp_archive.py +
  test_timelapse_baseline_restart_recovery.py): test_all_modules_importable
  in test_code_quality.py was deleting backend.app.main from sys.modules
  and re-importing it via importlib.import_module. That created NEW
  module-level dicts (_timelapse_baselines, _expected_prints,
  _active_prints, …) and re-ran root_logger.addHandler — hence the
  duplicate log lines at the same microsecond in captured stderr.

  Any sibling test that bound those names via "from backend.app.main
  import _timelapse_baselines" before the reimport now held a reference
  to the OLD dict; production code (reached via "from backend.app.main
  import on_print_start") resolved the symbol through the NEW module
  instance. Production mutated the new dict, the test read the old one,
  the assertion saw None / un-mutated mock_archive.

  Locally with -n 30, xdist load-balanced test_code_quality.py to a
  different worker process so the collision never happened (which is
  why the suite was green for me). CI's -n auto = -n 2 on ubuntu-latest
  made the collision deterministic.

  Fix: drop the "del sys.modules[name]" step. importlib.import_module
  already returns the cached module if cached, or runs the import
  machinery if not — either way, any import-time error surfaces. The
  "fresh import" framing was theatre; in practice every module in the
  list is already imported by other tests/fixtures before this test
  runs, so we were never actually getting a fresh import anyway — just
  destruction.

  CI workflow tightening (separate concern, same PR since both touch
  the test infrastructure):

  - Dropped -v from the pytest invocation. 5300+ "PASSED foo::bar"
    lines per worker were eating ~30-60s of stdout I/O on 2-vCPU
    runners. --tb=short is sufficient for failure context.
  - Sharded backend-tests into a 4-way matrix via pytest-split (new
    dev dep). Each shard runs ~1326 tests in ~95s on a 2-vCPU runner;
    all 4 run in parallel so wall-clock drops from 362s -> ~100s.
  - fail-fast: false on the matrix so a single failing shard doesn't
    hide failures in the other three — PRs see the complete failure
    picture in one push.
2026-05-24 12:50:35 +02:00
maziggy 93118b9c3e chore(ci): also ignore disputed PyJWT CVE-2025-45768 in ci.yml
security.yml had this ignore added in 9d440beb but ci.yml runs its
  own pip-audit step with a separate ignore list. CI was still failing
  on main + dev. Reasoning identical to the security.yml comment —
  disputed by PyJWT maintainers, no fix exists, Bambuddy uses
  secrets.token_urlsafe(64) and rejects short secrets.
2026-05-20 13:22:20 +02:00
maziggy b82cca6c4c Updated .github/workflows/ci.yml 2026-04-12 15:05:47 +02:00
maziggy da2be65abd Housekeeping 2026-03-26 14:08:27 +01:00
maziggy c2cf041af2 Update CI Node.js version from 20 to 22 LTS
Node 20 is being deprecated on GitHub Actions runners.
  Bump to Node 22 (Active LTS) in ci.yml and security.yml.
2026-03-13 15:34:22 +01:00
maziggy 7c0eeed8d5 Both workflows now parse package-lock.json directly instead of trusting npm ls. The lockfile correctly marks minimatch as dev: true and doesn't contain npm/tar at all —
so all three npm-internal packages will be filtered out regardless of which npm version CI uses.
2026-02-20 19:32:07 +01:00
maziggy 4991192246 Updated CI 2026-02-20 19:22:50 +01:00
maziggy 802bfe330a Updated CI 2026-02-20 19:19:20 +01:00
maziggy 101288d1b2 Updated CI 2026-02-18 13:28:33 +01:00
maziggy 1e5b263acb Added -n auto to run tests in parallel via pytest-xdist 2026-02-10 17:57:40 +01:00
maziggy 23d539f284 Fix CI backend-tests failing to collect FTP test suite
CI only installed requirements.txt, missing pyOpenSSL from
requirements-dev.txt. This caused an ImportError on
TLS_FTPHandler during test collection, blocking all
unit/services tests. Also adds pytest-timeout to dev deps
instead of ad-hoc pip install in CI.
2026-02-10 17:49:58 +01:00
maziggy cf19ac8d39 Added two steps to the docker-test job in ci.yml 2026-02-08 07:53:32 +01:00
maziggy 239d0c7748 Updated CI 2026-02-05 12:25:12 +01:00
maziggy d2c720e70f Updated CI 2026-01-29 15:10:34 +01:00
maziggy 51df60cb91 Fixed CI 2026-01-26 15:53:54 +01:00
maziggy 580225a38d Add security scanning to CI pipeline
- Add pip-audit check to PR workflow (non-blocking warning)
- Add npm audit check to PR workflow (non-blocking, high severity only)
- Create scheduled weekly security audit workflow that:
  - Runs strict pip-audit and npm audit
  - Creates/updates GitHub issues when vulnerabilities found
  - Uploads audit results as artifacts
  - Supports manual trigger via workflow_dispatch
2026-01-26 13:21:02 +01:00
maziggy 164d22f2bb Add security scanning to CI pipeline
- Add pip-audit check to PR workflow (non-blocking warning)
- Add npm audit check to PR workflow (non-blocking warning)
- Create scheduled weekly security audit workflow that:
  - Runs strict pip-audit and npm audit
  - Creates/updates GitHub issues when vulnerabilities found
  - Uploads audit results as artifacts
  - Supports manual trigger via workflow_dispatch
2026-01-26 13:18:29 +01:00
maziggy 4babcf6187 Updated CI 2026-01-22 12:32:45 +01:00
maziggy 7bca0d733f Fixed Github CI 2026-01-21 16:02:30 +01:00
maziggy 0d1056ded4 Added timeouts to Github CI runner
- Backend tests: 10 min (step-level)
- Frontend tests: 10 min (step-level)
- Docker tests: 20 min (job-level, since it has multiple build/test steps)
2026-01-21 15:27:24 +01:00
maziggy 8abfaa391a Rename Docker Test job back to Docker Build for branch protection 2026-01-11 07:59:19 +01:00
maziggyandClaude Opus 4.5 02dbc5a84f Add full Docker test suite to CI (matches test_docker.sh)
- Test 1: Build production image, verify imports & static files
- Test 2: Backend unit tests in Docker container
- Test 3: Frontend unit tests in Docker container
- Test 4: Integration tests (health, API, static files)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:53:03 +01:00
maziggyandClaude Opus 4.5 c665c3e6a3 Add Docker integration tests to CI
Match test_docker.sh workflow:
- Build Docker image
- Verify backend imports
- Verify static files exist
- Test health endpoint
- Test API endpoint
- Test static files served

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:47:21 +01:00
maziggyandClaude Opus 4.5 11482dd4d3 Run all backend tests in CI (unit + integration)
Previously only ran tests/unit/, now runs tests/ to match
test_backend.sh workflow (513 tests instead of 239).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:45:12 +01:00
maziggy 1a5d867e14 Enabled Github CI 2026-01-11 07:06:32 +01:00
maziggy b6a7dabbab Disbaled CI temp. 2025-12-11 14:56:04 +01:00
maziggy ff53e62ef8 Add comprehensive automated testing infrastructure
Backend:
  - pytest configuration with async support and coverage
  - Unit tests for notification service (23 tests)
  - Unit tests for smart plug manager (12 tests)
  - Unit tests for archive service (16 tests)
  - Integration tests for API endpoints
  - Fix: notifications now send immediately (digest is summary only)

  Frontend:
  - Vitest configuration with jsdom and coverage
  - MSW for API mocking
  - Component tests for Toggle, Button, Card, ConfirmModal (77 tests)
  - Test utilities with custom render wrapper

  CI/CD:
  - GitHub Actions workflow for automated testing
  - Backend lint, unit tests, integration tests
  - Frontend lint, type-check, unit tests, build
2025-12-11 10:03:40 +01:00