fix: record the version in .env before starting the containers
CI / check (pull_request) Successful in 19s
CI / check (pull_request) Successful in 19s
The services read ~/netork/.env through env_file, so whatever it says when `up -d` creates a container ends up in that container's environment. The settings were recorded only after the swap, so every container carried the previous deploy's NETORK_VERSION: the image was right, `docker exec <api> env` was not. Record them once the pull has brought the images onto the host and before the first `up -d`. A failed pull still leaves .env alone. If the swap fails afterwards, .env names the tag whose compose files and images are already on the host, which is what a hand-typed `docker compose up -d` there should start. Also say which branches a feature-<branch> tag comes from: feature/<name> and feat/<name> become feature-<name>, and fix/<name> now becomes feature-fix-<name> (NetOrk/netork#208), because the registry keeps only feature-* branch tags. The accepted forms do not change; the comment, the refusal message and the README now say so, and a test holds that feature-fix-<name> passes and a bare fix-<name> does not. Closes #6
This commit is contained in:
1 parent
a7e3617291
commit
3a15c311a0
5 files changed
+269
-57
No files matched your search
@@ -107,9 +107,13 @@ class TestTheHostRecordsOnlyWhatItRuns:
|
||||
failure path above: the deploy stopped exactly where it should, and still
|
||||
left `NETORK_VERSION=main-0000000` behind.
|
||||
|
||||
So it is written after the swap and after the image-id check agreed, and this
|
||||
holds that order. Positional rather than behavioural, which is the honest
|
||||
limit of a static check — but the order is the whole property.
|
||||
It then moved behind the image check, and that was too late the other way:
|
||||
the services read the file through `env_file: .env`, so every container was
|
||||
started with the previous deploy's version in its environment
|
||||
(NetOrk/deploy#6). So it is written once the pull has brought the images
|
||||
onto the host, and before the first `up -d`. Positional rather than
|
||||
behavioural, which is the honest limit of a static check; the behaviour is
|
||||
in test_deploy_env_before_up.py.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
@@ -118,14 +122,15 @@ class TestTheHostRecordsOnlyWhatItRuns:
|
||||
assert text.count(needle) == 1, f"{needle!r} appears {text.count(needle)} times"
|
||||
return text.index(needle)
|
||||
|
||||
def test_env_is_recorded_after_the_image_check(self) -> None:
|
||||
verified = self._position("Verified: containers run")
|
||||
recorded = self._position("Recording registry settings")
|
||||
|
||||
assert recorded > verified, (
|
||||
"the host records NETORK_VERSION before the deploy is verified; "
|
||||
"a failed deploy then leaves it pointing at a version never run"
|
||||
)
|
||||
|
||||
def test_env_is_recorded_after_the_pull(self) -> None:
|
||||
assert self._position("Recording registry settings") > self._position("Pulling images...")
|
||||
|
||||
def test_env_is_recorded_before_the_first_up(self) -> None:
|
||||
lines = _logical_lines()
|
||||
first_up = min(i for i, line in enumerate(lines) if "up -d" in line)
|
||||
recorded = next(i for i, line in enumerate(lines) if "Recording registry settings" in line)
|
||||
|
||||
assert recorded < first_up, (
|
||||
"containers are started before .env records NETORK_VERSION; "
|
||||
"they would carry the previous deploy's version in their environment"
|
||||
)
|
||||
Reference in new issue
Block a user