diff --git a/.github/workflows/Android-CI.yml b/.github/workflows/Android-CI.yml
index dbc2bba6a2..f16d7eb789 100644
--- a/.github/workflows/Android-CI.yml
+++ b/.github/workflows/Android-CI.yml
@@ -60,6 +60,8 @@ jobs:
MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
MPChartExample/build/outputs/androidTest-results/connected
- name: Compare screenshots
+ env:
+ CLASSIC_TOKEN: ${{ secrets.CLASSIC_TOKEN }}
run: |
ls -ls MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator\(AVD\)\ -\ 9/* screenshotsToCompare
diff --git a/screenShotCompare.sh b/screenShotCompare.sh
index b33a9215e0..de13c7c586 100755
--- a/screenShotCompare.sh
+++ b/screenShotCompare.sh
@@ -1,3 +1,5 @@
+#!/bin/zsh
+
diffFiles=./screenshotDiffs
mkdir $diffFiles
#cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator\(AVD\)\ -\ 9/* screenshotsToCompare
@@ -5,5 +7,48 @@ set -x
./git-diff-image/install.sh
GIT_DIFF_IMAGE_OUTPUT_DIR=$diffFiles git diff-image
+source scripts/lib.sh
+
+PR=$(echo "$GITHUB_REF_NAME" | sed "s/\// /" | awk '{print $1}')
+echo pr=$PR
+brew install jq
+
+# delete all old comments, starting with "Screenshot differs:"
+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"|")
+echo "comments=$comments"
+echo "$oldComments" | while read comment; do
+ echo "delete comment=$comment"
+ curl_gh -X DELETE https://api.github.com/repos/"$GITHUB_REPOSITORY"/issues/comments/"$comment"
+done
+
+pushd $diffFiles
+body=""
+COUNTER=0
+ls -la
+
+# ignore an error, when no files where found https://unix.stackexchange.com/a/723909/201876
+setopt no_nomatch
+for f in *.png; do
+ if [[ ${f} == "*.png" ]]
+ then
+ echo "nothing found"
+ else
+ (( COUNTER++ ))
+
+ newName="$1-${f}"
+ mv "${f}" "$newName"
+ echo "==> Uploaded screenshot $newName"
+ curl -i -F "file=@$newName" https://www.mxtracks.info/github
+ echo "==> Add screenshot comment $PR"
+ body="$body ${f}
"
+ fi
+done
+
+if [ ! "$body" == "" ]; then
+ curl_gh -X POST https://api.github.com/repos/"$GITHUB_REPOSITORY"/issues/$PR/comments -d "{ \"body\" : \"Screenshot differs: $COUNTER
$body \" }"
+fi
+
+popd 1>/dev/null
+
# set error when diffs are there
[ "$(ls -A $diffFiles)" ] && exit 1 || exit 0
diff --git a/scripts/lib.sh b/scripts/lib.sh
new file mode 100644
index 0000000000..9a24d131e6
--- /dev/null
+++ b/scripts/lib.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+## This file is intended to be sourced by other scripts
+
+function err() {
+ echo >&2 "$@"
+}
+
+function curl_gh() {
+ if [[ -n "$CLASSIC_TOKEN" ]]; then
+ curl \
+ --silent \
+ --header "Authorization: token $CLASSIC_TOKEN" \
+ "$@"
+ else
+ err "WARNING: No CLASSIC_TOKEN found. Skipping API call"
+ fi
+}