Skip to content

ci: clean up cancelled real-test services and cap bcrypt cost in tests - #44

Merged
agentHits merged 2 commits into
AgentHits-Devfrom
test/scope-real-test-cleanup
Oct 7, 2026
Merged

agentHits merged 2 commits into
AgentHits-Devfrom
test/scope-real-test-cleanup

Conversation

@agentHits

@agentHits agentHits commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

What:

  • App names in application.real.test.ts carry CHECKOUT_ID, the first 8 chars
    of sha256(process.cwd()): real--- and real-nixpacks-.
  • pull-request.yml adds an if: always() step to the test job that derives
    the same id from the apps/dokploy path and removes only the real-*-
    swarm services.
  • test/setup.ts caps bcrypt cost at 4 for all tests (production code is unchanged), and the 30 s timeout added in ci: run owner pull request checks on the self-hosted mac mini #38 is dropped again.
    Why:
  • Tests remove their own services, but a cancelled run (new push, timeout)
    skips that, and 0/1 services pile up on the Mac mini while swarm keeps
    trying to start them.
  • Docker on the Mac mini is shared by all runners, so removing every real-*
    service would break a neighbouring PR's tests.
    Risks:
  • If the tests ever change vitest's working directory, the ids diverge and
    the step simply removes nothing.
    Checks:
  • Commands and results: printf <runner 2 apps/dokploy path> | shasum -a 256
    gives 6b7e0626, matching real-nixpacks-6b7e0626 from the CI log; grep picks
    only names with that id; xargs -r runs nothing on empty input; biome, tsc
    on the file and YAML parsing are clean.
  • Limitations: cancelling a run mid-test was not exercised by hand.

🤖 Generated with Claude Code

agentHits and others added 2 commits October 7, 2026 10:29
Что:
- Имена приложений в application.real.test.ts содержат CHECKOUT_ID - первые
  8 символов sha256 от process.cwd(): real-<вид>-<id>-<время> и
  real-nixpacks-<id>.
- В pull-request.yml у задачи test добавлен шаг с if: always(), который
  считает тот же id из пути apps/dokploy и удаляет только swarm-сервисы
  real-*-<id>.
Зачем:
- Тесты удаляют свои сервисы сами, но при отмене прогона (новый push,
  таймаут) уборка не выполняется, и на Mac mini копятся сервисы 0/1,
  которые swarm безуспешно пытается запустить.
- Docker на Mac mini общий для всех раннеров, поэтому удалять все real-*
  нельзя: это сломало бы тесты соседнего PR.
Риски:
- Если тесты поменяют рабочую папку vitest, id в шаге и в тестах
  разойдутся, и шаг просто ничего не удалит.
Проверки:
- Команды и результаты: printf <путь apps/dokploy раннера 2> | shasum -a 256
  даёт 6b7e0626 - совпадает с real-nixpacks-6b7e0626 из лога CI; grep
  выбирает только имена с этим id; xargs -r на пустом вводе ничего не
  запускает; biome, tsc по файлу и разбор YAML - без ошибок.
- Ограничения: отмена прогона посреди тестов вручную не проверялась.

What:
- App names in application.real.test.ts carry CHECKOUT_ID, the first 8 chars
  of sha256(process.cwd()): real-<kind>-<id>-<time> and real-nixpacks-<id>.
- pull-request.yml adds an if: always() step to the test job that derives
  the same id from the apps/dokploy path and removes only the real-*-<id>
  swarm services.
Why:
- Tests remove their own services, but a cancelled run (new push, timeout)
  skips that, and 0/1 services pile up on the Mac mini while swarm keeps
  trying to start them.
- Docker on the Mac mini is shared by all runners, so removing every real-*
  service would break a neighbouring PR's tests.
Risks:
- If the tests ever change vitest's working directory, the ids diverge and
  the step simply removes nothing.
Checks:
- Commands and results: printf <runner 2 apps/dokploy path> | shasum -a 256
  gives 6b7e0626, matching real-nixpacks-6b7e0626 from the CI log; grep picks
  only names with that id; xargs -r runs nothing on empty input; biome, tsc
  on the file and YAML parsing are clean.
- Limitations: cancelling a run mid-test was not exercised by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Что:
- __test__/setup.ts подменяет bcrypt.hash: числовой cost ограничен 4,
  алгоритм и формат хэша остаются настоящими. Код сервиса не меняется
  (в продакшене по-прежнему cost 12).
- Убран таймаут 30 с у теста "covers every super password event" из PR #38:
  тест теперь идёт ~0,25 с.
Зачем:
- Супер-пароль хэшируется с cost 12 (~0,25 с на свободном ядре), а тесты
  делают десятки хэшей. На загруженном Mac mini тесты "locks for 15 minutes
  after 5 wrong attempts" и "still locks when no channel has the super
  password toggle on" упали по таймауту 5 с в CI этого PR. Подмена в общем
  setup закрывает все 6 таких файлов разом, а не по одному таймауту.
Риски:
- Ни один тест не проверяет сам cost; если такой появится, ему нужно будет
  обойти подмену.
Проверки:
- Команды и результаты: bun run test -- --run --exclude "**/*.real.test.ts"
  локально - 267 файлов, 2389 тестов, 53 с; тесты __test__/security и
  terminal-super-session - 168/168; "covers every super password event" -
  248 мс; biome и tsc по изменённым файлам - без ошибок.
- Ограничения: real-тесты - в CI этого PR.

What:
- __test__/setup.ts wraps bcrypt.hash so a numeric cost is capped at 4; the
  algorithm and hash format stay real. Service code is unchanged (production
  still uses cost 12).
- Dropped the 30 s timeout that PR #38 gave "covers every super password
  event": the test now runs in ~0.25 s.
Why:
- The super password is hashed at cost 12 (~0.25 s on an idle core) and the
  tests hash dozens of times. On the busy Mac mini, "locks for 15 minutes
  after 5 wrong attempts" and "still locks when no channel has the super
  password toggle on" hit the 5 s timeout in this PR's CI. Capping it in the
  shared setup covers all 6 such files at once instead of one timeout at a
  time.
Risks:
- No test checks the cost itself; one that does would need to bypass this.
Checks:
- Commands and results: bun run test -- --run --exclude "**/*.real.test.ts"
  locally - 267 files, 2389 tests, 53 s; __test__/security and
  terminal-super-session - 168/168; "covers every super password event" -
  248 ms; biome and tsc on the changed files - clean.
- Limitations: the real tests run in this PR's CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agentHits agentHits changed the title ci: remove a cancelled run's real-test swarm services ci: clean up cancelled real-test services and cap bcrypt cost in tests Oct 7, 2026
@agentHits
agentHits merged commit b5e8d3c into AgentHits-Dev Oct 7, 2026
7 checks passed
@agentHits
agentHits deleted the test/scope-real-test-cleanup branch October 7, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant