Skip to content

Commit

Permalink
CI: Cache GSHHG and DCW data as artifacts to simplify workflows (#8481)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored May 31, 2024
1 parent 5e53ea3 commit 58b5bea
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 83 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}

- name: Setup conda
- name: Setup conda (macOS)
uses: conda-incubator/setup-miniconda@v3
if: runner.os == 'macOS'

Expand All @@ -84,16 +84,10 @@ jobs:
env:
EXCLUDE_OPTIONAL: ${{ matrix.EXCLUDE_OPTIONAL }}

- name: Cache GSHHG and DCW data
uses: actions/cache@v4
id: cache-coastline
with:
path: ${{ env.COASTLINEDIR }}
key: coastline-${{ hashFiles('ci/download-coastlines.sh') }}

- name: Download coastlines
run: bash ci/download-coastlines.sh
if: steps.cache-coastline.outputs.cache-hit != 'true'
- name: Download GSHHG and DCW data
run: gh run download -n coastline-cache -D coastline
env:
GH_TOKEN: ${{ github.token }}

- name: Configure GMT
run: |
Expand Down Expand Up @@ -121,20 +115,18 @@ jobs:
cmake --build .
if: runner.os == 'Windows'

- name: Download cached GMT remote data from GitHub Artifacts
run: |
gh run download -n gmt-cache -D ~/.gmt/static/
ls -lRh ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}

- name: Install GMT
run: |
cd build
cmake --build . --target install
# Add GMT PATH to bin
echo "${INSTALLDIR}/bin" >> $GITHUB_PATH
- name: Download cached GMT remote data from GitHub Artifacts
run: gh run download -n gmt-cache -D ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}

- name: Check a few simple commands
run: bash ci/simple-gmt-tests.sh

Expand Down
27 changes: 24 additions & 3 deletions .github/workflows/ci-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Create CI caches for:
#
# 1. GMT remote data for building documentation and running tests
# 2. vcpkg libraries on Windows
# 2. GMT GSHHG and DCW datasets
# 3. vcpkg libraries on Windows
#
name: GMT CI Caches

Expand Down Expand Up @@ -105,8 +106,28 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: gmt-cache
path: |
~/.gmt/static
path: ~/.gmt/static

coastline_cache:
name: Cache GSHHG and DCW datasets
runs-on: ubuntu-latest
env:
COASTLINEDIR: ${{ github.workspace }}/coastline

steps:
- name: Checkout
uses: actions/checkout@v4.1.4

- name: Download GSHHG and DCW datasets
run: bash ci/download-coastlines.sh
env:
COASTLINEDIR: ${{ env.COASTLINEDIR }}

- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: coastline-cache
path: ${{ env.COASTLINEDIR }}

vcpkg_cache:
name: Cache vcpkg libraries
Expand Down
43 changes: 18 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ jobs:
- fedora:rawhide # rolling release with latest versions

steps:
- name: Checkout
uses: actions/checkout@v4.1.4

- name: Install GMT dependencies
run: |
os=$(cat /etc/os-release | grep "^ID=" | awk -F= '{print $2}')
Expand All @@ -83,24 +80,29 @@ jobs:
ghostscript curl git
apt reinstall -y ca-certificates
update-ca-certificates
# Install gh from binary deb package
curl -LO https://github.com/cli/cli/releases/download/v2.49.0/gh_2.49.0_linux_amd64.deb
apt install ./gh_2.49.0_linux_amd64.deb
elif [[ "$os" = "fedora" ]]; then
dnf install -y \
cmake ninja-build \
libcurl-devel netcdf-devel gdal-devel gdal \
fftw3-devel pcre-devel lapack-devel openblas-devel glib2-devel \
ghostscript openssl
ghostscript openssl gh
fi
- name: Cache GSHHG and DCW data
uses: actions/cache@v4
id: cache-coastline
with:
path: ${{ env.COASTLINEDIR }}
key: coastline-${{ hashFiles('ci/download-coastlines.sh') }}
- name: Checkout
uses: actions/checkout@v4.1.4

# Fix the git error:
# "failed to run git: fatal: detected dubious ownership in repository at '/__w/gmt/gmt'"
- name: Fixup git
run: git config --global --add safe.directory $GITHUB_WORKSPACE

- name: Download coastlines
run: bash ci/download-coastlines.sh
if: steps.cache-coastline.outputs.cache-hit != 'true'
- name: Download GSHHG and DCW data
run: gh run download -n coastline-cache -D coastline
env:
GH_TOKEN: ${{ github.token }}

- name: Configure GMT
run: bash ci/config-gmt-unix.sh
Expand All @@ -116,18 +118,9 @@ jobs:
echo "${INSTALLDIR}/bin" >> $GITHUB_PATH
- name: Download cached GMT remote data from GitHub Artifacts
uses: dawidd6/action-download-artifact@v3.1.4
with:
workflow: ci-caches.yml
name: gmt-cache
path: gmt-cache

# Move downloaded files to ~/.gmt directory and list them
- name: Move and list downloaded remote files
run: |
mkdir -p ~/.gmt/static/
mv gmt-cache/* ~/.gmt/static/
ls -lRh ~/.gmt/static/
run: gh run download -n gmt-cache -D ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}

- name: Check a few simple commands
run: bash ci/simple-gmt-tests.sh
27 changes: 7 additions & 20 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}

- name: Setup conda
- name: Setup conda (macOS)
uses: conda-incubator/setup-miniconda@v3
if: runner.os == 'macOS'

Expand All @@ -76,19 +76,10 @@ jobs:
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
bash ci/install-dependencies-${os}.sh
- name: Cache GSHHG and DCW data
uses: actions/cache@v4
id: cache-coastline
with:
path: ${{ env.COASTLINEDIR }}
key: coastline-${{ hashFiles('ci/download-coastlines.sh') }}

- name: Download coastlines
run: bash ci/download-coastlines.sh
if: steps.cache-coastline.outputs.cache-hit != 'true'

- name: Pull baseline image data from dvc remote
run: dvc pull --no-run-cache
- name: Download GSHHG and DCW data
run: gh run download -n coastline-cache -D coastline
env:
GH_TOKEN: ${{ github.token }}

- name: Configure GMT
run: |
Expand Down Expand Up @@ -116,12 +107,8 @@ jobs:
cmake --build .
if: runner.os == 'Windows'

- name: Download cached GMT remote data from GitHub Artifacts
run: |
gh run download -n gmt-cache -D ~/.gmt/static/
ls -lRh ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}
- name: Pull baseline image data from dvc remote
run: dvc pull --no-run-cache

- name: Build documentation
run: |
Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,10 @@ jobs:
New-ItemProperty -Path "HKLM:\Software\GPL Ghostscript\10.02" -Name GS_LIB -PropertyType String -Value "C:\Miniconda\Library\bin;C:\Miniconda\Library\lib;C\Miniconda\Library\Font;C:\Miniconda\Library\fonts"
if: runner.os == 'Windows'

- name: Cache GSHHG and DCW data
uses: actions/cache@v4
id: cache-coastline
with:
path: ${{ env.COASTLINEDIR }}
key: coastline-${{ hashFiles('ci/download-coastlines.sh') }}

- name: Download coastlines
run: bash ci/download-coastlines.sh
if: steps.cache-coastline.outputs.cache-hit != 'true'
- name: Download GSHHG and DCW data
run: gh run download -n coastline-cache -D coastline
env:
GH_TOKEN: ${{ github.token }}

- name: Configure GMT
run: |
Expand Down Expand Up @@ -127,13 +121,6 @@ jobs:
cmake --build .
if: runner.os == 'Windows'

- name: Download cached GMT remote data from GitHub Artifacts
run: |
gh run download -n gmt-cache -D ~/.gmt/static/
ls -lRh ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}

- name: Pull baseline image data from dvc remote
run: dvc pull --no-run-cache

Expand All @@ -144,6 +131,11 @@ jobs:
# Add GMT PATH to bin
echo "${INSTALLDIR}/bin" >> $GITHUB_PATH
- name: Download cached GMT remote data from GitHub Artifacts
run: gh run download -n gmt-cache -D ~/.gmt/static/
env:
GH_TOKEN: ${{ github.token }}

- name: Check a few simple commands
run: bash ci/simple-gmt-tests.sh

Expand Down

0 comments on commit 58b5bea

Please sign in to comment.