Skip to content

Commit

Permalink
Fix the DVC-diff workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed May 13, 2023
1 parent 632b928 commit 9bd66b8
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/dvc-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ jobs:
awk 'NF==5 && NR>=7 && $2=="added" {print $4}' report.md > added_files.txt
awk 'NF==5 && NR>=7 && $2=="modified" {print $4}' report.md > modified_files.txt
# Backup the new images in the "baseline-new" directory
mkdir pygmt/tests/baseline-new
cp pygmt/tests/baseline/*.png pygmt/tests/baseline-new
# Pull images in the main branch from cloud storage
git checkout main
dvc pull --remote upstream
# Append each image to the markdown report
echo -e "## Image diff(s)\n" >> report.md
echo -e "<details>\n" >> report.md
Expand All @@ -66,35 +73,21 @@ jobs:
echo -e "### Added images\n" >> report.md
while IFS= read -r line; do
echo -e "- $line \n" >> report.md
cml-publish --title $line --md "$line" >> report.md < /dev/null
echo -e "![](${line/baseline/baseline-new})" >> report.md
done < added_files.txt
# Modified images
echo -e "### Modified images\n" >> report.md
# Upload new images
while IFS= read -r line; do
cml-publish --title $line --md "$line" >> modified_images_new.md < /dev/null
done < modified_files.txt
# Pull images in the main branch from cloud storage
git checkout main
dvc pull --remote upstream
# Upload old images
while IFS= read -r line; do
cml-publish --title $line --md "$line" >> modified_images_old.md < /dev/null
done < modified_files.txt
# Append image report for modified images
echo -e "| Path | Old | New |" >> report.md
echo -e "|---|---|---|" >> report.md
paste modified_files.txt modified_images_old.md modified_images_new.md -d"|" |
awk -F"|" 'function basename(file) {sub(".*/", "", file); return file} {printf("| %s | %s | %s |\n", basename($1), $2, $3)}' >> report.md
awk -F"|" 'function basename(file) {sub(".*/", "", file); return file} {printf("| %s | ![](%s) | ![](%s) |\n", basename($1), $2, $3)}' modified_files.txt >> report.md
echo -e "</details>\n" >> report.md
# Mention git commit SHA in the report
echo -e "Report last updated at commit ${{ github.event.pull_request.head.sha }}" >> report.md
cml comment update report.md
# Save the report content to the output parameter 'report'
echo 'report<<EOF' >> $GITHUB_OUTPUT
cat report.md >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 9bd66b8

Please sign in to comment.