fix(ci): two persistent CI failures — date-buckets timezone + Testcontainers Docker #476

Closed
opened 2026-05-07 20:26:28 +02:00 by marcel · 1 comment
Owner

Context

Two unrelated CI failures block every PR merge. Both are pre-existing (present on main since at least run 1374) and are not caused by feature code.


Failure 1 — date-buckets.spec.ts (frontend, 2 tests)

Affected tests (src/lib/shared/utils/date-buckets.spec.ts):

  • bucketByDay > returns "today" at exact midnight start of today
  • bucketByDay > returns "yesterday" for any time on the previous day

Root cause: startOfDay() in date-buckets.ts:12 uses Date.setHours(0, 0, 0, 0), which sets midnight in the system's local timezone. The CI runner runs in UTC. Two test cases pass midnight Berlin-time dates (+02:00), which are 22:00 UTC the previous day:

Test input UTC value UTC result Expected
2026-04-22T00:00:00+02:00 April 21 22:00 UTC → April 21 UTC yesterday today
2026-04-21T00:00:00+02:00 April 20 22:00 UTC → April 20 UTC (= Mon) thisWeek yesterday

The function logic is correct — it's the runner timezone that diverges from the test assumptions.

Fix: Add TZ: Europe/Berlin to the env: block of the frontend test CI step in the workflow YAML. One line, zero code changes.

# .gitea/workflows/ci.yml (frontend test step)
env:
  TZ: Europe/Berlin

Failure 2 — Backend Unit Tests (234 errors)

Affected tests: All integration test classes that use Testcontainers (PersonRepositoryTest, PersonServiceIntegrationTest, RelationshipServiceIntegrationTest, RenameUsersToAppUsersMigrationTest, …)

Root cause: Testcontainers cannot find the Docker daemon in the CI runner container:

Could not find a valid Docker environment.
Please see logs and check configuration

All 234 errors are a cascade: the first context load fails, then every subsequent test class is skipped with ApplicationContext failure threshold (1) exceeded.

The OCR Service Tests job (pure unit tests, no Testcontainers) passes every time, confirming the runner itself works — only Docker-in-Docker is missing.

Fix: Configure the self-hosted runner to expose Docker to the job container. Two options:

  • Option A (preferred): Mount the host Docker socket into the runner's job container:
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    
  • Option B: Enable privileged: true on the job container so Testcontainers can spin up its own Docker daemon (DinD).

Acceptance criteria

  • date-buckets.spec.ts passes in CI (both failing tests green)
  • Backend integration tests pass in CI (Testcontainers can start postgres:16-alpine)
  • No other tests regress
## Context Two unrelated CI failures block every PR merge. Both are pre-existing (present on `main` since at least run 1374) and are not caused by feature code. --- ## Failure 1 — `date-buckets.spec.ts` (frontend, 2 tests) **Affected tests** (`src/lib/shared/utils/date-buckets.spec.ts`): - `bucketByDay > returns "today" at exact midnight start of today` - `bucketByDay > returns "yesterday" for any time on the previous day` **Root cause:** `startOfDay()` in `date-buckets.ts:12` uses `Date.setHours(0, 0, 0, 0)`, which sets midnight in the **system's local timezone**. The CI runner runs in UTC. Two test cases pass midnight Berlin-time dates (`+02:00`), which are 22:00 UTC the previous day: | Test input | UTC value | UTC result | Expected | |---|---|---|---| | `2026-04-22T00:00:00+02:00` | April 21 22:00 UTC → April 21 UTC | `yesterday` | `today` | | `2026-04-21T00:00:00+02:00` | April 20 22:00 UTC → April 20 UTC (= Mon) | `thisWeek` | `yesterday` | The function logic is correct — it's the runner timezone that diverges from the test assumptions. **Fix:** Add `TZ: Europe/Berlin` to the `env:` block of the frontend test CI step in the workflow YAML. One line, zero code changes. ```yaml # .gitea/workflows/ci.yml (frontend test step) env: TZ: Europe/Berlin ``` --- ## Failure 2 — Backend Unit Tests (234 errors) **Affected tests:** All integration test classes that use Testcontainers (`PersonRepositoryTest`, `PersonServiceIntegrationTest`, `RelationshipServiceIntegrationTest`, `RenameUsersToAppUsersMigrationTest`, …) **Root cause:** Testcontainers cannot find the Docker daemon in the CI runner container: ``` Could not find a valid Docker environment. Please see logs and check configuration ``` All 234 errors are a cascade: the first context load fails, then every subsequent test class is skipped with `ApplicationContext failure threshold (1) exceeded`. The `OCR Service Tests` job (pure unit tests, no Testcontainers) passes every time, confirming the runner itself works — only Docker-in-Docker is missing. **Fix:** Configure the self-hosted runner to expose Docker to the job container. Two options: - **Option A (preferred):** Mount the host Docker socket into the runner's job container: ```yaml volumes: - /var/run/docker.sock:/var/run/docker.sock ``` - **Option B:** Enable `privileged: true` on the job container so Testcontainers can spin up its own Docker daemon (DinD). --- ## Acceptance criteria - [ ] `date-buckets.spec.ts` passes in CI (both failing tests green) - [ ] Backend integration tests pass in CI (Testcontainers can start `postgres:16-alpine`) - [ ] No other tests regress
marcel added the bugdevopstest labels 2026-05-07 20:26:33 +02:00
Author
Owner

Implemented in PR #494 — branch fix/issue-476-ci-failures.

Commits:

  • 42fda767fix(ci): add TZ=Europe/Berlin to frontend test step
  • 1333e690fix(ci): expose Docker socket env vars for Testcontainers in backend job
  • ab7fe81bci: track act_runner config with Docker socket mount

Verified locally:

  • TZ=UTC npx vitest run date-buckets.spec.ts → 2 failures (confirms the bug)
  • TZ=Europe/Berlin npx vitest run date-buckets.spec.ts → 7/7 green (confirms the fix)

The Testcontainers fix (DOCKER_HOST + TESTCONTAINERS_RYUK_DISABLED) requires a CI run to verify. The runner-config.yaml with the Docker socket mount is now tracked in the repo.

Implemented in PR #494 — branch `fix/issue-476-ci-failures`. **Commits:** - `42fda767` — `fix(ci): add TZ=Europe/Berlin to frontend test step` - `1333e690` — `fix(ci): expose Docker socket env vars for Testcontainers in backend job` - `ab7fe81b` — `ci: track act_runner config with Docker socket mount` **Verified locally:** - `TZ=UTC npx vitest run date-buckets.spec.ts` → 2 failures (confirms the bug) - `TZ=Europe/Berlin npx vitest run date-buckets.spec.ts` → 7/7 green (confirms the fix) The Testcontainers fix (`DOCKER_HOST` + `TESTCONTAINERS_RYUK_DISABLED`) requires a CI run to verify. The runner-config.yaml with the Docker socket mount is now tracked in the repo.
Sign in to join this conversation.
No Label bug devops test
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#476