diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7cc51004..b0c736b7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -95,6 +95,28 @@ jobs: env: BASE_URL: http://127.0.0.1:8730 + - name: Stop and restart the container + run: | + before=$(sha256sum "$RUNNER_TEMP/data/apps.json") + docker stop -t 30 stackyard-e2e + code=$(docker inspect -f '{{.State.ExitCode}}' stackyard-e2e) + echo "stopped with exit code ${code}" + if [ "$code" = 137 ]; then + echo "::error::the container ignored SIGTERM and was killed" + exit 1 + fi + docker start stackyard-e2e + for i in $(seq 1 60); do + if curl -fsS http://127.0.0.1:8730/health >/dev/null 2>&1; then echo "up again after ${i}s"; break; fi + if [ "$i" = 60 ]; then echo "::error::the container never became healthy after a restart"; exit 1; fi + sleep 1 + done + after=$(sha256sum "$RUNNER_TEMP/data/apps.json") + if [ "$before" != "$after" ]; then + echo "::error::the restart changed the saved config" + exit 1 + fi + - name: Container logs on failure if: failure() run: docker logs stackyard-e2e diff --git a/test/repo/release-workflow.test.js b/test/repo/release-workflow.test.js index 5018c391..b2761da6 100644 --- a/test/repo/release-workflow.test.js +++ b/test/repo/release-workflow.test.js @@ -191,6 +191,21 @@ test('the e2e workflow can be called, and still runs on its own', () => { ); }); +test('the e2e workflow stops and restarts the built image after the specs', () => { + const e2e = yaml.load(fs.readFileSync(path.join(root, '.github/workflows/e2e.yml'), 'utf8')); + const e2eSteps = Object.values(e2e.jobs)[0].steps; + const at = e2eSteps.findIndex(s => s.name === 'Stop and restart the container'); + assert.ok( + at > e2eSteps.findIndex(s => s.name === 'Run the specs'), + 'the restart must run on the config the specs saved', + ); + const run = e2eSteps[at].run; + assert.match(run, /docker stop -t \d+ stackyard-e2e/); + assert.match(run, /"\$code" = 137/, 'a container killed after the stop timeout must fail the job'); + assert.match(run, /docker start stackyard-e2e/); + assert.match(run, /"\$before" != "\$after"/, 'the restart must leave the saved config as it was'); +}); + /* Every other gate reads a locally built copy. These pin the checks that read the published image, and that nothing announces a release before they pass. */