Skip to content

Commit 3c9ba21

Browse files
authored
Merge branch 'main' into test/timestamp
2 parents e852f44 + 452ce23 commit 3c9ba21

160 files changed

Lines changed: 1336 additions & 1042 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/bump_gmt_checklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ assignees: ''
1919
- [ ] Bump the GMT version in CI (1 PR)
2020
- [ ] Update `environment.yml`
2121
- [ ] Update `ci/requirements/docs.yml`
22+
- [ ] Update `.github/workflows/benchmarks.yml`
2223
- [ ] Update `.github/workflows/cache_data.yaml`
2324
- [ ] Update `.github/workflows/ci_doctests.yaml`
2425
- [ ] Update `.github/workflows/ci_docs.yml`

.github/workflows/benchmarks.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Run performance benchmarks
2+
#
3+
# Continuous benchmarking using pytest-codspeed. Measures the execution speed
4+
# of tests marked with @pytest.mark.benchmark decorator.
5+
6+
name: Benchmarks
7+
8+
on:
9+
# Run on pushes to the main branch
10+
push:
11+
branches: [ main ]
12+
paths:
13+
- 'pygmt/**/*.py'
14+
- '!pygmt/tests/**'
15+
- '.github/workflows/benchmarks.yml'
16+
pull_request:
17+
paths:
18+
- 'pygmt/**/*.py'
19+
- '!pygmt/tests/**'
20+
- '.github/workflows/benchmarks.yml'
21+
# `workflow_dispatch` allows CodSpeed to trigger backtest
22+
# performance analysis in order to generate initial data.
23+
workflow_dispatch:
24+
release:
25+
types:
26+
- published
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.ref }}
30+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
31+
32+
jobs:
33+
benchmarks:
34+
runs-on: ubuntu-22.04
35+
if: github.repository == 'GenericMappingTools/pygmt'
36+
defaults:
37+
run:
38+
shell: bash -l {0}
39+
40+
steps:
41+
# Checkout current git repository
42+
- name: Checkout
43+
uses: actions/checkout@v4.1.1
44+
with:
45+
# fetch all history so that setuptools-scm works
46+
fetch-depth: 0
47+
48+
# Install Miniconda with conda-forge dependencies
49+
- name: Setup Miniconda
50+
uses: conda-incubator/setup-miniconda@v3.0.1
51+
with:
52+
auto-activate-base: true
53+
activate-environment: "" # base environment
54+
channels: conda-forge,nodefaults
55+
channel-priority: strict
56+
57+
# Install GMT and dependencies from conda-forge
58+
- name: Install dependencies
59+
run: |
60+
# $CONDA is an environment variable pointing to the root of the miniconda directory
61+
# Preprend $CONDA/bin to $PATH so that conda's python is used over system python
62+
echo $CONDA/bin >> $GITHUB_PATH
63+
conda install --solver=libmamba gmt=6.4.0 python=3.12 \
64+
numpy pandas xarray netCDF4 packaging \
65+
geopandas pytest pytest-mpl
66+
python -m pip install -U pytest-codspeed setuptools
67+
68+
# Download cached remote files (artifacts) from GitHub
69+
- name: Download remote data from GitHub
70+
uses: dawidd6/action-download-artifact@v3.0.0
71+
with:
72+
workflow: cache_data.yaml
73+
workflow_conclusion: success
74+
name: gmt-cache
75+
path: .gmt
76+
77+
# Move downloaded files to ~/.gmt directory and list them
78+
- name: Move and list downloaded remote files
79+
run: |
80+
mkdir -p ~/.gmt
81+
mv .gmt/* ~/.gmt
82+
# Change modification times of the two files, so GMT won't refresh it
83+
touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt
84+
ls -lhR ~/.gmt
85+
86+
# Install the package that we want to test
87+
- name: Install the package
88+
run: make install
89+
90+
# Run the benchmark tests
91+
- name: Run benchmarks
92+
uses: CodSpeedHQ/action@v2.0.2
93+
with:
94+
run: |
95+
python -c "import pygmt; pygmt.show_versions()"
96+
PYGMT_USE_EXTERNAL_DISPLAY="false" python -m pytest -r P --pyargs pygmt --codspeed
97+
env:
98+
GMT_LIBRARY_PATH: /usr/share/miniconda/lib/

.github/workflows/cache_data.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# Cache GMT remote data files and uploads as artifacts
1+
# Cache GMT remote data files and upload as artifacts
22
#
33
# This workflow downloads data files needed by PyGMT tests/documentation from
44
# the GMT data server and uploads as workflow artifacts which can be accessed
55
# by other GitHub Actions workflows.
66
#
77
# It is scheduled to run every Sunday at 12:00 (UTC). If new remote files are
8-
# needed urgently, maintainers can manually uncomment the 'pull_request:' line
9-
# below to refresh the cache.
8+
# needed urgently, maintainers can update the workflow file or
9+
# 'pygmt/helpers/caching.py' file to refresh the cache.
1010
#
1111
name: Cache data
1212

1313
on:
14-
# Uncomment the 'pull_request' line below to manually re-cache data artifacts
15-
# pull_request:
14+
pull_request:
15+
# Make any changes to the following files to refresh the cache
16+
paths:
17+
- 'pygmt/helpers/caching.py'
18+
- '.github/workflows/cache_data.yaml'
1619
# Schedule runs on 12 noon every Sunday
1720
schedule:
1821
- cron: '0 12 * * 0'
@@ -35,7 +38,7 @@ jobs:
3538

3639
# Install Micromamba with conda-forge dependencies
3740
- name: Setup Micromamba
38-
uses: mamba-org/setup-micromamba@v1.7.0
41+
uses: mamba-org/setup-micromamba@v1.7.3
3942
with:
4043
environment-name: pygmt
4144
condarc: |
@@ -61,11 +64,11 @@ jobs:
6164
# Download remote files
6265
- name: Download remote data
6366
run: |
64-
python -c "from pygmt.helpers.testing import download_test_data; download_test_data()"
67+
python -c "from pygmt.helpers.caching import cache_data; cache_data()"
6568
6669
# Upload the downloaded files as artifacts to GitHub
6770
- name: Upload artifacts to GitHub
68-
uses: actions/upload-artifact@v3
71+
uses: actions/upload-artifact@v4
6972
with:
7073
name: gmt-cache
7174
path: |

.github/workflows/check-links.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
check_links:
1919
name: Check Links
2020
runs-on: ubuntu-latest
21+
if: github.repository == 'GenericMappingTools/pygmt'
2122

2223
steps:
2324
- name: Checkout the repository

.github/workflows/ci_docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
docs:
3838
name: ${{ matrix.os }}
3939
runs-on: ${{ matrix.os }}
40+
if: github.repository == 'GenericMappingTools/pygmt'
4041
strategy:
4142
fail-fast: false
4243
matrix:
@@ -65,14 +66,14 @@ jobs:
6566

6667
# Install Micromamba with conda-forge dependencies
6768
- name: Setup Micromamba
68-
uses: mamba-org/setup-micromamba@v1.7.0
69+
uses: mamba-org/setup-micromamba@v1.7.3
6970
with:
7071
environment-name: pygmt
7172
condarc: |
7273
channels:
7374
- conda-forge
7475
- nodefaults
75-
cache-downloads: true
76+
cache-downloads: false
7677
cache-environment: true
7778
create-args: >-
7879
python=3.12
@@ -101,7 +102,7 @@ jobs:
101102
102103
# Download cached remote files (artifacts) from GitHub
103104
- name: Download remote data from GitHub
104-
uses: dawidd6/action-download-artifact@v2.28.0
105+
uses: dawidd6/action-download-artifact@v3.0.0
105106
with:
106107
workflow: cache_data.yaml
107108
workflow_conclusion: success

.github/workflows/ci_doctests.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
test:
2222
name: ${{ matrix.os }}
2323
runs-on: ${{ matrix.os }}
24+
if: github.repository == 'GenericMappingTools/pygmt'
2425
strategy:
2526
fail-fast: false
2627
matrix:
@@ -40,7 +41,7 @@ jobs:
4041

4142
# Install Micromamba with conda-forge dependencies
4243
- name: Setup Micromamba
43-
uses: mamba-org/setup-micromamba@v1.7.0
44+
uses: mamba-org/setup-micromamba@v1.7.3
4445
with:
4546
environment-name: pygmt
4647
condarc: |
@@ -69,7 +70,7 @@ jobs:
6970
7071
# Download cached remote files (artifacts) from GitHub
7172
- name: Download remote data from GitHub
72-
uses: dawidd6/action-download-artifact@v2.28.0
73+
uses: dawidd6/action-download-artifact@v3.0.0
7374
with:
7475
workflow: cache_data.yaml
7576
workflow_conclusion: success

.github/workflows/ci_tests.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ jobs:
9494

9595
# Install Micromamba with conda-forge dependencies
9696
- name: Setup Micromamba
97-
uses: mamba-org/setup-micromamba@v1.7.0
97+
uses: mamba-org/setup-micromamba@v1.7.3
9898
with:
9999
environment-name: pygmt
100100
condarc: |
101101
channels:
102102
- conda-forge
103103
- nodefaults
104-
cache-downloads: true
104+
cache-downloads: false
105105
cache-environment: true
106106
create-args: >-
107107
python=${{ matrix.python-version }}${{ matrix.optional-packages }}
@@ -123,7 +123,7 @@ jobs:
123123
124124
# Download cached remote files (artifacts) from GitHub
125125
- name: Download remote data from GitHub
126-
uses: dawidd6/action-download-artifact@v2.28.0
126+
uses: dawidd6/action-download-artifact@v3.0.0
127127
with:
128128
workflow: cache_data.yaml
129129
workflow_conclusion: success
@@ -141,9 +141,7 @@ jobs:
141141
142142
# Pull baseline image data from dvc remote (DAGsHub)
143143
- name: Pull baseline image data from dvc remote
144-
run: |
145-
dvc pull --verbose
146-
ls -lhR pygmt/tests/baseline/
144+
run: dvc pull --verbose && ls -lhR pygmt/tests/baseline/
147145

148146
# Install the package that we want to test
149147
- name: Install the package
@@ -155,7 +153,7 @@ jobs:
155153

156154
# Upload diff images on test failure
157155
- name: Upload diff images if any test fails
158-
uses: actions/upload-artifact@v3
156+
uses: actions/upload-artifact@v4
159157
if: ${{ failure() }}
160158
with:
161159
name: artifact-${{ runner.os }}-${{ matrix.python-version }}

.github/workflows/ci_tests_dev.yaml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,36 @@ jobs:
5757
# fetch all history so that setuptools-scm works
5858
fetch-depth: 0
5959

60-
# Generate token from GenericMappingTools bot
61-
- name: Generate token from GenericMappingTools bot
62-
uses: tibdex/github-app-token@v2
63-
if: github.event_name == 'repository_dispatch'
64-
id: generate-token
65-
with:
66-
app_id: ${{ secrets.APP_ID }}
67-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
68-
6960
# Checkout the pull request branch
7061
- name: Checkout
7162
uses: actions/checkout@v4.1.1
7263
if: github.event_name == 'repository_dispatch'
7364
with:
74-
token: ${{ steps.generate-token.outputs.token }}
65+
token: ${{ secrets.GITHUB_TOKEN }}
7566
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
7667
ref: ${{ github.event.client_payload.pull_request.head.ref }}
7768
# fetch all history so that setuptools-scm works
7869
fetch-depth: 0
7970

8071
- name: Show job URL
8172
uses: peter-evans/create-or-update-comment@v3.1.0
82-
if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest')
73+
if: github.event_name == 'repository_dispatch' && runner.os == 'Linux'
8374
with:
84-
token: ${{ steps.generate-token.outputs.token }}
75+
token: ${{ secrets.GITHUB_TOKEN }}
8576
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
8677
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
8778
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
8879

8980
# Install Micromamba with conda-forge dependencies
9081
- name: Setup Micromamba
91-
uses: mamba-org/setup-micromamba@v1.7.0
82+
uses: mamba-org/setup-micromamba@v1.7.3
9283
with:
9384
environment-name: pygmt
9485
condarc: |
9586
channels:
9687
- conda-forge
9788
- nodefaults
98-
cache-downloads: true
89+
cache-downloads: false
9990
cache-environment: true
10091
create-args: >-
10192
python=3.12
@@ -120,7 +111,7 @@ jobs:
120111
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
121112
env:
122113
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
123-
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
114+
GMT_INSTALL_DIR: ${{ runner.temp }}/gmt-install-dir
124115
if: runner.os != 'Windows'
125116

126117
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Windows)
@@ -139,13 +130,15 @@ jobs:
139130
-DGMT_USE_THREADS=TRUE
140131
cmake --build .
141132
cmake --build . --target install
133+
cd ..
134+
rm -rf gmt/
142135
env:
143136
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
144-
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
137+
GMT_INSTALL_DIR: ${{ runner.temp }}/gmt-install-dir
145138
if: runner.os == 'Windows'
146139

147140
- name: Add GMT's bin to PATH
148-
run: echo '${{ github.workspace }}/gmt-install-dir/bin' >> $GITHUB_PATH
141+
run: echo '${{ runner.temp }}/gmt-install-dir/bin' >> $GITHUB_PATH
149142

150143
# Install dependencies from PyPI
151144
- name: Install dependencies
@@ -163,13 +156,11 @@ jobs:
163156

164157
# Pull baseline image data from dvc remote (DAGsHub)
165158
- name: Pull baseline image data from dvc remote
166-
run: |
167-
dvc pull
168-
ls -lhR pygmt/tests/baseline/
159+
run: dvc pull --verbose && ls -lhR pygmt/tests/baseline/
169160

170161
# Download cached remote files (artifacts) from GitHub
171162
- name: Download remote data from GitHub
172-
uses: dawidd6/action-download-artifact@v2.28.0
163+
uses: dawidd6/action-download-artifact@v3.0.0
173164
with:
174165
workflow: cache_data.yaml
175166
workflow_conclusion: success
@@ -193,11 +184,11 @@ jobs:
193184
- name: Test with pytest
194185
run: make test PYTEST_EXTRA="-r P"
195186
env:
196-
GMT_LIBRARY_PATH: ${{ github.workspace }}/gmt-install-dir/lib
187+
GMT_LIBRARY_PATH: ${{ runner.temp }}/gmt-install-dir/lib
197188

198189
# Upload diff images on test failure
199190
- name: Upload diff images if any test fails
200-
uses: actions/upload-artifact@v3
191+
uses: actions/upload-artifact@v4
201192
if: ${{ failure() }}
202193
with:
203194
name: artifact-GMT-${{ matrix.gmt_git_ref }}-${{ runner.os }}

0 commit comments

Comments
 (0)