Skip to content

Commit 82cd7f0

Browse files
committed
Merge remote-tracking branch 'origin/test-coast-dvc' into test-coast-dvc
2 parents 0a1c5e7 + bd3fc84 commit 82cd7f0

16 files changed

+135
-36
lines changed

.github/workflows/cache_data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
# Setup Miniconda
2121
- name: Setup Miniconda
22-
uses: conda-incubator/setup-miniconda@v2.0.1
22+
uses: conda-incubator/setup-miniconda@v2.1.0
2323
with:
2424
channels: conda-forge
2525
miniconda-version: "latest"

.github/workflows/ci_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656

5757
# Setup Miniconda
5858
- name: Setup Miniconda
59-
uses: conda-incubator/setup-miniconda@v2.0.1
59+
uses: conda-incubator/setup-miniconda@v2.1.0
6060
with:
6161
activate-environment: pygmt
6262
python-version: ${{ matrix.python-version }}

.github/workflows/ci_tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676

7777
# Setup Miniconda
7878
- name: Setup Miniconda
79-
uses: conda-incubator/setup-miniconda@v2.0.1
79+
uses: conda-incubator/setup-miniconda@v2.1.0
8080
with:
8181
activate-environment: pygmt
8282
python-version: ${{ matrix.python-version }}
@@ -140,7 +140,7 @@ jobs:
140140

141141
# Upload coverage to Codecov
142142
- name: Upload coverage to Codecov
143-
uses: codecov/codecov-action@v1.2.2
143+
uses: codecov/codecov-action@v1.3.1
144144
with:
145145
file: ./coverage.xml # optional
146146
env_vars: OS,PYTHON,NUMPY

.github/workflows/ci_tests_dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373

7474
# Setup Miniconda
7575
- name: Setup Miniconda
76-
uses: conda-incubator/setup-miniconda@v2.0.1
76+
uses: conda-incubator/setup-miniconda@v2.1.0
7777
with:
7878
activate-environment: pygmt
7979
python-version: ${{ matrix.python-version }}

.github/workflows/dvc-diff.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Checks for image diffs in a Pull Request and adds a GitHub comment showing the diff
2+
name: DVC image diff
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- 'pygmt/tests/baseline/*.png.dvc'
8+
9+
jobs:
10+
dvc-diff:
11+
name: DVC image diff
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/[email protected]
17+
with:
18+
# fetch all history so that dvc diff works
19+
fetch-depth: 0
20+
21+
- name: Setup data version control (DVC)
22+
uses: iterative/[email protected]
23+
24+
- name: Setup continuous machine learning (CML)
25+
uses: iterative/[email protected]
26+
27+
# Produce the markdown diff report, which should look like:
28+
# ## Summary of changed images
29+
#
30+
# This is an auto-generated report of images that have changed on the DVC remote
31+
#
32+
# | Status | Path |
33+
# |----------|-------------------------------------|
34+
# | added | pygmt/tests/baseline/test_image.png |
35+
- name: Put list of images that were added or changed into report
36+
run: |
37+
echo -e "## Summary of changed images\n" > report.md
38+
echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md
39+
dvc diff --show-md master HEAD >> report.md
40+
cat report.md
41+
42+
- name: Pull image data from cloud storage
43+
run: dvc pull --remote upstream
44+
45+
- name: Put image diff(s) into report
46+
env:
47+
repo_token: ${{ secrets.GITHUB_TOKEN }}
48+
id: image-diff
49+
run: |
50+
# Get just the filename of the changed image from the report
51+
awk 'NF==5 && NR>=7 {print $4}' report.md > diff_files.txt
52+
53+
# Append each image to the markdown report
54+
echo -e "## Image diff(s)\n" >> report.md
55+
echo -e "<details>\n" >> report.md
56+
57+
while IFS= read -r line; do
58+
echo -e "- $line \n" >> report.md
59+
cml-publish --title $line --md "$line" >> report.md < /dev/null
60+
done < diff_files.txt
61+
62+
echo -e "</details>\n" >> report.md
63+
64+
# Mention git commit SHA in the report
65+
echo -e "Report last updated at commit ${{ github.event.pull_request.head.sha }}" >> report.md
66+
67+
# Format report to escape newlines before publishing as GitHub comment
68+
report=$(cat report.md)
69+
report="${report//'%'/'%25'}"
70+
report="${report//$'\n'/'%0A'}"
71+
report="${report//$'\r'/'%0D'}"
72+
echo ::set-output name=report::$report
73+
74+
- name: Find comment with image diff report
75+
uses: peter-evans/[email protected]
76+
id: fc
77+
with:
78+
issue-number: ${{ github.event.pull_request.number }}
79+
comment-author: 'github-actions[bot]'
80+
body-includes: 'This is an auto-generated report of images that have changed on the DVC remote'
81+
82+
- name: Create comment with image diff report
83+
if: steps.fc.outputs.comment-id == ''
84+
uses: peter-evans/[email protected]
85+
with:
86+
issue-number: ${{ github.event.pull_request.number }}
87+
body: ${{ steps.image-diff.outputs.report }}
88+
89+
- name: Update comment with new image diff report
90+
if: steps.fc.outputs.comment-id != ''
91+
uses: peter-evans/[email protected]
92+
with:
93+
comment-id: ${{ steps.fc.outputs.comment-id }}
94+
body: ${{ steps.image-diff.outputs.report }}
95+
edit-mode: replace

MAINTENANCE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ There are 9 configuration files located in `.github/workflows`:
127127

128128
This workflow is triggered in a PR if the slash command `/format` is used.
129129

130+
10. `dvc-diff.yml` (Report changes to test images on dvc remote)
131+
132+
This workflow is triggered in a PR when any *.png.dvc files have been added,
133+
modified, or deleted. A GitHub comment will be published that contains a summary
134+
table of the images that have changed along with a visual report.
135+
130136
## Continuous Documentation
131137

132138
We use the [Vercel for GitHub](https://github.com/apps/vercel) App to preview changes
-66.5 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 68c12988f1bb0dbc67da560fe4d51ea2
3+
size: 64936
4+
path: test_contour_from_file.png
-54.5 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 7a8e0d23ce325cef3be12da033ab2602
3+
size: 75839
4+
path: test_contour_matrix.png
-91.4 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 8bae58cc9d84de9ff9c30f3d45792dc5
3+
size: 87570
4+
path: test_contour_vec.png
-74.8 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 4d1ed417fd2625d0b2fa5c17dafd32fd
3+
size: 73728
4+
path: test_legend_entries.png

pygmt/tests/test_contour.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def test_contour_fail_no_data(data):
6262
z=data[:, 2],
6363
data=data,
6464
region=region,
65-
projection="X4i",
65+
projection="X10c",
6666
style="c0.2c",
6767
color="red",
6868
frame="afg",
69-
pen="",
69+
pen=True,
7070
)
7171

7272

@@ -83,7 +83,7 @@ def test_contour_vec(region):
8383
y = y.flatten()
8484
z = (x - 0.5 * (region[0] + region[1])) ** 2 + 4 * y ** 2
8585
z = np.exp(-z / 10 ** 2 * np.log(2))
86-
fig.contour(x=x, y=y, z=z, projection="X4i", region=region, frame="a", pen="")
86+
fig.contour(x=x, y=y, z=z, projection="X10c", region=region, frame="a", pen=True)
8787
return fig
8888

8989

@@ -93,7 +93,7 @@ def test_contour_matrix(data, region):
9393
Plot data.
9494
"""
9595
fig = Figure()
96-
fig.contour(data=data, projection="X3i", region=region, frame="ag", pen="")
96+
fig.contour(data=data, projection="X10c", region=region, frame="ag", pen=True)
9797
return fig
9898

9999

@@ -104,6 +104,6 @@ def test_contour_from_file(region):
104104
"""
105105
fig = Figure()
106106
fig.contour(
107-
data=POINTS_DATA, projection="X4i", region=region, frame="af", pen="#ffcb87"
107+
data=POINTS_DATA, projection="X10c", region=region, frame="af", pen="#ffcb87"
108108
)
109109
return fig

pygmt/tests/test_legend.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pygmt import Figure
66
from pygmt.exceptions import GMTInvalidInput
77
from pygmt.helpers import GMTTempFile
8-
from pygmt.helpers.testing import check_figures_equal
98

109

1110
@pytest.mark.mpl_image_compare
@@ -44,42 +43,25 @@ def test_legend_default_position():
4443
return fig
4544

4645

47-
@check_figures_equal()
46+
@pytest.mark.mpl_image_compare
4847
def test_legend_entries():
4948
"""
5049
Test different marker types/shapes.
5150
"""
52-
fig_ref, fig_test = Figure(), Figure()
53-
54-
# Use single-character arguments for the reference image
55-
fig_ref = Figure()
56-
fig_ref.basemap(J="x1i", R="0/7/3/7", B="")
57-
fig_ref.plot(
58-
data="@Table_5_11.txt",
59-
S="c0.15i",
60-
G="lightgreen",
61-
W="faint",
62-
l="Apples",
63-
)
64-
fig_ref.plot(data="@Table_5_11.txt", W="1.5p,gray", l='"My lines"')
65-
fig_ref.plot(data="@Table_5_11.txt", S="t0.15i", G="orange", l="Oranges")
66-
fig_ref.legend(D="JTR+jTR")
67-
68-
fig_test.basemap(projection="x1i", region=[0, 7, 3, 7], frame=True)
69-
fig_test.plot(
51+
fig = Figure()
52+
fig.basemap(projection="x1i", region=[0, 7, 3, 7], frame=True)
53+
fig.plot(
7054
data="@Table_5_11.txt",
7155
style="c0.15i",
7256
color="lightgreen",
7357
pen="faint",
7458
label="Apples",
7559
)
76-
fig_test.plot(data="@Table_5_11.txt", pen="1.5p,gray", label='"My lines"')
77-
fig_test.plot(
78-
data="@Table_5_11.txt", style="t0.15i", color="orange", label="Oranges"
79-
)
80-
fig_test.legend(position="JTR+jTR")
60+
fig.plot(data="@Table_5_11.txt", pen="1.5p,gray", label='"My lines"')
61+
fig.plot(data="@Table_5_11.txt", style="t0.15i", color="orange", label="Oranges")
62+
fig.legend(position="JTR+jTR")
8163

82-
return fig_ref, fig_test
64+
return fig
8365

8466

8567
@pytest.mark.mpl_image_compare

0 commit comments

Comments
 (0)