diff --git a/.github/workflows/Android-CI.yml b/.github/workflows/Android-CI.yml index 4fc411c8c4..e90ce4916a 100644 --- a/.github/workflows/Android-CI.yml +++ b/.github/workflows/Android-CI.yml @@ -80,7 +80,7 @@ jobs: cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator-5554\ -\ ${{ matrix.emulatorApi }}/* screenshotsToCompare${{ matrix.emulatorApi }} export DISPLAY=:99 sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & - ./screenShotCompare.sh + ./screenShotScript/screenShotCompare.sh - name: Archive screenshots diffs if: ${{ always() }} uses: actions/upload-artifact@v4 diff --git a/.gitmodules b/.gitmodules index 9d36ff314d..4d332661d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "git-diff-image"] path = git-diff-image url = git@github.com:ewanmellor/git-diff-image.git +[submodule "screenShotScript"] + path = screenShotScript + url = git@github.com:hannesa2/screenShotScript.git diff --git a/screenShotCompare.sh b/screenShotCompare.sh deleted file mode 100755 index 07d1477972..0000000000 --- a/screenShotCompare.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/zsh - -diffFiles=./screenshotDiffs -mkdir $diffFiles -#cp MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/emulator\(AVD\)\ -\ 9/* screenshotsToCompare -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 - -OS="`uname`" -case $OS in - 'Linux') - ;; - 'FreeBSD') - ;; - 'WindowsNT') - ;; - 'Darwin') - brew install jq - ;; - 'SunOS') - ;; - 'AIX') ;; - *) ;; -esac - -echo "=> delete all old comments, starting with Screenshot differs:$emulatorApi" - -oldComments=$(curl_gh -X GET https://api.github.com/repos/"$GITHUB_REPOSITORY"/issues/"$PR"/comments | jq '.[] | (.id |tostring) + "|" + (.body | test("Screenshot differs:'$emulatorApi'.*") | tostring)' | grep "|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 -pwd -body="" -COUNTER=0 -ls -la - -echo "=> 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="${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}![screenshot](https://www.mxtracks.info/github/uploads/$newName)

" - fi -done - -if [ ! "$body" == "" ]; then - curl_gh -X POST https://api.github.com/repos/"$GITHUB_REPOSITORY"/issues/$PR/comments -d "{ \"body\" : \"Screenshot differs:$emulatorApi $COUNTER

$body \" }" -fi - -popd 1>/dev/null - -# set error when diffs are there -[ "$(ls -A $diffFiles)" ] && exit 1 || exit 0 diff --git a/screenShotScript b/screenShotScript new file mode 160000 index 0000000000..fe15efbeef --- /dev/null +++ b/screenShotScript @@ -0,0 +1 @@ +Subproject commit fe15efbeefab9b8006d14d1a78b89e6ebfb5befb diff --git a/scripts/lib.sh b/scripts/lib.sh deleted file mode 100644 index 9a24d131e6..0000000000 --- a/scripts/lib.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 -}