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
35 changes: 34 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
# Github doesn't seem to like a working-directory arg for a custom action
# and I ideally want to test this works as expected in the root
- name: Copy test files to root
run: cp test/cached-composer-install/composer.* .
run: cp test/cached-composer-install/composer.* .

- name: Install without dev dependencies
uses: ./cached-composer-install
Expand All @@ -40,3 +40,36 @@ jobs:
env:
EXPECT_DEV_PACKAGES: installed
run: php test/cached-composer-install/check-installed.php

integration-test-check-docker-composer-platform:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: 8.3 # note, using 8.3 to prove that the composer reqs are only met within the mounted image
tools: composer:v2

- name: Pass with correct php version
uses: ./check-docker-composer-platform
with:
image: "php:8.4-alpine"
composer_json_dir: '${{ github.workspace }}/test/check-docker-composer-platform'

- name: Fail with incorrect php version
id: with-wrong-version
continue-on-error: true
uses: ./check-docker-composer-platform
with:
image: "php:8.3-alpine"
composer_json_dir: '${{ github.workspace }}/test/check-docker-composer-platform'

- name: Assert failed steps should have failed
shell: bash
run: |
if [ "${{ steps.with-wrong-version.outcome }}" != "failure" ] ; then
echo "Should have failed with incorrect PHP version in image, got ${{ steps.with-wrong-version.outcome }}"
exit 1
fi
39 changes: 39 additions & 0 deletions check-docker-composer-platform/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Check docker image meets composer platform requirements'
description: 'Verifies that the PHP and extension versions in a docker image meet the platform requirements of the project and any composer-managed dependencies'
inputs:
image:
description: 'The docker image name and tag to check'
required: true
composer_json_dir:
description: 'The directory holding the composer.json and composer.lock - defaults to the main workspace'
default: ${{ github.workspace }}
runs:
using: 'composite'
steps:
- id: find_composer
name: Identify path to composer binary
shell: bash
run: |
set +e errexit
composer_bin=$(which composer)
set -e errexit
if [ -z "$composer_bin" ] ; then
echo "Cannot find composer binary on the github actions runner: have you run the setup-php action?"
exit 1
fi

echo "composer_bin=$composer_bin" >> $GITHUB_OUTPUT

- name: Run composer check-platform-reqs
shell: bash
run: |
docker run \
--rm \
--quiet \
-v "${{ steps.find_composer.outputs.composer_bin }}":/usr/bin/composer \
-v "${{ inputs.composer_json_dir }}":/workspace \
-w /workspace \
--entrypoint /usr/bin/composer \
"${{ inputs.image }}" \
check-platform-reqs \
--lock
5 changes: 5 additions & 0 deletions test/check-docker-composer-platform/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "8.4.*"
}
}
20 changes: 20 additions & 0 deletions test/check-docker-composer-platform/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading