Skip to content

test: add rollback integration test + audit#17

Merged
heznpc merged 2 commits intomainfrom
feat/rollback-integration-test
Apr 23, 2026
Merged

test: add rollback integration test + audit#17
heznpc merged 2 commits intomainfrom
feat/rollback-integration-test

Conversation

@heznpc
Copy link
Copy Markdown
Member

@heznpc heznpc commented Apr 23, 2026

Summary

  • Extract the deploy+rollback logic from cd.yml into scripts/deploy-with-rollback.sh so the same code runs in production (SSH on the VPS) and in CI (locally on the runner).
  • Add tests/rollback-integration.sh plus good/bad Dockerfile fixtures. Wired into ci.yml as a new rollback-integration-test job. No secrets or registry required.

Test design

Three scenarios in tests/rollback-integration.sh:

  1. First deploy of a healthy image succeeds and /health responds build=good.
  2. Deploying a broken image (returns 500 on /health) on top of the healthy one fails AND rollback restores the healthy image. Verifies: script exits non-zero, /health still serves build=good, compose file is rewritten to the good image.
  3. First deploy of a broken image with no previous image fails loudly (no silent success).

Audit of existing tests (Task B)

Before this PR the repo had no test files and no test steps in any workflow. There was nothing to fix:

  • No --passWithNoTests flags (no test runner at all).
  • No expect(true).toBe(true) tautologies.
  • No file-existence-only tests.
  • No self-mocking tests.

This PR introduces the first real test in the repo.

Test plan

  • bash -n syntax check passes on both scripts.
  • CI rollback-integration-test job passes on Ubuntu runner.
  • Existing CI steps (hadolint, compose validate, build, Trivy, size) still pass.

heznpc added 2 commits April 24, 2026 01:46
Extract the deploy+rollback logic from cd.yml into
scripts/deploy-with-rollback.sh so the same code runs in production (over
SSH on the VPS) and in CI (locally on the runner).

Add tests/rollback-integration.sh plus good/bad Dockerfile fixtures. The
test covers three scenarios:

1. First deploy of a healthy image succeeds.
2. Deploying a broken image on top of a healthy one fails AND rollback
   restores the healthy image (compose file is rewritten, /health still
   serves the good build).
3. First deploy of a broken image with no previous image fails loudly.

Wired into ci.yml as a new rollback-integration-test job, no secrets or
registry required. Regression protection: if someone breaks the rollback
logic in the shared script, CI fails.
The test failed because the container exposed port 3000 internally (Node
default) while compose mapped host:container as ${PORT}:${PORT} (38080).
Setting PORT in the compose `environment:` block ensures the app and
the health check both use the port the script was configured with.
@heznpc heznpc merged commit d65d91d into main Apr 23, 2026
4 checks passed
@heznpc heznpc deleted the feat/rollback-integration-test branch April 23, 2026 16:51
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