Skip to content

Commit

Permalink
Windows: Improve packaging automation
Browse files Browse the repository at this point in the history
Adds a script to download binaries for the specific app version and to
view screenshots.

Adds more screenshots and uploads them as a single zip file.
  • Loading branch information
hluk committed Apr 1, 2024
1 parent e3f318a commit 28188b3
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 67 deletions.
6 changes: 5 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ environment:
--no-quick
# Parameters for default build commands (build_script is used instead).
build:
build: false

install:
- ps: $env:Path = "C:\Program Files\Git\bin;$env:Path"
Expand All @@ -53,6 +53,10 @@ build_script:
after_build:
- bash utils/appveyor/after_build.sh

test_script:
- bash utils/appveyor/test_screenshots.sh
- bash utils/appveyor/test.sh

# Upload test log files.
on_finish:
- ps: >-
Expand Down
66 changes: 0 additions & 66 deletions utils/appveyor/after_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -exuo pipefail
# shellcheck disable=SC1091
source utils/appveyor/env.sh

Source=$APPVEYOR_BUILD_FOLDER
Destination=$APPVEYOR_BUILD_FOLDER/$APP
Executable=$Destination/copyq.exe
BuildPlugins=$BUILD_PATH/plugins/${BUILD_SUB_DIR:-}

mkdir -p "$Destination"

cmake --install "$BUILD_PATH" --config Release --prefix "$Destination" --verbose
Expand Down Expand Up @@ -61,70 +56,9 @@ rm -vf /c/Windows/SysWOW64/libcrypto-*
rm -vf /c/Windows/SysWOW64/libssl-*
OldPath=$PATH
export PATH="$GPGPATH":$Destination

mkdir ~/.gnupg
chmod go-rwx ~/.gnupg
gpg --version

export QT_FORCE_STDERR_LOGGING=1
export COPYQ_TESTS_RERUN_FAILED=1
"$Executable" --help
"$Executable" --version
"$Executable" --info
"$Executable" tests

# Take screenshots of the app.
"$Executable" &
copyq_pid=$!
"$Executable" showAt 0 0 9999 9999

"$Executable" add "Plain text item"
"$Executable" add "Unicode: "
"$Executable" 'write(mimeText, "Highlighted item", mimeColor, "#ff0")'
"$Executable" 'write(mimeText, "Item with notes", mimeItemNotes, "Notes...")'
"$Executable" 'write(mimeText, "Item with tags", plugins.itemtags.mimeTags, "important")'
"$Executable" write text/html "<p><b>Rich text</b> <i>item</i></p>"
"$Executable" write image/png - < "$Source/src/images/icon_128x128.png"

# FIXME: Native notifications do not show up.
# Maybe a user interaction, like mouse move, is required.
"$Executable" config native_notifications "false"
"$Executable" popup "Popup title" "Popup message..."
"$Executable" notification \
.title "Notification title" \
.message "Notification message..." \
.button OK cmd data \
.button Close cmd data

"$Executable" sleep 1000

export PATH=$Destination:$OldPath

screenshot() {
"$Executable" screenshot > "$1.png"
appveyor PushArtifact "$1.png" -DeploymentName "$1"
}

screenshot "Screenshot - App"

"$Executable" keys "Ctrl+P" "focus:ConfigurationManager"
for n in $(seq 9); do
screenshot "Screenshot - Configuration Tab $n"
"$Executable" keys "DOWN" "focus:ConfigurationManager"
done
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" keys "Shift+F1" "focus:AboutDialog"
screenshot "Screenshot - About Dialog"
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" keys "Alt+T" "focus:Menu"
screenshot "Screenshot - Tab Menu"
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" exit
wait "$copyq_pid"

export PATH=$OldPath

choco install -y InnoSetup
Expand Down
8 changes: 8 additions & 0 deletions utils/appveyor/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ APP_VERSION=$(
)
export APP_VERSION
export APP=copyq-$APP_VERSION

export Source=$APPVEYOR_BUILD_FOLDER
export Destination=$APPVEYOR_BUILD_FOLDER/$APP
export Executable=$Destination/copyq.exe
export BuildPlugins=$BUILD_PATH/plugins/${BUILD_SUB_DIR:-}

export QT_FORCE_STDERR_LOGGING=1
export COPYQ_TESTS_RERUN_FAILED=1
14 changes: 14 additions & 0 deletions utils/appveyor/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/bash
set -exuo pipefail

# shellcheck disable=SC1091
source utils/appveyor/env.sh

export PATH="$GPGPATH":$Destination:$PATH
mkdir ~/.gnupg
chmod go-rwx ~/.gnupg
gpg --version

"$Executable" tests

gpgconf --kill all
78 changes: 78 additions & 0 deletions utils/appveyor/test_screenshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/bash
set -exuo pipefail

# shellcheck disable=SC1091
source utils/appveyor/env.sh

export PATH=$Destination:$PATH

export QT_FORCE_STDERR_LOGGING=1

"$Executable" &
copyq_pid=$!
"$Executable" showAt 0 0 9999 9999

"$Executable" add "Plain text item"
"$Executable" add "Unicode: "
"$Executable" 'write(mimeText, "Highlighted item", mimeColor, "#ff0")'
"$Executable" 'write(mimeText, "Item with notes", mimeItemNotes, "Notes...")'
"$Executable" 'write(mimeText, "Item with tags", plugins.itemtags.mimeTags, "important")'
"$Executable" write text/html "<p><b>Rich text</b> <i>item</i></p>"
"$Executable" write image/png - < "$Source/src/images/icon_128x128.png"

# FIXME: Native notifications do not show up.
# Maybe a user interaction, like mouse move, is required.
"$Executable" config native_notifications "false"
"$Executable" popup "Popup title" "Popup message..."
"$Executable" notification \
.title "Notification title" \
.message "Notification message..." \
.button OK cmd data \
.button Close cmd data

"$Executable" sleep 1000

screenshot_count=0
mkdir -p copyq-screenshots

screenshot() {
screenshot_count=$((screenshot_count + 1))
file=$(printf "copyq-screenshots/%02d - %s.png" "$screenshot_count" "$1")
"$Executable" screenshot > "$file"
}

screenshot "App"

"$Executable" keys "Ctrl+P" "focus:ConfigurationManager"
for n in $(seq 9); do
screenshot "Configuration Tab $n"
"$Executable" keys "DOWN" "focus:ConfigurationManager"
done
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" keys "Shift+F1" "focus:AboutDialog"
screenshot "About Dialog"
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" keys "Alt+T" "focus:Menu"
screenshot "Tab Menu"
"$Executable" keys "ESCAPE" "focus:ClipboardBrowser"

"$Executable" keys "Ctrl+N" "focus:ItemEditorWidget"
"$Executable" keys ":Testing 1 2 3" "focus:ItemEditorWidget"
screenshot "Editor"
"$Executable" keys "F2" "focus:ClipboardBrowser"

"$Executable" keys "Ctrl+N" "focus:ItemEditorWidget" \
":New Item" "F2" "focus:ClipboardBrowser"
"$Executable" keys "F2" "focus:ItemEditorWidget" \
"END" "ENTER" ":with Notes" "F2" "focus:ClipboardBrowser"
"$Executable" keys "Shift+F2" "focus:ItemEditorWidget" \
":Some Notes" "F2" "focus:ClipboardBrowser"
screenshot "Items"

7z a "copyq-screenshots.zip" -r "copyq-screenshots"
appveyor PushArtifact "copyq-screenshots.zip" -DeploymentName "CopyQ Screenshots"

"$Executable" exit
wait "$copyq_pid"
13 changes: 13 additions & 0 deletions utils/download_window_builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
version=$1
base=https://ci.appveyor.com/api/projects/hluk/copyq/artifacts
urls=(
"$base/copyq-$version.zip?tag=v$version"
"$base/copyq-$version-setup.exe?tag=v$version"
)
for url in "${urls[@]}"; do
echo "Downloading: $url"
curl -LO --fail-with-body "$url"
done
echo "DONE"
20 changes: 20 additions & 0 deletions utils/view_windows_screenshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail

image_viewer=${IMAGE_VIEWER:-eog}
url="https://ci.appveyor.com/api/projects/hluk/copyq/artifacts/copyq-screenshots.zip?$*"

if [[ $# == 0 ]]; then
echo "Usage: $0 {tag=v8.0.0|branch=master}"
exit 1
fi

dir=$(mktemp --directory)
clean() {
rm -rf -- "$dir"
}
trap clean QUIT TERM INT HUP EXIT

curl -L --fail-with-body --output "$dir/copyq-screenshots.zip" "$url"
7z e -o"$dir" "$dir/copyq-screenshots.zip"
"$image_viewer" "$dir"

0 comments on commit 28188b3

Please sign in to comment.