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
@@ -16,8 +16,8 @@ on: # yamllint disable-line rule:truthy
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A newer push to the same pull request cancels the running run. A tag's ref differs from every
|
||||
# branch's, so a tag run has a group of its own and is never cancelled.
|
||||
# A newer push to the same pull request cancels the running run. Other runs on one ref (a tag,
|
||||
# a dispatched branch) queue instead: a newer one waits and replaces one still waiting.
|
||||
concurrency:
|
||||
group: build-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
@@ -17,8 +17,8 @@ on: # yamllint disable-line rule:truthy
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A newer push to the same pull request makes the running run obsolete; a manual dispatch never
|
||||
# cancels another run.
|
||||
# A newer push to the same pull request makes the running run obsolete. Other runs on one ref
|
||||
# queue instead: a newer one waits for the running one and replaces one still waiting.
|
||||
concurrency:
|
||||
group: lint-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
@@ -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