ci(molecule): harden the stale-container sweep and correct comments
The sweep now fails the step when a timestamp cannot be parsed or a container it removes is still there, while tolerating one another run's sweep removed first. Its 30-minute bound and the job's timeout point at each other, since a shorter bound would remove a live run's containers. The concurrency comments of Lint and Build now say that runs on one ref queue rather than cancel, and the scenarios' comment names the run script as what removes their containers. The workflow test checks the label filters of the sweep and cleanup steps by name. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
96cb9246c6
commit
6c2e05c95a
21 files changed
+61
-66
No files matched your search
@@ -47,6 +47,7 @@ jobs:
|
||||
(github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: [kamino-molecule]
|
||||
# Also the age past which the first step removes a run's containers; keep the two equal.
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
# The tools and collections molecule runs with: the image Lint and Build use.
|
||||
@@ -93,11 +94,17 @@ jobs:
|
||||
run: |
|
||||
# Assigned first so that a failing `docker ps` fails the step instead of looking empty.
|
||||
ids="$(docker ps -aq --filter 'label=net.rkdr.mortis.molecule-run')"
|
||||
# The job's timeout-minutes: a shorter bound would remove a live run's containers.
|
||||
cutoff="$(date -d '30 minutes ago' +%s)"
|
||||
for id in $ids; do
|
||||
# a container removed since the listing is skipped
|
||||
# a container removed since the listing, by its run or another run's sweep, is skipped
|
||||
created="$(docker inspect --format '{{.Created}}' "$id")" || continue
|
||||
if [ "$(date -d "$created" +%s)" -lt "$cutoff" ]; then docker rm -f "$id"; fi
|
||||
created="$(date -d "$created" +%s)"
|
||||
if [ "$created" -ge "$cutoff" ]; then continue; fi
|
||||
if ! docker rm -f "$id" >/dev/null && docker container inspect "$id" >/dev/null 2>&1; then
|
||||
echo "::error::could not remove container $id"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
|
||||
|
||||
Reference in new issue
Block a user