ci: Remove docker containers at end, systematically - #3020
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3020 +/- ##
=======================================
Coverage 83.77% 83.77%
=======================================
Files 257 257
Lines 54992 54992
Branches 4705 4705
=======================================
Hits 46072 46072
Misses 8108 8108
Partials 812 812
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| docker image rm -f "${{ inputs.tag }}_${{ inputs.uid }}" | ||
| CONTAINER_NAME="ci-${NAME:-${TAG}}-${UNIQUE}" | ||
|
|
||
| docker container rm -f "${CONTAINER_NAME}" 2>/dev/null || true |
There was a problem hiding this comment.
Does this actually work if a process is hung inside the container?
There was a problem hiding this comment.
Containers also have a unique ID that we should use, rather than just the name
There was a problem hiding this comment.
Does this actually work if a process is hung inside the container?
Yes as long as the the runner and Docker daemon are still responsive
Containers also have a unique ID that we should use, rather than just the name
tweaking it
There was a problem hiding this comment.
CID_FILE is a small host-side file containing Docker’s actual container ID.
docker run --cidfile "$CID_FILE" writes the ID as soon as the container is created. If docker run later hangs or gets cancelled, the cleanup action can still do:
docker container rm -f "$(cat "$CID_FILE")"
It’s used because an action output written after docker run would never be produced if the run hangs. The file lives under RUNNER_TEMP, outside the container, and is deleted during cleanup.
7755000 to
be9903c
Compare
| UNIQUE: ${{ inputs.uid }} | ||
| run: | | ||
| CONTAINER_NAME="ci-${NAME:-${TAG}}-${UNIQUE}" | ||
| CID_FILE="${RUNNER_TEMP}/${CONTAINER_NAME}.cid" |
There was a problem hiding this comment.
No, this should be an output and handled by actions, not written to some arbitrary file. Look at how I built all the custom action, or tell codex to...
No description provided.