Skip to content

Cache data

Cache data #353

Workflow file for this run

# Cache GMT remote data files and upload as artifacts
#
# This workflow downloads data files needed by PyGMT tests/documentation from the GMT
# data server and uploads them as workflow artifacts, which can then be accessed by other
# GitHub Actions workflows.
#
# It is scheduled to run every Sunday at 12:00 (UTC). If new remote files are needed
# urgently, maintainers can refresh the cache by one of the following methods:
#
# 1. Update this workflow file
# 2. Update the `pygmt/helpers/caching.py` file
# 3. Go to https://github.com/GenericMappingTools/pygmt/actions/workflows/cache_data.yaml
# and click the "Run workflow" button
#
name: Cache data
on:
pull_request:
# Make any changes to the following files to refresh the cache in PRs
paths:
- 'pygmt/helpers/caching.py'
- '.github/workflows/cache_data.yaml'
workflow_dispatch:
# Schedule runs on 12 noon every Sunday
schedule:
- cron: '0 12 * * 0'
jobs:
gmt_cache:
name: Cache GMT artifacts
runs-on: macos-latest
defaults:
run:
shell: bash -l {0}
steps:
# Checkout current git repository
- name: Checkout
uses: actions/[email protected]
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
# Install Micromamba with conda-forge dependencies
- name: Setup Micromamba
uses: mamba-org/[email protected]
with:
environment-name: pygmt
condarc: |
channels:
- conda-forge
- nodefaults
create-args: >-
python=3.12
gmt=6.5.0
numpy
pandas
xarray
netCDF4
packaging
build
# Install the package that we want to test
- name: Install the package
run: |
python -m build --sdist
python -m pip install dist/*
# Download remote files
- name: Download remote data
run: |
python -c "from pygmt.helpers.caching import cache_data; cache_data()"
- name: List downloaded remote files
run: ls -lhR ~/.gmt
# Upload the downloaded files as artifacts to GitHub
- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: gmt-cache
path: |
~/.gmt/cache
~/.gmt/server
~/.gmt/gmt_data_server.txt
~/.gmt/gmt_hash_server.txt