Skip to content

perf: optimize ImageMagick installation in GitHub Actions workflows#10005

Merged
paulbalandan merged 1 commit intocodeigniter4:developfrom
paulbalandan:perf-optimize-imagick-installation
Feb 25, 2026
Merged

perf: optimize ImageMagick installation in GitHub Actions workflows#10005
paulbalandan merged 1 commit intocodeigniter4:developfrom
paulbalandan:perf-optimize-imagick-installation

Conversation

@paulbalandan
Copy link
Member

@paulbalandan paulbalandan commented Feb 24, 2026

Description

This PR optimizes the ImageMagick installation step in GitHub Actions workflows to significantly reduce execution time, especially for PHP 8.4 where the current implementation takes over 10 minutes.

Problem

The current ImageMagick installation process:

  • Takes 10+ minutes on PHP 8.4 (vs. 2-3 minutes for other PHP versions)
  • Installs unnecessary dependencies (fonts, ghostscript, poppler, etc.)
  • Uses --reinstall flag which forces redownloading packages
  • Includes a problematic --fix-broken call that suggests unresolved dependency conflicts
  • Multiple separate apt-get calls causing overhead

Solution

The optimized installation:

  • Eliminates the --reinstall flag
  • Removes the --fix-broken call
  • Removes unnecessary font packages that aren't needed for imagick tests
  • Consolidates into a single apt-get install command

Changes

Updated two workflow files:

  • .github/workflows/reusable-phpunit-test.yml
  • .github/workflows/reusable-serviceless-phpunit-test.yml

The optimized installation now includes only necessary packages:

  • imagemagick - core ImageMagick library
  • libmagickwand-dev - PHP imagick extension development headers
  • ghostscript - PostScript/PDF rendering (required for image processing)
  • poppler-data - PDF rendering support
  • libjbig2dec0:amd64 - JBIG2 image compression support
  • libopenjp2-7:amd64 - JPEG2000 support

This reduces installation time from 10+ minutes to ~2-3 minutes on PHP 8.4, matching other PHP versions.

Collaboration

This work was developed with assistance from GitHub Copilot (Claude AI), which helped identify the performance bottlenecks, propose optimizations, and validate the implementation.

Checklist

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication) - N/A
  • Unit testing, with >80% coverage - N/A (workflow configuration change)
  • User guide updated - N/A (infrastructure change)
  • Conforms to style guide

Remove unnecessary dependencies and redundant installation commands that cause
significant slowdowns on PHP 8.4.

Changes:
- Remove --reinstall flag which forces unnecessary downloads
- Remove unneeded packages (fonts, ghostscript, poppler, etc.)
- Remove problematic --fix-broken call
- Use --no-install-recommends to skip optional dependencies
- Consolidate installation into single apt-get command

This reduces installation time from 10+ minutes on PHP 8.4 to 2-3 minutes,
matching other PHP versions.
@paulbalandan paulbalandan force-pushed the perf-optimize-imagick-installation branch from bea81b1 to 26d5e82 Compare February 24, 2026 19:31
@paulbalandan paulbalandan added the github_actions Pull requests that update Github_actions code label Feb 24, 2026
@paulbalandan paulbalandan merged commit cfa7042 into codeigniter4:develop Feb 25, 2026
39 checks passed
@paulbalandan paulbalandan deleted the perf-optimize-imagick-installation branch February 25, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update Github_actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants