Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 18 additions & 128 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,135 +1,25 @@
name: CI
on: [push, pull_request]

jobs:
tests:
name: PHP ${{ matrix.php }}
on:
push:
branches: [main]
pull_request:

# ubuntu-24.04 ships libvips 8.15
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php: ["8.4", "8.5", "8.6"]
env:
extensions: exif, ffi, gd, imagick
# tests for these drivers and formats fail instead of skipping
DARKROOM_REQUIRE: "gd:avif,webp imagick:avif,heic,jp2,webp vips:avif,heic,jp2,jxl,webp"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
permissions:
contents: read

jobs:
php:
uses: getkirby/actions/.github/workflows/php.yml@5a2291a578b5304133b7e3106f3bb92f9385bea0 # 0.1.0
with:
# ImageMagick and libvips read HEIC and AVIF through libheif, whose codecs are plugins:
# libde265 and x265 for HEIC, aom for AVIF (aomdec is a dependency)
- name: Install libvips and libheif's HEIC and AVIF codecs
run: |
sudo apt-get update
sudo apt-get install -y libvips42t64 libheif-plugin-libde265 libheif-plugin-x265 libheif-plugin-aomenc

- name: Setup PHP cache environment
id: ext-cache
uses: shivammathur/cache-extensions@695b1b465eba861efe67cbbc31252c27f5ed253d # 1.15.11
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: php-v1

- name: Cache PHP extensions
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.ext-cache.outputs.dir }}
key: ${{ steps.ext-cache.outputs.key }}
restore-keys: ${{ steps.ext-cache.outputs.key }}

- name: Setup PHP environment
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install cpx
run: composer global require cpx/cpx:2.1.0

- name: Cache cpx tools
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cpx
key: cpx-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('composer.json') }}
restore-keys: cpx-${{ runner.os }}-php${{ matrix.php }}-

- name: Get Composer cache directory
id: composerCache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composerCache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-php${{ matrix.php }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Show driver libraries
run: |
php -r 'var_export(gd_info());'
php -r 'echo Imagick::getVersion()["versionString"], PHP_EOL, implode(", ", Imagick::queryFormats()), PHP_EOL;'
php -r 'require "vendor/autoload.php"; echo "libvips ", Jcupitt\Vips\Config::version(), PHP_EOL;'

- name: Run tests
run: composer test -- --display-skipped

analysis:
name: Analysis

runs-on: ubuntu-24.04
timeout-minutes: 10
env:
php: "8.4"
# libde265 and x265 for HEIC, aom for AVIF (aomdec is a dependency); ubuntu-24.04 ships libvips 8.15
apt: libvips42t64 libheif-plugin-libde265 libheif-plugin-x265 libheif-plugin-aomenc
# tests for these drivers and formats fail instead of skipping
env: DARKROOM_REQUIRE=gd:avif,webp imagick:avif,heic,jp2,webp vips:avif,heic,jp2,jxl,webp
extensions: exif, ffi, gd, imagick

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup PHP environment
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ env.php }}
extensions: ${{ env.extensions }}
coverage: none

- name: Install cpx
run: composer global require cpx/cpx:2.1.0

- name: Cache cpx tools
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cpx
key: cpx-${{ runner.os }}-analysis-php${{ env.php }}-${{ hashFiles('composer.json') }}
restore-keys: cpx-${{ runner.os }}-analysis-php${{ env.php }}-

- name: Install dependencies
id: finishPrepare
run: composer install --prefer-dist

- name: Validate composer.json
if: always() && steps.finishPrepare.outcome == 'success'
run: composer run analyze:composer

- name: Statically analyze using Psalm
if: always() && steps.finishPrepare.outcome == 'success'
run: composer run analyze:psalm -- --output-format=github --php-version=${{ env.php }}

- name: Check for PHP coding style violations
if: always() && steps.finishPrepare.outcome == 'success'
run: composer run fix -- --dry-run --diff
phpunit-args: --display-skipped
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@analyze",
"@test"
],
"fix": "cpx getkirby/php-cs:^0.2 fix",
"fix": "cpx getkirby/php-cs:0.2.1 fix",
"playground": [
"Composer\\Config::disableProcessTimeout",
"@putenv PHP_CLI_SERVER_WORKERS=8",
Expand Down