Skip to content

POC: Deduplicate the GMT cache download step into a composite action - #4858

Draft
seisman wants to merge 2 commits into
mainfrom
ci/composite-action-poc
Draft

POC: Deduplicate the GMT cache download step into a composite action#4858
seisman wants to merge 2 commits into
mainfrom
ci/composite-action-poc

Conversation

@seisman

@seisman seisman commented Aug 25, 2026

Copy link
Copy Markdown
Member

Note

Proof of concept, opened as a draft for discussion. It works and CI should pass,
but the point is to decide whether we want local composite actions in this repo at all
before going further.

What this does

Six workflows each carried their own copy of the step that downloads the gmt-cache
artifact into ~/.gmt: benchmarks, ci_docs, ci_doctests, ci_tests,
ci_tests_dev and ci_tests_legacy.

All six were functionally identical — the only differences were comment drift
("Download files" vs "Download cached files" in ci_tests, and a stray trailing period
in ci_tests_legacy), which is the usual symptom of copy-paste.

They now share .github/actions/download-gmt-cache:

      - name: Download remote data from GitHub
        uses: ./.github/actions/download-gmt-cache

Net -48/+6 lines in the workflows.

Things worth knowing before deciding

  • This would be the first composite action in the repo, so it sets a precedent for
    how CI logs read: the inner step is nested under the outer step name rather than
    appearing flat in the step list.
  • Composite actions do not inherit defaults.run.shell. All six jobs use
    shell: bash -l {0}, so the action sets that explicitly. Without it the step would
    silently fall back to plain bash, which behaves differently on the Windows runners
    in ci_docs.
  • No runtime cost worth caring about. A local composite action runs in the same job
    on the same runner and needs no download (it comes from the checkout), unlike a
    reusable workflow, which would add a separate job. The step it replaces takes ~33 s in
    a recent ci_tests run, so the wrapper overhead is noise.
  • uses: ./ reads the action from the checked-out tree, so on pull_request a fork
    could alter its contents. Not a new exposure for these particular workflows — they
    already execute PR code via make install/make test, with permissions: {} and no
    secrets — but it is a difference from an inline step, which always comes from the base
    branch.
  • zizmor reports no new findings.

Possible follow-ups, deliberately not done here

  • Get current week number of year (4 workflows) and make install (5 workflows) are
    also duplicated, but they are 1-2 lines each, so wrapping them likely costs more in
    indirection than it saves.

Idea by @seisman, and implemented by Claude Code

Six workflows (benchmarks, ci_docs, ci_doctests, ci_tests, ci_tests_dev and
ci_tests_legacy) each carried their own copy of the step that downloads the
'gmt-cache' artifact into ~/.gmt. All six were functionally identical; the only
differences were comment drift.

Replace them with a local composite action at
.github/actions/download-gmt-cache, which removes 48 lines and adds 6.

Note that composite actions do not inherit the job's 'defaults.run.shell', so the
action sets 'shell: bash -l {0}' explicitly to match the workflows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@seisman seisman added maintenance Boring but important stuff for the core devs discussions Need more discussion before taking further actions labels Aug 25, 2026
The 'Ensure hyphens are not used in names of directories and Python files' step in
style_checks.yaml greps every tracked directory, so '.github/actions/download-gmt-cache'
would have failed CI. Rename it to 'download_gmt_cache'.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussions Need more discussion before taking further actions maintenance Boring but important stuff for the core devs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant