File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 6464 MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
6565 MPChartExample/build/outputs/androidTest-results/connected
6666 - name : Compare screenshots
67+ env :
68+ CLASSIC_TOKEN : ${{ secrets.CLASSIC_TOKEN }}
6769 run : |
6870 ls -ls MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
6971 cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator\(AVD\)\ -\ 9/* screenshotsToCompare
Original file line number Diff line number Diff line change 1+ #! /bin/zsh
2+
13diffFiles=./screenshotDiffs
24mkdir $diffFiles
35# cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator\(AVD\)\ -\ 9/* screenshotsToCompare
46set -x
57./git-diff-image/install.sh
68GIT_DIFF_IMAGE_OUTPUT_DIR=$diffFiles git diff-image
79
10+ source scripts/lib.sh
11+
12+ PR=$( echo " $GITHUB_REF_NAME " | sed " s/\// /" | awk ' {print $1}' )
13+ echo pr=$PR
14+ brew install jq
15+
16+ # delete all old comments, starting with "Screenshot differs:"
17+ oldComments=$( curl_gh -X GET https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/" $PR " /comments | jq ' .[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("Screenshot differs:.*") | tostring)' | grep " true|true" | tr -d " \" " | cut -f1 -d" |" )
18+ echo " comments=$comments "
19+ echo " $oldComments " | while read comment; do
20+ echo " delete comment=$comment "
21+ curl_gh -X DELETE https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/comments/" $comment "
22+ done
23+
24+ pushd $diffFiles
25+ body=" "
26+ COUNTER=0
27+ ls -la
28+
29+ # ignore an error, when no files where found https://unix.stackexchange.com/a/723909/201876
30+ setopt no_nomatch
31+ for f in * .png; do
32+ if [[ ${f} == " *.png" ]]
33+ then
34+ echo " nothing found"
35+ else
36+ (( COUNTER++ ))
37+
38+ newName=" $1 -${f} "
39+ mv " ${f} " " $newName "
40+ echo " ==> Uploaded screenshot $newName "
41+ curl -i -F " file=@$newName " https://www.mxtracks.info/github
42+ echo " ==> Add screenshot comment $PR "
43+ body=" $body ${f}  <br/><br/>"
44+ fi
45+ done
46+
47+ if [ ! " $body " == " " ]; then
48+ curl_gh -X POST https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/$PR /comments -d " { \" body\" : \" Screenshot differs: $COUNTER <br/><br/> $body \" }"
49+ fi
50+
51+ popd 1> /dev/null
52+
853# set error when diffs are there
954[ " $( ls -A $diffFiles ) " ] && exit 1 || exit 0
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # # This file is intended to be sourced by other scripts
4+
5+ function err() {
6+ echo >&2 " $@ "
7+ }
8+
9+ function curl_gh() {
10+ if [[ -n " $CLASSIC_TOKEN " ]]; then
11+ curl \
12+ --silent \
13+ --header " Authorization: token $CLASSIC_TOKEN " \
14+ " $@ "
15+ else
16+ err " WARNING: No CLASSIC_TOKEN found. Skipping API call"
17+ fi
18+ }
You can’t perform that action at this time.
0 commit comments