Skip to content

fix: clean registry buildcache tags on PR close - #90

Open
wdconinc with Copilot wants to merge 12 commits into
masterfrom
copilot/clean-registry-buildcache-tags
Open

wdconinc with Copilot wants to merge 12 commits into
masterfrom
copilot/clean-registry-buildcache-tags

Conversation

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Buildcache tags accumulate in container registries (ghcr.io and eicweb.phy.anl.gov) without timestamps for automatic eviction. This adds a workflow to delete them when PRs close or via manual trigger.

Implementation

  • New workflow .github/workflows/cleanup-buildcache.yml triggers on:
    • pull_request: types[closed] - automatic cleanup when PR closes
    • workflow_dispatch - manual cleanup with branch slug input
  • Slug Action Integration: Explicitly includes rlespinasse/github-slug-action@v5 (for pull_request events) to ensure GITHUB_REF_POINT_SLUG is set
  • GitHub Container Registry: Uses GitHub Packages API to delete versions matching tag pattern -{GITHUB_REF_POINT_SLUG}-
  • GitLab Container Registry: Uses GitLab API v4 to delete tags from project 290 (containers/eic_container)
  • Tag pattern: Matches all buildcache variants using GITHUB_REF_POINT_SLUG (derived from branch name):
    • Base images: {BUILD_IMAGE}-{GITHUB_REF_POINT_SLUG}-{arch}
    • EIC images: {BUILD_IMAGE}{ENV}-{BUILD_TYPE}-{GITHUB_REF_POINT_SLUG}-{arch}

Example

For a PR from branch "my-feature" (where GITHUB_REF_POINT_SLUG = "my-feature"), deletes:

debian_stable_base-my-feature-amd64
debian_stable_base-my-feature-amd64_v3
debian_stable_base-my-feature-arm64
cuda_devel-my-feature-amd64
eic_ci-default-my-feature-amd64
eic_ci-default-my-feature-amd64_v3
eic_xl-default-my-feature-arm64
...

For manual cleanup via workflow_dispatch, provide the branch slug (e.g., "old-feature") as input to delete buildcache tags for that branch.

The cleanup workflow uses the same GITHUB_REF_POINT_SLUG variable as the build-push workflow, ensuring pattern consistency between tag creation and deletion.

Authentication uses existing secrets: GHCR_REGISTRY_TOKEN and GITLAB_TOKEN

Documentation

Updated docs/build-pipeline.md to document cleanup workflow and caching strategy.

Original prompt

This section details on the original issue you should resolve

<issue_title>Clean registry buildcache when PR merged or closed</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
We write the buildcache for pull requests to the registry as tags for the buildcache image at https://eicweb.phy.anl.gov/containers/eic_container/container_registry/143. This accumulates without a clear way to clean up since the buildcache tags don't have a timestamp set that could be used for automatic eviction. This also affects ghcr.io.

Describe the solution you'd like
When a pull request is merged, we should explicitly remove the buildcache tags from the registries (both eicweb and ghcr.io).

Describe alternatives you've considered
An alternative approach is to have a periodic scheduled workflow that removes the buildcache entries that do not have a corresponding open pull request.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 14, 2025 17:24
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean registry buildcache on PR merge or close Clean registry buildcache tags on PR close Dec 14, 2025
Copilot AI requested a review from wdconinc December 14, 2025 17:32
Comment thread .github/workflows/cleanup-buildcache.yml Outdated
Copilot AI and others added 2 commits December 14, 2025 17:58
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Comment thread .github/workflows/cleanup-buildcache.yml Outdated
Comment thread .github/workflows/cleanup-buildcache.yml
Copilot AI and others added 2 commits December 14, 2025 18:14
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
@wdconinc
wdconinc marked this pull request as ready for review December 14, 2025 18:16
Copilot AI review requested due to automatic review settings December 14, 2025 18:16
Copilot AI requested a review from wdconinc December 14, 2025 18:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements automatic cleanup of buildcache container image tags from both ghcr.io and eicweb.phy.anl.gov registries when pull requests are closed or merged. This addresses the issue of buildcache accumulation without timestamps for automatic eviction. The workflow uses the branch slug (GITHUB_REF_POINT_SLUG) to identify and remove all associated buildcache tags.

Key Changes

  • Added new .github/workflows/cleanup-buildcache.yml workflow triggered on PR close
  • Implements deletion logic for both GitHub Container Registry (ghcr.io) and GitLab Container Registry (eicweb.phy.anl.gov)
  • Updated build pipeline documentation to describe the automatic cleanup behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/cleanup-buildcache.yml New workflow that cleans up buildcache tags using branch slug pattern matching from both registries when PRs are closed, with manual dispatch option
docs/build-pipeline.md Documents the buildcache cleanup workflow behavior and adds new trigger table section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/cleanup-buildcache.yml Outdated
Comment thread docs/build-pipeline.md Outdated
Comment thread docs/build-pipeline.md Outdated
Comment thread .github/workflows/cleanup-buildcache.yml Outdated
@wdconinc wdconinc changed the title Clean registry buildcache tags on PR close fix: clean registry buildcache tags on PR close Dec 14, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
wdconinc and others added 3 commits December 14, 2025 17:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
wdconinc added a commit that referenced this pull request Sep 15, 2026
* docs: correct pipeline, image and version-update documentation

The documentation had drifted from the code in several places that would send
a reader, human or agent, down the wrong path.

AGENTS.md:
- the workflow tree listed three of the six workflows, omitting the two
  reusable workflows that do all the building and the backport workflow
- the image list named three images; cuda_devel and cuda_runtime were missing,
  as was any mention of the environments built only on GitLab CI
- the spack-environment tree showed two of the nine environments
- "Update versions in both places" named xl and cuda only. There are nine
  environments with an epic overlay, and the thing that actually matters is
  the trailing marker comment the Dockerfile keys its sed overrides on, which
  was not documented at all
- "Tags are automatically cleaned on PR close by cleanup workflows" is not
  true for GitHub Actions: no such workflow exists, which is what issue #89 is
  about and PR #90 proposes. GitLab does clean up, via clean_unstable_mr and
  clean_pipeline. Say which is which

.github/copilot-instructions.md carried the same "both xl and cuda" claim;
corrected in step with AGENTS.md. The rest of that file correctly defers to
AGENTS.md as the primary reference and is left alone.

docs/build-pipeline.md described the pipeline as it was before the reusable
workflows were split out: build-push.yml appeared to run the builds itself,
and the diagrams showed two architectures where three are built. Add a table
of the two reusable workflows and what each produces, and correct the
architecture set to amd64, amd64_v3 and arm64.

README.md linked to the GitLab mirror for files that live in this repository,
and the link captioned "spack.sh" actually pointed at packages.yaml while the
text describes editing the cherry-pick list, which is in spack-packages.sh.
Point both at the files here. The historical merge-request link is left as-is,
since it is a reference to something that only exists on GitLab.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6394UjZvzHPVygCvjRc9n

* docs: add amd64_v3 EIC jobs to build-pipeline flowchart

Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>

* docs: use "available per-arch digests" in base-manifest step description

Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean registry buildcache when PR merged or closed

3 participants