Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Fix and simplify the dvc-diff workflow #2549

Merged
merged 8 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
36 changes: 8 additions & 28 deletions .github/workflows/dvc-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
- name: Pull image data from cloud storage
run: dvc pull --remote upstream

# workaround from https://github.com/iterative/cml/issues/1377
- name: Setup NodeJS
uses: actions/setup-node@v1
with:
node-version: '16'

# Produce the markdown diff report, which should look like:
# ## Summary of changed images
#
Comment on lines 44 to 46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could update the preview a little bit below here

    # | Status   | Path                                |
    # |----------|-------------------------------------|
    # | added    | pygmt/tests/baseline/test_image.png |
    # | deleted  | pygmt/tests/baseline/test_image2.png |
    # | modified | pygmt/tests/baseline/test_image3.png |
+
+    ## Image diff(s)
+
+    <details>
+    ...
+    </details>
+
+    Report last updated at commit abcdef

Expand All @@ -48,7 +54,6 @@ jobs:
- name: Generate the image diff report
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
id: image-diff
run: |
echo -e "## Summary of changed images\n" > report.md
echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md
Expand Down Expand Up @@ -95,30 +100,5 @@ jobs:
# Mention git commit SHA in the report
echo -e "Report last updated at commit ${{ github.event.pull_request.head.sha }}" >> report.md

# Save the report content to the output parameter 'report'
echo 'report<<EOF' >> $GITHUB_OUTPUT
cat report.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

- name: Find comment with image diff report
uses: peter-evans/[email protected]
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'This is an auto-generated report of images that have changed on the DVC remote'

- name: Create comment with image diff report
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.image-diff.outputs.report }}

- name: Update comment with new image diff report
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: ${{ steps.image-diff.outputs.report }}
edit-mode: replace
# create/update PR comment
cml comment update report.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this simplifies so many lines of code!

4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_basemap.png.dvc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 3cf01816fa5dd3fbc1adc602557bb032
size: 6187
- md5: 35388aa0ddd861e337b8f47ba4f587dc
size: 7472
path: test_basemap.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_added.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: a5aaf4c3cbea32a3373721237e767789
size: 9420
path: test_basemap_added.png
4 changes: 0 additions & 4 deletions pygmt/tests/baseline/test_basemap_loglog.png.dvc

This file was deleted.

12 changes: 4 additions & 8 deletions pygmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ def test_basemap():
Create a simple basemap plot.
"""
fig = Figure()
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c", frame="afg")
fig.basemap(region=[10, 70, -3, 8], projection="X10c/6c", frame="afg")
return fig


@pytest.mark.mpl_image_compare
def test_basemap_loglog():
def test_basemap_added():
"""
Create a loglog basemap plot.
Create a simple basemap plot.
"""
fig = Figure()
fig.basemap(
region=[1, 10000, 1e20, 1e25],
projection="X16cl/12cl",
frame=["WS", "x2+lWavelength", "ya1pf3+lPower"],
)
fig.basemap(region=[10, 70, -20, 20], projection="X10c/6c", frame="afg")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes in b7ad43b before merging

Remember to do the revert!

return fig


Expand Down