24
24
- name : Setup continuous machine learning (CML)
25
25
uses : iterative/setup-cml@v1.0.0
26
26
27
+ - name : Pull image data from cloud storage
28
+ run : dvc pull --remote upstream
29
+
27
30
# Produce the markdown diff report, which should look like:
28
31
# ## Summary of changed images
29
32
#
@@ -32,32 +35,52 @@ jobs:
32
35
# | Status | Path |
33
36
# |----------|-------------------------------------|
34
37
# | added | pygmt/tests/baseline/test_image.png |
35
- - name : Put list of images that were added or changed into report
38
+ # | deleted | pygmt/tests/baseline/test_image2.png |
39
+ # | modified | pygmt/tests/baseline/test_image3.png |
40
+ - name : Generate the image diff report
41
+ env :
42
+ repo_token : ${{ secrets.GITHUB_TOKEN }}
43
+ id : image-diff
36
44
run : |
37
45
echo -e "## Summary of changed images\n" > report.md
38
46
echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md
39
47
dvc diff --show-md master HEAD >> report.md
40
- cat report.md
41
48
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
49
+ # Get just the filename of the added and modified image from the report
50
+ awk 'NF==5 && NR>=7 && $2=="added" {print $4}' report.md > added_files.txt
51
+ awk 'NF==5 && NR>=7 && $2=="modified" {print $4}' report.md > modified_files.txt
52
52
53
53
# Append each image to the markdown report
54
54
echo -e "## Image diff(s)\n" >> report.md
55
55
echo -e "<details>\n" >> report.md
56
56
57
+ # Added images
58
+ echo -e "### Added images\n" >> report.md
57
59
while IFS= read -r line; do
58
60
echo -e "- $line \n" >> report.md
59
61
cml-publish --title $line --md "$line" >> report.md < /dev/null
60
- done < diff_files.txt
62
+ done < added_files.txt
63
+
64
+ # Modified images
65
+ echo -e "### Modified images\n" >> report.md
66
+ # Upload new images
67
+ while IFS= read -r line; do
68
+ cml-publish --title $line --md "$line" > modified_images_new.md < /dev/null
69
+ done < modified_files.txt
70
+
71
+ # Pull images in the master branch from cloud storage
72
+ git checkout master
73
+ dvc pull --remote upstream
74
+ # Upload old images
75
+ while IFS= read -r line; do
76
+ cml-publish --title $line --md "$line" > modified_images_old.md < /dev/null
77
+ done < modified_files.txt
78
+
79
+ # Append image report for modified images
80
+ echo -e "| Path | Old | New |" >> report.md
81
+ echo -e "|---|---|---|" >> report.md
82
+ gpaste modified_files.txt modified_images_old.md modified_images_new.md |
83
+ gawk 'function basename(file) {sub(".*/", "", file);return file} {printf("| %s | %s | %s |\n", basename($1), $2, $3)}'
61
84
62
85
echo -e "</details>\n" >> report.md
63
86
0 commit comments