test: add rollback integration test + audit#17
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cd.ymlintoscripts/deploy-with-rollback.shso the same code runs in production (SSH on the VPS) and in CI (locally on the runner).tests/rollback-integration.shplus good/bad Dockerfile fixtures. Wired intoci.ymlas a newrollback-integration-testjob. No secrets or registry required.Test design
Three scenarios in
tests/rollback-integration.sh:/healthrespondsbuild=good./health) on top of the healthy one fails AND rollback restores the healthy image. Verifies: script exits non-zero,/healthstill servesbuild=good, compose file is rewritten to the good image.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:
--passWithNoTestsflags (no test runner at all).expect(true).toBe(true)tautologies.This PR introduces the first real test in the repo.
Test plan
bash -nsyntax check passes on both scripts.rollback-integration-testjob passes on Ubuntu runner.