Skip to content

Commit

Permalink
Fix CI/CD fail by installing ImageMagick on runner
Browse files Browse the repository at this point in the history
This commit addresses an issue where CI/CD jobs fail due to the removal of
`imagemagick` from GitHub's preinstalled software list for Ubuntu
runners. As a result, commands relying on `imagemagick` were not found.

To resolve this, the commit installs `imagemagick` across all platforms
(Linux, macOS, and Windows). This safeguards against future changes to
the preinstalled software list on GitHub runners.

This commit also centralizes installing of ImageMagick as its own action
for reusability.
  • Loading branch information
undergroundwires committed Oct 11, 2024
1 parent 74378f7 commit 627857a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .github/actions/install-imagemagick/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
inputs:
project-root:
required: false
default: '.'
runs:
using: composite
steps:
-
name: Install ImageMagick
shell: bash
run: ./.github/actions/install-imagemagick/install-imagemagick.sh
working-directory: ${{ inputs.project-root }}
56 changes: 56 additions & 0 deletions .github/actions/install-imagemagick/install-imagemagick.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

main() {
local command
if ! command=$(get_install_command); then
fatal_error 'Could not find available command to install'
fi
if ! $command; then
echo "Failed to install ImageMagick. Command: ${command}"
exit 1
fi
echo 'ImageMagick installation completed successfully'
}

get_install_command() {
case "$OSTYPE" in
darwin*)
ensure_command_exists 'brew'
echo 'brew install imagemagick'
;;
linux-gnu*)
if is_ubuntu; then
ensure_command_exists 'apt'
echo 'sudo apt install -y imagemagick'
else
fatal_error 'Unsupported Linux distribution'
fi
;;
msys*|cygwin*)
ensure_command_exists 'choco'
echo 'choco install -y imagemagick'
;;
*)
fatal_error "Unsupported operating system: $OSTYPE"
;;
esac
}

ensure_command_exists() {
local -r command="$1"
if ! command -v "$command" >/dev/null 2>&1; then
fatal_error 'Command missing: brew'
fi
}

fatal_error() {
local -r error_message="$1"
>&2 echo "$error_message"
exit 1
}

is_ubuntu() {
[ -f /etc/lsb-release ] && grep -q 'Ubuntu' /etc/lsb-release
}

main
6 changes: 3 additions & 3 deletions .github/workflows/checks.desktop-runtime-errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
-
name: Install dependencies
uses: ./.github/actions/npm-install-dependencies
-
name: Install ImageMagick # For screenshots
uses: ./.github/actions/install-imagemagick
-
name: Configure Ubuntu
if: contains(matrix.os, 'ubuntu') # macOS runner is missing Docker
Expand Down Expand Up @@ -56,9 +59,6 @@ jobs:
sudo Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo "DISPLAY=:99" >> $GITHUB_ENV
# Install ImageMagick for screenshots
sudo apt install -y imagemagick
# Install xdotool and xprop (from x11-utils) for window title capturing
sudo apt install -y xdotool x11-utils
-
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/checks.scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ jobs:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ macos, ubuntu, windows ]
os: [macos, ubuntu, windows]
fail-fast: false # Still interested to see results from other combinations
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Install ImageMagick on macOS
if: matrix.os == 'macos'
run: brew install imagemagick
name: Install ImageMagick
uses: ./.github/actions/install-imagemagick
-
name: Setup node
uses: ./.github/actions/setup-node
Expand Down

0 comments on commit 627857a

Please sign in to comment.