Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# This workflow runs regular PyGMT tests with the GMT dev version, and also
# pre-release versions of several dependencies like NumPy, Pandas, Xarray, etc.
# If any tests fail, it also uploads the diff images as workflow artifacts.
# On Linux/macOS, GMT dev version is installed by fetching the latest source
# codes from the GMT master branch and compiling.
# On Windows, GMT dev version is installed from the conda-forge's dev channel
# due to the complexity of building GMT source codes on Windows.
# The GMT dev version is installed by fetching the latest source codes from
# the GMT master branch and compiling.
#
# It is triggered when a pull request is marked as "ready as review", or using
# the slash command `/test-gmt-dev`. It is also scheduled to run on Monday,
Expand Down Expand Up @@ -116,6 +114,38 @@ jobs:
pcre
zlib

# Build and install latest GMT from GitHub
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
env:
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
if: runner.os != 'Windows'

- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Windows)
shell: cmd
run: |
git clone --depth=1 --single-branch --branch ${{ env.GMT_GIT_REF }} https://github.com/GenericMappingTools/gmt
cd gmt/
mkdir build
cd build
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake -G Ninja .. ^
-DCMAKE_INSTALL_PREFIX=${{ env.GMT_INSTALL_DIR }} ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH=${{ env.MAMBA_ROOT_PREFIX }}\envs\pygmt\Library ^
-DGMT_ENABLE_OPENMP=TRUE ^
-DGMT_USE_THREADS=TRUE
cmake --build .
cmake --build . --target install
env:
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
if: runner.os == 'Windows'

- name: Add GMT's bin to PATH
run: echo '${{ github.workspace }}/gmt-install-dir/bin' >> $GITHUB_PATH

# Install dependencies from PyPI
- name: Install dependencies
run: |
Expand All @@ -136,18 +166,6 @@ jobs:
dvc pull
ls -lhR pygmt/tests/baseline/

# Build and install latest GMT from GitHub
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
env:
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
if: runner.os != 'Windows'

- name: Install GMT dev version from conda-forge (Windows)
run: micromamba install -c conda-forge/label/dev gmt
if: runner.os == 'Windows'

# Download cached remote files (artifacts) from GitHub
- name: Download remote data from GitHub
uses: dawidd6/[email protected]
Expand All @@ -170,21 +188,11 @@ jobs:
- name: Install the package
run: make install

- name: Add GMT's bin to PATH (Linux/macOS)
run: echo ${GITHUB_WORKSPACE}/gmt-install-dir/bin >> $GITHUB_PATH
if: runner.os != 'Windows'

# Run the tests
- name: Test with pytest (Linux/macOS)
- name: Test with pytest
run: make test PYTEST_EXTRA="-r P"
env:
GMT_LIBRARY_PATH: ${{ github.workspace }}/gmt-install-dir/lib
if: runner.os != 'Windows'

# Run the tests
- name: Test with pytest (Windows)
run: make test PYTEST_EXTRA="-r P"
if: runner.os == 'Windows'

# Upload diff images on test failure
- name: Upload diff images if any test fails
Expand Down
8 changes: 4 additions & 4 deletions pygmt/tests/test_clib_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test the functions that load libgmt.
"""
import ctypes
import os
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -280,9 +281,8 @@ def test_clib_full_names_gmt_library_path_undefined_path_included(
"""
with monkeypatch.context() as mpatch:
mpatch.delenv("GMT_LIBRARY_PATH", raising=False)
mpatch.setenv("PATH", gmt_bin_dir)
mpatch.setenv("PATH", gmt_bin_dir, prepend=os.pathsep)
lib_fullpaths = clib_full_names()

assert isinstance(lib_fullpaths, types.GeneratorType)
# Windows: find_library() searches the library in PATH, so one more
npath = 2 if sys.platform == "win32" else 1
Expand All @@ -298,7 +298,7 @@ def test_clib_full_names_gmt_library_path_defined_path_included(
"""
with monkeypatch.context() as mpatch:
mpatch.setenv("GMT_LIBRARY_PATH", str(PurePath(gmt_lib_realpath).parent))
mpatch.setenv("PATH", gmt_bin_dir)
mpatch.setenv("PATH", gmt_bin_dir, prepend=os.pathsep)
lib_fullpaths = clib_full_names()

assert isinstance(lib_fullpaths, types.GeneratorType)
Expand All @@ -317,7 +317,7 @@ def test_clib_full_names_gmt_library_path_incorrect_path_included(
"""
with monkeypatch.context() as mpatch:
mpatch.setenv("GMT_LIBRARY_PATH", "/not/a/valid/library/path")
mpatch.setenv("PATH", gmt_bin_dir)
mpatch.setenv("PATH", gmt_bin_dir, prepend=os.pathsep)
lib_fullpaths = clib_full_names()

assert isinstance(lib_fullpaths, types.GeneratorType)
Expand Down