Skip to content

Commit 886c464

Browse files
authored
Merge branch 'master' into pyproject
2 parents 25a845f + d313015 commit 886c464

File tree

7 files changed

+85
-19
lines changed

7 files changed

+85
-19
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ Fixes #
1515
- [ ] Add new public functions/methods/classes to `doc/api/index.rst`.
1616
- [ ] Write detailed docstrings for all functions/methods.
1717
- [ ] If adding new functionality, add an example to docstrings or tutorials.
18+
19+
**Notes**
20+
21+
- You can write `/format` in the first line of a comment to lint the code automatically

.github/workflows/format-command.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: format-command
2+
on:
3+
repository_dispatch:
4+
types: [format-command]
5+
jobs:
6+
format:
7+
runs-on: ubuntu-latest
8+
steps:
9+
# Generate token from GenericMappingTools bot
10+
- uses: tibdex/github-app-token@v1
11+
id: generate-token
12+
with:
13+
app_id: ${{ secrets.APP_ID }}
14+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
15+
16+
# Checkout the pull request branch
17+
- uses: actions/checkout@v2
18+
with:
19+
token: ${{ steps.generate-token.outputs.token }}
20+
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
21+
ref: ${{ github.event.client_payload.pull_request.head.ref }}
22+
23+
# Setup Python environment
24+
- uses: actions/setup-python@v1
25+
26+
# Install formatting tools
27+
- name: Install formatting tools
28+
run: pip install black blackdoc flake8
29+
30+
# Run "make format" and commit the change to the PR branch
31+
- name: Commit to the PR branch if any changes
32+
run: |
33+
make format
34+
if [[ $(git ls-files -m) ]]; then
35+
git config --global user.name 'actions-bot'
36+
git config --global user.email '[email protected]'
37+
git commit -am "[format-command] fixes"
38+
git push
39+
fi
40+
41+
- name: Add reaction
42+
uses: peter-evans/create-or-update-comment@v1
43+
with:
44+
token: ${{ steps.generate-token.outputs.token }}
45+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
46+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
47+
reaction-type: hooray
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Slash Command Dispatch
2+
on:
3+
issue_comment:
4+
types: [created]
5+
# Add "edited" type for test purposes. Where possible, avoid using to prevent processing unnecessary events.
6+
# types: [created, edited]
7+
jobs:
8+
slashCommandDispatch:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Generate token from GenericMappingTools bot
12+
- uses: tibdex/github-app-token@v1
13+
id: generate-token
14+
with:
15+
app_id: ${{ secrets.APP_ID }}
16+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
17+
18+
- name: Slash Command Dispatch
19+
uses: peter-evans/slash-command-dispatch@v2
20+
with:
21+
token: ${{ steps.generate-token.outputs.token }}
22+
commands: |
23+
format
24+
issue-type: pull-request

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ Before committing, run it to automatically format your code:
255255
make format
256256
```
257257

258-
Don't worry if you forget to do it.
259-
Our continuous integration systems will warn us and you can make a new commit with the
260-
formatted code.
258+
Don't worry if you forget to do it. Our continuous integration systems will
259+
warn us and you can make a new commit with the formatted code.
260+
Even better, you can just write `/format` in the first line of any comment in a
261+
Pull Request to lint the code automatically.
261262

262263
We also use [flake8](http://flake8.pycqa.org/en/latest/) and
263264
[pylint](https://www.pylint.org/) to check the quality of the code and quickly catch

pygmt/tests/test_clib.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,8 @@ def test_call_module_error_message():
161161
try:
162162
lib.call_module("info", "bogus-data.bla")
163163
except GMTCLibError as error:
164-
msg = "\n".join(
165-
[
166-
"Module 'info' failed with status code 71:",
167-
"gmtinfo [ERROR]: Cannot find file bogus-data.bla",
168-
]
169-
)
170-
assert str(error) == msg
164+
assert "Module 'info' failed with status code" in str(error)
165+
assert "gmtinfo [ERROR]: Cannot find file bogus-data.bla" in str(error)
171166

172167

173168
def test_method_no_session():

pygmt/tests/test_grdimage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Test Figure.grdimage
33
"""
4+
import sys
45
import numpy as np
56
import pytest
67
import xarray as xr
@@ -73,9 +74,9 @@ def test_grdimage_file():
7374
return fig
7475

7576

76-
@pytest.mark.xfail(
77+
@pytest.mark.skip(
7778
reason="Upstream bug in GMT 6.1.1",
78-
condition=gmt_version <= Version("6.1.1"),
79+
condition=gmt_version <= Version("6.1.1") and sys.platform == "darwin",
7980
)
8081
@check_figures_equal()
8182
@pytest.mark.parametrize(

pygmt/tests/test_info.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88
import pandas as pd
99
import pytest
1010
import xarray as xr
11-
from packaging.version import Version
1211

13-
from .. import clib, info
12+
from .. import info
1413
from ..exceptions import GMTInvalidInput
1514

1615
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
1716
POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")
1817

19-
with clib.Session() as _lib:
20-
gmt_version = Version(_lib.info["version"])
21-
2218

2319
def test_info():
2420
"Make sure info works on file name inputs"
@@ -43,7 +39,6 @@ def test_info_dataframe():
4339

4440

4541
@pytest.mark.xfail(
46-
condition=gmt_version <= Version("6.1.1"),
4742
reason="UNIX timestamps returned instead of ISO datetime, should work on GMT 6.2.0 "
4843
"after https://github.com/GenericMappingTools/gmt/issues/4241 is resolved",
4944
)
@@ -63,7 +58,6 @@ def test_info_pandas_dataframe_time_column():
6358

6459

6560
@pytest.mark.xfail(
66-
condition=gmt_version <= Version("6.1.1"),
6761
reason="UNIX timestamp returned instead of ISO datetime, should work on GMT 6.2.0 "
6862
"after https://github.com/GenericMappingTools/gmt/issues/4241 is resolved",
6963
)

0 commit comments

Comments
 (0)