Skip to content

Commit

Permalink
CI: Fix and simplify the dvc-diff workflow (#2549)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jun 1, 2023
1 parent cf5c107 commit 43dc381
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 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
#
Expand All @@ -45,10 +51,17 @@ jobs:
# | 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
- 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 +108,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

0 comments on commit 43dc381

Please sign in to comment.