fix(ci): verify deployment socket and rollback image
This commit is contained in:
parent
006c7e041f
commit
d61d296ea1
3 changed files with 59 additions and 7 deletions
|
|
@ -277,6 +277,8 @@ describe("workspace boundaries", () => {
|
|||
expect(workflow).toContain("needs: ci");
|
||||
expect(workflow).toContain("github.event_name == 'push'");
|
||||
expect(workflow).toContain("github.ref == 'refs/heads/main'");
|
||||
expect(workflow).toContain("docker inspect dimensionlab-website");
|
||||
expect(workflow).toContain("PODMAN_SYSTEMD_UNIT");
|
||||
expect(workflow).toContain("scripts/deploy-dimensionlab-website.sh");
|
||||
});
|
||||
|
||||
|
|
@ -335,7 +337,8 @@ describe("workspace boundaries", () => {
|
|||
},
|
||||
{
|
||||
DEPLOY_CONTAINER_CLI: "podman",
|
||||
DEPLOY_CONTAINER_START_TIMEOUT_SECONDS: "0",
|
||||
DEPLOY_CONTAINER_START_TIMEOUT_SECONDS: "1",
|
||||
DEPLOY_TEST_CONTAINER_IMAGE: "wrong",
|
||||
DEPLOY_EVENT_NAME: "push",
|
||||
DEPLOY_REF: "refs/heads/main",
|
||||
DEPLOY_RESTART_STRATEGY: "quadlet-container",
|
||||
|
|
@ -346,6 +349,7 @@ describe("workspace boundaries", () => {
|
|||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toContain("did not restart on localhost/dimensionlab-website:latest");
|
||||
expect(result.stderr).toContain("rolling back to localhost/dimensionlab-website:rollback-");
|
||||
expect(result.stderr).toContain("rollback image is running");
|
||||
expect(result.log).toMatch(
|
||||
/tag localhost\/dimensionlab-website:rollback-\d{14} localhost\/dimensionlab-website:latest/,
|
||||
);
|
||||
|
|
@ -492,13 +496,29 @@ esac
|
|||
|
||||
function fakePodmanCommand(systemdUnit: string): string {
|
||||
return `#!/usr/bin/env bash
|
||||
state_file="$DEPLOY_TEST_LOG.state"
|
||||
[ -f "$state_file" ] || printf 'initial' > "$state_file"
|
||||
printf '%s\\n' "$*" >> "$DEPLOY_TEST_LOG"
|
||||
if [ "$1" = "image" ] && [ "$2" = "inspect" ]; then
|
||||
if [ "$4" = "--format" ]; then
|
||||
echo sha256:new
|
||||
case "$3" in
|
||||
*:rollback-*)
|
||||
echo sha256:old
|
||||
;;
|
||||
*)
|
||||
if [ "$(cat "$state_file")" = "rollback" ]; then
|
||||
echo sha256:old
|
||||
else
|
||||
echo sha256:new
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
if [ "$1" = "tag" ] && [ "$2" != "localhost/dimensionlab-website:latest" ]; then
|
||||
printf 'rollback' > "$state_file"
|
||||
fi
|
||||
if [ "$1" = "inspect" ]; then
|
||||
case "$*" in
|
||||
*PODMAN_SYSTEMD_UNIT*)
|
||||
|
|
@ -508,7 +528,13 @@ if [ "$1" = "inspect" ]; then
|
|||
echo true
|
||||
;;
|
||||
*'.Image'*|*'{{.Image}}'*)
|
||||
echo sha256:new
|
||||
if [ "$(cat "$state_file")" = "rollback" ]; then
|
||||
echo sha256:old
|
||||
elif [ "\${DEPLOY_TEST_CONTAINER_IMAGE:-new}" = "wrong" ]; then
|
||||
echo sha256:wrong
|
||||
else
|
||||
echo sha256:new
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue