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 5439f951083..b870051d7ec 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,7 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 persist-credentials: false - lfs: true + lfs: false - name: Get current week number of year id: date @@ -143,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 uses: $/.github/actions/download-gmt-cache diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index a3317bf0b26..241d54d64f0 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,7 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 persist-credentials: false - lfs: true + lfs: false - name: Get current week number of year id: date @@ -154,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 uses: $/.github/actions/download-gmt-cache