Skip to content

Commit f0d3762

Browse files
weiji14seisman
andauthored
Cache GMT remote data as artifacts on Github (#530)
Use GMT on macOS to download the GMT remote files from the GMT data server, and then upload them as artifacts on Github. * Download cached remote data artifacts from Github * Include instructions on how to manually refresh the CI data cache * Bump action-download-artifact from 2.0.0 to 2.6.3 * Just download to `.gmt` folder and list downloaded remote files * Move downloaded files from .gmt to ~/.gmt * Make a directory under ~/.gmt before moving files into it Co-authored-by: Dongdong Tian <[email protected]>
1 parent 9a4c0a0 commit f0d3762

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

.github/workflows/cache_data.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow gets and uploads the GMT data artifacts used in the PyGMT CI tests
2+
name: Cache data
3+
4+
on:
5+
# Uncomment the 'pull_request' line below to manually re-cache data artifacts
6+
# pull_request:
7+
# Schedule runs on 12 noon every Sunday
8+
schedule:
9+
- cron: '0 12 * * 0'
10+
11+
jobs:
12+
gmt_cache:
13+
name: Cache GMT artifacts
14+
runs-on: macOS-latest
15+
16+
steps:
17+
# Setup Miniconda
18+
- name: Setup Miniconda
19+
uses: goanpeca/[email protected]
20+
with:
21+
channels: conda-forge
22+
23+
# Install GMT
24+
- name: Install GMT
25+
shell: bash -l {0}
26+
run: conda install -c conda-forge gmt=6.1.0
27+
28+
# Download remote files
29+
- name: Download remote data
30+
shell: bash -l {0}
31+
run: |
32+
gmt which -Ga @earth_relief_10m_p @earth_relief_10m_g @earth_relief_30m_p @earth_relief_30m_g @earth_relief_01d_p @earth_relief_01d_g
33+
gmt which -Ga @ridge.txt @Table_5_11.txt @test.dat.nc @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt
34+
35+
# Upload the downloaded files as artifacts to Github
36+
- name: Upload artifacts to Github
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: gmt-cache
40+
path: |
41+
~/.gmt/cache
42+
~/.gmt/server

.github/workflows/ci_tests.yaml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,39 +83,21 @@ jobs:
8383
shell: bash -l {0}
8484
run: conda list
8585

86-
# Cache the ${HOME}/.gmt directory, for docs and testing
87-
- name: Cache GMT directory
88-
uses: actions/cache@v2
89-
id: cache
86+
# Download cached remote files (artifacts) from Github
87+
- name: Download remote data from Github
88+
uses: dawidd6/[email protected]
9089
with:
91-
path: |
92-
~/.gmt/cache
93-
~/.gmt/server
94-
key: cache-gmt-${{ runner.os }}-${{ github.ref }}-20200711
95-
restore-keys: cache-gmt-${{ runner.os }}-refs/heads/master-
96-
97-
# Workaround for the timeouts of 'gmt which' on Linux and Windows
98-
- name: Download remote data using wget (Linux & Windows)
99-
shell: bash -l {0}
100-
run: |
101-
if [ "$RUNNER_OS" == "Windows" ]; then choco install wget; fi # install wget on Windows
102-
mkdir -p ~/.gmt ~/.gmt/cache ~/.gmt/server/earth/earth_relief/
103-
wget --no-check-certificate https://oceania.generic-mapping-tools.org/gmt_hash_server.txt -P ~/.gmt/server/
104-
for data in earth_relief_01d_p.grd earth_relief_01d_g.grd earth_relief_30m_p.grd earth_relief_30m_g.grd earth_relief_10m_p.grd earth_relief_10m_g.grd; do
105-
wget --no-check-certificate https://oceania.generic-mapping-tools.org/server/earth/earth_relief/${data} -P ~/.gmt/server/earth/earth_relief/
106-
done
107-
for data in ridge.txt Table_5_11.txt test.dat.nc tut_bathy.nc tut_quakes.ngdc tut_ship.xyz usgs_quakes_22.txt; do
108-
wget --no-check-certificate https://oceania.generic-mapping-tools.org/cache/${data} -P ~/.gmt/cache/
109-
done
110-
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'macOS'
111-
112-
# Download remote files, if not already cached
113-
- name: Download remote data (macOS)
90+
workflow: cache_data.yaml
91+
name: gmt-cache
92+
path: .gmt
93+
94+
# Move downloaded files to ~/.gmt directory and list them
95+
- name: Move and list downloaded remote files
11496
shell: bash -l {0}
11597
run: |
116-
gmt which -Ga @earth_relief_10m_p @earth_relief_10m_g @earth_relief_30m_p @earth_relief_30m_g @earth_relief_01d_p @earth_relief_01d_g
117-
gmt which -Ga @ridge.txt @Table_5_11.txt @test.dat.nc @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt
118-
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
98+
mkdir -p ~/.gmt
99+
mv .gmt/* ~/.gmt
100+
ls -lh ~/.gmt
119101
120102
# Install the package that we want to test
121103
- name: Install the package

MAINTENANCE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ The configuration file for these services are in
4646
`.github/workflows/ci_tests.yaml` and `.travis.yml`.
4747
They rely on the `requirements.txt` file to install required dependencies using
4848
conda and the `Makefile` to run the tests and checks.
49+
There is also a `.github/workflows/cache_data.yaml` file which caches some GMT
50+
remote data files needed for the Github Actions CI on a regular basis.
51+
If new remote files are needed urgently, maintainers can manually uncomment
52+
the 'pull_request:' line in that `cache_data.yaml` file to refresh the cache.
4953

5054
Travis also handles all of our deployments automatically:
5155

0 commit comments

Comments
 (0)