From 3f41dd0f94f5590c7b3ce143949fdfc8b2e3d10e Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 29 Jan 2022 13:52:27 +0100 Subject: [PATCH] :tada: Add advanced CI tests --- .github/workflows/checks.yml | 23 ++++ docs/changelog.md | 1 + tests/references/preferences.png | Bin 0 -> 4817 bytes tests/run-test.sh | 180 +++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 tests/references/preferences.png create mode 100755 tests/run-test.sh diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d1d6ebf..80b5371 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -76,6 +76,17 @@ jobs: ( contains(github.ref, 'main') && !contains(github.event.head_commit.message, '[no-ci]') ) || ( contains(github.ref, 'develop') && !contains(github.event.head_commit.message, '[no-ci]') ) || contains(github.event.head_commit.message, '[run-ci]') + strategy: + fail-fast: false + matrix: + version: + - '32' + - '33' + - '34' + - '35' + session: + - 'gnome-xsession' + - 'gnome-wayland-nested' steps: - uses: actions/checkout@v2 - name: Download Dependencies @@ -84,3 +95,15 @@ jobs: sudo apt install gettext -qq - name: Build Burn-My-Windows run: make + - name: Test Burn-My-Windows + run: sudo $GITHUB_WORKSPACE/tests/run-test.sh -v ${{ matrix.version }} -s ${{ matrix.session }} + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: log_${{ matrix.version }}_${{ matrix.session }} + path: fail.log + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: screen_${{ matrix.version }}_${{ matrix.session }} + path: fail.png \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index 6c0b0a1..40b8706 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -16,6 +16,7 @@ * Added a menu entry with a link to the guide for creating new effect types. * Added a new option to the Matrix Effect: **Vertical Overshooting**: This can add some vertical variation to the start and end position of the letter drops. * Thanks to improved timing, the default animation time of several effects could be reduced. +* **Add advanced CI tests:** For each commit to `main`, it is now tested whether the extension can be installed and if the preferences dialog can be shown on GNOME Shell 3.36, 3.38, 40, and 41. Both, X11 and Wayland are checked. * The README now shows the current lines of code and the current comment percentage using my [dynamic-badges-action](https://github.com/Schneegans/dynamic-badges-action). ## [Burn My Window 9](https://github.com/schneegans/Burn-My-Windows/releases/tag/v9) diff --git a/tests/references/preferences.png b/tests/references/preferences.png new file mode 100644 index 0000000000000000000000000000000000000000..b57a4bf45e88b4ee28a15a272c831e0e5e0eaa9a GIT binary patch literal 4817 zcmb7IXHXMBw+%5ss3N`h5(0wsjv=%Ff}tzDh(sjx-a{3TDoBwMn)Ig9r1zpg5D=s{ zX&*?FF7Wc^{e3^)yED6Yc4l{H_wLzy&zxAKo+bq;GbsQ7pwL378Q^^xzGZ=l@O>-V zy$$a`o^UNAFy4Z|FW%tCOkV2GybN7mdimOVH~<`7T+t2>J?%Xl99%q6u3iWCI+Xzc zYI`j;6(hf#{ak-9Bjdcm&V~|bx)Jp!gh>xI{VN;AusFSR>q?ogcxVz^Xb6a zrC`x>PfFtB-HyOelI1qvgM-_U&Pw;z9NR~XX@%+Y03sgdCs^_dTc87yf(8=dlnG-p z>IIEpnfZ}K(~mIXWzi&QDpLQaDI`6ff6Es5A=LcHSdzK@y0J^CijTS(^R()P8S?~G)9Yoe6cnI0O5?9qvepFMrtA7$HX z9!mp&yT~+WGiOy9h&;h^KiHI=dU(TDk)M-*^z@8D2W^cD%tC+nf}lW51=L7UmihEs zh9-JT$(>t;zMPmJiD~vZ7$~{^6SFmxl8Mfpzs&>0PZ83T0hmoX5=PwDyQilgH25AY zCt*kV>y3BANhH~OY%KzVnQBC=$Rpt!P429F9HHC=w!5mmP7+7FwD3`h@t(7$&VKLK zf@Vg(QayN)BfB#7EKS;dU_S`}Gomf4eEmeNXo?~*{J2Zrl|6gO-_-5#Rhwd3jw~hG zsRC?L&TR&wjOP#br<{9#Rp12$hbUjM&W;1M3cIY1^ugCbW!Z8%)b2olsbPeWgd^A9 zxz3MHW*cAvd{L;j=lte8HF0(BG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%}cP!{>)j9kght@O)8tec(Y;L#RLj7qojBeDT4qNry>FJHUP|QUs$H zkk(vXX|Rww=hSzkx+l#XK_JMZsqOkC2g!#kUTU}b8qu~EwqG1M0Le+dkN>1B2zF)i zIiplRMSrX|7J%D78jPL)3I)h?hJUvtx;}?xa@IwUf6=DISH-KhJ8dCFENA^bMP5?j z>|H9Un>Ewi)m2YC0wZC$u!iz-M80xDv(grj`Mwq^8CajodtIU%e5k@mN?I&~08Ek4 z0zNSaucRYpf)broaCC<HTh01xL}A8zY+ zw|L&4O95CpjDXW|*bZelTp1aq3R@Hbcx{I8kw3Q0s@%IgDG_lKgIs)uOND6rFx!EXYV{dsE|(s2?3LAzMNZxt9;E&Dd^FEoi!#?qKciKew`1++ncLlbgZ3N5+f$3zcYQFdlzKh>YO3yH0XNGsb&AJt7Cs_XyIT(mS8mSz z`o(Z>3kgZp)->aPhBC`NH7vP22*OwRkQQAkx_&ZR0Ct*ttAt^~^FJmi$mqe#zL<(z znNgn55tDPMsxgodhK?fF2&%i&{r~C^|D$Fk>=H7YxYvKI3+Qa1Hxfm*E>hNx3p6pM zx@|7Vwdf|ZI*skp#;2vxN=h#(vO=g<>TXXcnqObIW%?O;om>SS1}GV1LKqXt)^I62 zv$v;-KKUgd%Xk=eh$?8dy9jRdr#GiIcA14b7TVPL-GvWW8`mQ;GB00wL z(&uTl1cf18Z_5pl^6uf#W!4J1Z3+t!8E2o?g_j6;oE#J0JU(y%g7g#Q;{4EK!y literal 0 HcmV?d00001 diff --git a/tests/run-test.sh b/tests/run-test.sh new file mode 100755 index 0000000..8d04204 --- /dev/null +++ b/tests/run-test.sh @@ -0,0 +1,180 @@ +#!/bin/bash + +# -------------------------------------------------------------------------------------- # +# ) ( # +# ( /( ( ( ) ( ( ( ( )\ ) ( ( # +# )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( # +# ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ # +# | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) # +# | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< # +# |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ # +# |__/ # +# Copyright (c) 2021 Simon Schneegans # +# Released under the GPLv3 or later. See LICENSE file for details. # +# -------------------------------------------------------------------------------------- # + +# This script is based on a similar script from the Fly-Pie GNOME Shell extension which is +# published under the MIT License (https://github.com/Schneegans/Fly-Pie). + +# This script executes several automated tests on Burn-My-Windows. To do this, it is +# installed in a fedora-based container running GNOME Shell on xvfb. The used container is +# hosted on Github: https://github.com/Schneegans/gnome-shell-pod. This scripts installs +# Burn-My-Windows from the burn-my-windows@schneegans.github.com.zip file which is +# expected to be present in the repository root. Therefore you have to call "make" before +# this script. +# +# The scripts supports two arguments: +# +# -v fedora_version: This determines the version of GNOME Shell to test agains. +# -v 32: GNOME Shell 3.36 +# -v 33: GNOME Shell 3.38 +# -v 34: GNOME Shell 40 +# -v 35: GNOME Shell 41 +# -s session: This can either be "gnome-xsession" or "gnome-wayland-nested". + +# Exit on error. +set -e + +usage() { + echo "Usage: $0 -v fedora_version -s session" >&2 +} + +FEDORA_VERSION=33 +SESSION="gnome-xsession" + +while getopts "v:s:h" opt; do + case $opt in + v) FEDORA_VERSION="${OPTARG}";; + s) SESSION="${OPTARG}";; + h) usage; exit 0;; + *) usage; exit 1;; + esac +done + +# Go to the repo root. +cd "$( cd "$( dirname "$0" )" && pwd )/.." || \ + { echo "ERROR: Could not find the repo root."; exit 1; } + +IMAGE="ghcr.io/schneegans/gnome-shell-pod-${FEDORA_VERSION}" +EXTENSION="burn-my-windows@schneegans.github.com" + +# Run the container. For more info, visit https://github.com/Schneegans/gnome-shell-pod. +POD=$(podman run --rm --cap-add=SYS_NICE --cap-add=IPC_LOCK -td "${IMAGE}") + +# Properly shutdown podman when this script is exited. +quit() { + podman kill "${POD}" + wait +} + +trap quit INT TERM EXIT + +# -------------------------------------------------------------------------------- methods + +# This function is used below to execute any shell command inside the running container. +do_in_pod() { + podman exec --user gnomeshell --workdir /home/gnomeshell "${POD}" set-env.sh "$@" +} + +# This is called whenever a test fails. It prints an error message (given as first +# parameter), captures a screenshot to "fail.png" and stores a log in "fail.log". +fail() { + echo "${1}" + podman cp "${POD}:/opt/Xvfb_screen0" - | tar xf - --to-command 'convert xwd:- fail.png' + LOG=$(do_in_pod sudo journalctl | grep -C 5 "error\|gjs") + echo "${LOG}" > fail.log + exit 1 +} + +# This searches the virtual screen of the container for a given target image (first +# parameter). If it is not found, an error message (second paramter) is printed and the +# script exits via the fail() method above. +find_target() { + echo "Looking for ${1} on the screen." + POS=$(do_in_pod find-target.sh "${1}") || true + if [[ -z "${POS}" ]]; then + fail "${2}" + fi +} + +# This searches the virtual screen of the container for a given target image (first +# parameter) and moves the mouse to the upper left corner of the best match. If the target +# image is not found, an error message (second paramter) is printed and the script exits +# via the fail() method above. +move_mouse_to_target() { + echo "Trying to move mouse to ${1}." + POS=$(do_in_pod find-target.sh "${1}") || true + if [[ -z "${POS}" ]]; then + fail "${2}" + fi + + # shellcheck disable=SC2086 + do_in_pod xdotool mousemove $POS +} + +# This simulates the given keystroke in the container. Simply calling "xdotool key $1" +# sometimes fails to be recognized. Maybe the default 12ms between key-down and key-up +# are too short for xvfb... +send_keystroke() { + do_in_pod xdotool keydown "${1}" + sleep 0.5 + do_in_pod xdotool keyup "${1}" +} + +# This simulates a mouse click in the container. Simply calling "xdotool click $1" +# sometimes fails to be recognized. Maybe the default 12ms between button-down and +# button-up are too short for xvfb... +send_click() { + do_in_pod xdotool mousedown "${1}" + sleep 0.5 + do_in_pod xdotool mouseup "${1}" +} + + +# ----------------------------------------------------- wait for the container to start up + +echo "Waiting for D-Bus." +do_in_pod wait-user-bus.sh > /dev/null 2>&1 + + +# ----------------------------------------------------- install the to-be-tested extension + +echo "Installing extension." +podman cp "tests/references" "${POD}:/home/gnomeshell/references" +podman cp "${EXTENSION}.zip" "${POD}:/home/gnomeshell" +do_in_pod gnome-extensions install "${EXTENSION}.zip" +do_in_pod gnome-extensions enable "${EXTENSION}" + + +# ---------------------------------------------------------------------- start GNOME Shell + +# Starting with GNOME 40, there is a "Welcome Tour" dialog popping up at first launch. +# We disable this beforehand. +if [[ "${FEDORA_VERSION}" -gt 33 ]]; then + echo "Disabling welcome tour." + do_in_pod gsettings set org.gnome.shell welcome-dialog-last-shown-version "999" || true +fi + +echo "Starting $(do_in_pod gnome-shell --version)." +do_in_pod systemctl --user start "${SESSION}@:99" +sleep 10 + +# Starting with GNOME 40, the overview is the default mode. We close this here by hitting +# the super key. +if [[ "${FEDORA_VERSION}" -gt 33 ]]; then + echo "Closing Overview." + send_keystroke "super" + sleep 3 +fi + + +# ---------------------------------------------------------------------- perform the tests + +# First we open the preferences and check whether the window is shown on screen by +# searching for a small snippet of the preferences dialog. +echo "Opening Preferences." +do_in_pod gnome-extensions prefs "${EXTENSION}" +sleep 3 +find_target "references/preferences.png" "Failed to open preferences!" + +echo "All tests executed successfully."