From 97c5efddc295ceaf2238c932d318c6a9073b73f9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 30 Aug 2026 18:55:03 +0800 Subject: [PATCH 1/2] CI: Cache Git LFS objects --- .github/actions/checkout-lfs/action.yml | 31 +++++++++++++++++++++++++ .github/dependabot.yml | 4 +++- .github/workflows/ci_tests.yaml | 7 +++++- .github/workflows/ci_tests_dev.yaml | 6 ++++- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .github/actions/checkout-lfs/action.yml diff --git a/.github/actions/checkout-lfs/action.yml b/.github/actions/checkout-lfs/action.yml new file mode 100644 index 00000000000..fd323afe210 --- /dev/null +++ b/.github/actions/checkout-lfs/action.yml @@ -0,0 +1,31 @@ +# Check out the Git LFS objects, with the objects cached by GitHub Actions +# +# The Git LFS objects (i.e., the baseline images for image comparison tests) are +# restored from the GitHub Actions cache, so that they are fetched from the Git LFS +# server only when they are missing from the cache, which saves the Git LFS bandwidth. +# +# This action must be used after the "actions/checkout" step, and that step must set +# "lfs: false" (the default), otherwise the objects are fetched from the Git LFS server +# before the cache can be restored. +# +name: Checkout Git LFS objects +description: Check out the Git LFS objects, restoring them from the GitHub Actions cache + +runs: + using: composite + steps: + - name: Get the list of Git LFS objects + shell: bash + run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id + + - name: Cache the Git LFS objects + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 # zizmor: ignore[cache-poisoning] + with: + path: .git/lfs + key: git-lfs-${{ hashFiles('.lfs-assets-id') }} + # Fall back to the most recent cache so Git LFS only fetches missing objects. + restore-keys: git-lfs- + + - name: Checkout the Git LFS objects + shell: bash + run: git lfs pull diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 37c2e43bba5..7bb1a18c9d6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,9 @@ version: 2 updates: - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/.github/actions/*" schedule: # Check for updates to GitHub Actions on Tuesdays interval: "weekly" diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 68faa79a394..91a696776ad 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -29,11 +29,13 @@ on: branches: [ main ] paths: - 'pygmt/**' + - '.github/actions/checkout-lfs/action.yml' - '.github/workflows/ci_tests.yaml' pull_request: types: [opened, reopened, synchronize, ready_for_review] paths: - 'pygmt/**' + - '.github/actions/checkout-lfs/action.yml' - '.github/workflows/ci_tests.yaml' workflow_dispatch: release: @@ -112,7 +114,10 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 persist-credentials: false - lfs: true + lfs: false + + - name: Checkout the Git LFS (i.e., the baseline images) objects + uses: $/.github/actions/checkout-lfs - name: Get current week number of year id: date diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index 9a46e59563f..a7800846e9b 100644 --- a/.github/workflows/ci_tests_dev.yaml +++ b/.github/workflows/ci_tests_dev.yaml @@ -18,6 +18,7 @@ on: types: [ opened, reopened, labeled, synchronize ] paths: - 'pygmt/**' + - '.github/actions/checkout-lfs/action.yml' - '.github/workflows/ci_tests_dev.yaml' workflow_dispatch: # Schedule tests on Monday/Wednesday/Friday @@ -56,7 +57,10 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 persist-credentials: false - lfs: true + lfs: false + + - name: Checkout the Git LFS (i.e., the baseline images) objects + uses: $/.github/actions/checkout-lfs - name: Get current week number of year id: date From fc5c7043c8a3f3b0f72636a95aa4a795e09a66a2 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 4 Sep 2026 10:48:40 +0800 Subject: [PATCH 2/2] Check out LFS later --- .github/workflows/ci_tests.yaml | 6 +++--- .github/workflows/ci_tests_dev.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 91a696776ad..f02565e86e0 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -116,9 +116,6 @@ jobs: persist-credentials: false lfs: false - - name: Checkout the Git LFS (i.e., the baseline images) objects - uses: $/.github/actions/checkout-lfs - - name: Get current week number of year id: date run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19 @@ -148,6 +145,9 @@ jobs: pytest-mpl pytest-rerunfailures + - name: Checkout the Git LFS (i.e., the baseline images) objects + uses: $/.github/actions/checkout-lfs + # Download cached remote files (artifacts) from GitHub - name: Download remote data from GitHub run: | diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index a7800846e9b..31bab63e751 100644 --- a/.github/workflows/ci_tests_dev.yaml +++ b/.github/workflows/ci_tests_dev.yaml @@ -59,9 +59,6 @@ jobs: persist-credentials: false lfs: false - - name: Checkout the Git LFS (i.e., the baseline images) objects - uses: $/.github/actions/checkout-lfs - - name: Get current week number of year id: date run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19 @@ -158,6 +155,9 @@ jobs: - name: List installed packages run: micromamba list + - name: Checkout the Git LFS (i.e., the baseline images) objects + uses: $/.github/actions/checkout-lfs + # Download cached remote files (artifacts) from GitHub - name: Download remote data from GitHub run: |