Skip to content

Revert phpbuild (docker user) #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2024
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Inputs

The following configuration options are available:

+ `version` The version of PHPUnit to use e.g. `9` or `9.5.0` (default: latest)
+ `version` The version of PHPUnit to use e.g. `latest`, `9` or `9.5.0` (default: `composer` - use the version specified in composer.json)
+ `php_version` The version of PHP to use e.g. `7.4` (default: latest)
+ `php_extensions` Space-separated list of extensions using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A)
+ `vendored_phpunit_path` The path to a phar file already present on the runner (default: N/A)
Expand Down Expand Up @@ -95,7 +95,7 @@ PHP and PHPUnit versions

It's possible to run any version of PHPUnit under any version of PHP, with any PHP extensions you require. This is configured with the following inputs:

+ `version` - the version number of PHPUnit to run e.g. `9` or `9.5.0` (default: latest)
+ `version` - the version number of PHPUnit to run e.g. `latest`, `9` or `9.5.0` (default: `composer`). Using the default value, `composer` will install the version specified in `composer.json`
+ `php_version` - the version number of PHP to use e.g. `7.4` (default: latest)
+ `php_extensions` - a space-separated list of extensions to install using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A)

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Run your PHPUnit tests in your Github Actions.
inputs:
version:
description: What version of PHPUnit to use
default: latest
default: composer
required: false

php_version:
Expand Down
24 changes: 24 additions & 0 deletions phpunit-action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ docker_tag=$(cat ./docker_tag)

echo "Docker tag: $docker_tag" >> output.log 2>&1

function get_version_from_composer() {
version_string="*"

if [ -f composer.lock ]
then
version_string=$(jq -r 'first(.["packages-dev"][]?, .packages[]? | select(.name == "phpunit/phpunit") | .version)' composer.lock)
else
version_string=$(jq '.["require-dev"]["phpunit/phpunit"] // .["require"]["phpunit/phpunit"]' composer.json)
version_string=$(echo "$version_string" | sed -E 's/^[^0-9]*//')
fi

echo $version_string
}

if [ -z "$ACTION_PHPUNIT_PATH" ]
then
phar_url="https://phar.phpunit.de/phpunit"
if [ "$ACTION_VERSION" == "composer" ]
then
ACTION_VERSION=$(get_version_from_composer)
fi

if [ "$ACTION_VERSION" != "latest" ]
then
phar_url="${phar_url}-${ACTION_VERSION}"
Expand Down Expand Up @@ -135,6 +154,11 @@ fi

echo "Command: ${command_string[@]}" >> output.log 2>&1

me=$(whoami)
echo "Current user: $me"

ls -la

docker run --rm \
--volume "${phar_path}":/usr/local/bin/phpunit \
--volume "${GITHUB_WORKSPACE}":/app \
Expand Down