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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This action is able to run certain test suites for Matomo or any Matomo plugin.

Defines the PHP version to set up for testing. (Not needed for Client tests)

Use `matomo5_min_php`/`matomo5_max_php` (Matomo 5) or `matomo6_min_php`/`matomo6_max_php` (Matomo 6) to resolve to the centrally managed (defined in action.yml) minimum or maximum PHP versions supported by Matomo tests.
Use `matomo5_min_php`/`matomo5_max_php` (Matomo 5) or `matomo6_min_php`/`matomo6_max_php` (Matomo 6) to resolve to the centrally managed minimum or maximum PHP versions supported by Matomo tests. The alias table is `scripts/bash/resolve_php_version.sh`, so anything else needing these versions can resolve the same table instead of copying it.

The action uses `shivammathur/setup-php` to set up PHP. You can find supported PHP versions here: https://github.com/shivammathur/setup-php#tada-php-support

Expand Down
26 changes: 6 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,13 @@ runs:
- name: Resolve PHP version
id: resolve-php
shell: bash
# the alias table lives in scripts/bash/resolve_php_version.sh so anything else needing
# these versions resolves the same table instead of copying it. The input arrives through
# the environment rather than an expression, so a caller's value is never expanded as shell.
env:
PHP_VERSION_INPUT: ${{ inputs.php-version }}
run: |
case "${{ inputs.php-version }}" in
matomo5_min_php)
RESOLVED_VERSION="7.2"
;;
matomo5_max_php)
RESOLVED_VERSION="8.5"
;;
matomo6_min_php)
RESOLVED_VERSION="8.1"
;;
matomo6_max_php)
RESOLVED_VERSION="8.5"
;;
'')
exit 0
;;
*)
RESOLVED_VERSION="${{ inputs.php-version }}"
;;
esac
RESOLVED_VERSION=$("${{ github.action_path }}/scripts/bash/resolve_php_version.sh" "$PHP_VERSION_INPUT")

echo "version=$RESOLVED_VERSION" >> "$GITHUB_OUTPUT"

Expand Down
31 changes: 31 additions & 0 deletions scripts/bash/resolve_php_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Resolves the centrally managed PHP version aliases to concrete versions, so that a caller can
# track a Matomo major's floor or ceiling without repeating the number. Anything unrecognised is
# echoed back unchanged, which is what lets callers pass a literal version such as 8.2. Empty
# input echoes empty, which callers use to mean "do not set PHP up at all".
#
# Keeping the table in a script rather than inline in action.yml lets anything else that needs
# these versions — including workflows in other repositories, which can check this repository
# out — resolve the same table instead of copying it. A copy drifts exactly when a floor moves,
# which is the moment the value matters.

case "$1" in
matomo5_min_php)
RESOLVED_VERSION="7.2"
;;
matomo5_max_php)
RESOLVED_VERSION="8.5"
;;
matomo6_min_php)
RESOLVED_VERSION="8.1"
;;
matomo6_max_php)
RESOLVED_VERSION="8.5"
;;
*)
RESOLVED_VERSION="$1"
;;
esac

printf '%s' "$RESOLVED_VERSION"