Skip to content
2 changes: 2 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:
# Run the benchmark tests
- name: Run benchmarks
uses: CodSpeedHQ/action@9d332c4d90b43981c3e55ae8e38e68709996240f # v4.17.0
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
with:
mode: "instrumentation"
# 'bash -el -c' is needed to use the custom shell.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cache_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ jobs:

# Download remote files
- name: Download remote data
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: |
python -c "from pygmt.helpers.caching import cache_data; cache_data()"

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ jobs:
python -m pip install dist/*

- name: Build the HTML documentation
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: |
log_file="${RUNNER_TEMP}/sphinx-html.log"
make -C doc clean html 2>&1 | tee "${log_file}"
Expand All @@ -146,6 +148,8 @@ jobs:
exit "${exit_code}"

- name: Build the PDF documentation
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: |
log_file="${RUNNER_TEMP}/sphinx-pdf.log"
make -C doc pdf 2>&1 | tee "${log_file}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_doctests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jobs:

# Run the doctests
- name: Run doctests
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: |
log_file="${RUNNER_TEMP}/pytest.log"
make doctest PYTEST_EXTRA="-r P" 2>&1 | tee "${log_file}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ jobs:

# Run the regular tests
- name: Run tests
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: |
log_file="${RUNNER_TEMP}/pytest.log"
make test PYTEST_EXTRA="-r P --reruns 2" 2>&1 | tee "${log_file}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
- name: Test with pytest
run: make test PYTEST_EXTRA="-r P --reruns 2"
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
GMT_LIBRARY_PATH: ${{ runner.temp }}/gmt-install-dir/lib

# Upload diff images on test failure
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_tests_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ jobs:

# Run the tests but skip images
- name: Run tests
env:
GMT_DATA_SERVER: https://opentopography.s3.sdsc.edu/gmtdata
run: make test_no_images PYTEST_EXTRA="-r P"
4 changes: 3 additions & 1 deletion examples/tutorials/advanced/draping_on_3d_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
# The original image is available on Wikimedia Commons at
# https://commons.wikimedia.org/wiki/File:Flag_of_Europe.svg
# but we use a cached version on the GMT data server.
url_to_image = "https://oceania.generic-mapping-tools.org/cache/euflag.png"
url_to_image = (
"https://github.com/GenericMappingTools/gmtserver-admin/raw/master/cache/euflag.png"
)
with rasterio.open(url_to_image) as dataset:
data = dataset.read()
drape_grid = xr.DataArray(data, dims=("band", "y", "x"))
Expand Down
32 changes: 12 additions & 20 deletions pygmt/tests/test_datatypes_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,17 @@ def test_dataset_to_strings_with_none_values():
See the bug report at https://github.com/GenericMappingTools/pygmt/issues/3170.
"""
# Sometimes, the test may fail in CI due to intermittent internet connection issue.
# Catch the FileNotFoundError exception so that we can focus on the bug.
tiles = ["@N30E060.earth_age_01m_g.nc", "@N30E090.earth_age_01m_g.nc"]
try:
paths = which(fname=tiles, download="auto")
assert len(paths) == 2

# 'paths' may contain an empty string or not, depending on if tiles are cached.
if "" not in paths: # Contains two valid paths.
# Delete the cached tiles and try again.
for path in paths:
Path(path).unlink()
with pytest.warns(expected_warning=RuntimeWarning) as record: # noqa: PT031
try:
paths = which(fname=tiles, download="auto")
assert len(record) == 1
assert len(paths) == 2
assert "" in paths
except FileNotFoundError:
pass
except FileNotFoundError:
pass
paths = which(fname=tiles, download="auto")
assert len(paths) == 2
# 'paths' may contain an empty string or not, depending on if the tiles are cached.
if "" not in paths: # Contains two valid paths.
# Delete the cached tiles and try again.
for path in paths:
Path(path).unlink()
with pytest.warns(expected_warning=RuntimeWarning) as record:
paths = which(fname=tiles, download="auto")
assert len(record) == 1
assert len(paths) == 2
assert "" in paths
5 changes: 1 addition & 4 deletions pygmt/tests/test_which.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ def test_which_nonascii_path(monkeypatch):
# Start a new session
begin()
# GMT should download the remote file under the new home directory.
try:
fname = which(fname="@static_earth_relief.nc", download="cache")
except FileNotFoundError:
pytest.skip("Failed to download the file, skipping the test.")
fname = which(fname="@static_earth_relief.nc", download="cache")
assert fname.startswith(fakehome)
assert fname.endswith("static_earth_relief.nc")
end()
Expand Down