Skip to content

Commit 38e0cee

Browse files
author
Greg Bowler
authored
Faster implementation with php-build (#24)
* Update to use php-build * Fix whitespace * Fix whitespace * Set Github token * Bump php-build * Bump php-build * Correct bash script filename * Add missing file extension * Remove composer env variable * Drop quotes around arguments * Use arrays instead of string concatenation * Use asterisk * Try without double quotes * Fix quotes * Upgrade php-build * Silence
1 parent 74e4ecf commit 38e0cee

File tree

5 files changed

+125
-153
lines changed

5 files changed

+125
-153
lines changed

Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

action.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ name: PHPUnit (php-actions)
22
description: Run your PHPUnit tests in your Github Actions.
33

44
inputs:
5+
version:
6+
description: What version of PHPUnit to use
7+
default: latest
8+
required: false
9+
510
php_version:
611
description: What version of PHP to use
712
default: latest
813
required: false
914

10-
phpunit_version:
11-
description: What version of PHPUnit to use
12-
default: latest
15+
php_extensions:
16+
description: Space separated list of extensions to configure with the PHP build
1317
required: false
1418

1519
configuration:
@@ -74,25 +78,31 @@ inputs:
7478
required: false
7579

7680
runs:
77-
using: 'docker'
78-
image: 'Dockerfile'
79-
env:
80-
action_php_version: ${{ inputs.php_version }}
81-
action_phpunit_version: ${{ inputs.phpunit_version }}
82-
action_configuration: ${{ inputs.configuration }}
83-
action_log_junit: ${{ inputs.log_junit }}
84-
action_testdox_html: ${{ inputs.testdox_html }}
85-
action_testdox_text: ${{ inputs.testdox_text }}
86-
action_testdox_xml: ${{ inputs.testdox_xml }}
87-
action_bootstrap: ${{ inputs.bootstrap }}
88-
action_filter: ${{ inputs.filter }}
89-
action_testsuite: ${{ inputs.testsuite }}
90-
action_group: ${{ inputs.group }}
91-
action_exclude_group: ${{ inputs.exclude_group }}
92-
action_test_suffix: ${{ inputs.test_suffix }}
93-
action_whitelist: ${{ inputs.whitelist }}
94-
action_memory_limit: ${{ inputs.memory_limit }}
95-
action_args: ${{ inputs.args }}
81+
using: "composite"
82+
steps:
83+
- env:
84+
ACTION_TOKEN: ${{ github.token }}
85+
ACTION_VERSION: ${{ inputs.version }}
86+
ACTION_PHP_VERSION: ${{ inputs.php_version }}
87+
ACTION_PHP_EXTENSIONS: ${{ inputs.php_extensions }}
88+
ACTION_CONFIGURATION: ${{ inputs.configuration }}
89+
ACTION_LOG_JUNIT: ${{ inputs.log_junit }}
90+
ACTION_TESTDOX_HTML: ${{ inputs.testdox_html }}
91+
ACTION_TESTDOX_TEXT: ${{ inputs.testdox_text }}
92+
ACTION_TESTDOX_XML: ${{ inputs.testdox_xml }}
93+
ACTION_BOOTSTRAP: ${{ inputs.bootstrap }}
94+
ACTION_FILTER: ${{ inputs.filter }}
95+
ACTION_TESTSUITE: ${{ inputs.testsuite }}
96+
ACTION_GROUP: ${{ inputs.group }}
97+
ACTION_EXCLUDE_GROUP: ${{ inputs.exclude_group }}
98+
ACTION_TEST_SUFFIX: ${{ inputs.test_suffix }}
99+
ACTION_WHITELIST: ${{ inputs.whitelist }}
100+
ACTION_MEMORY_LIMIT: ${{ inputs.memory_limit }}
101+
ACTION_ARGS: ${{ inputs.args }}
102+
id: phpunit_run
103+
run: bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cc563958b37b62874df04de865e5e9c6d8bb93dd/php-build.bash) phpunit \
104+
&& ${{ github.action_path }}/phpunit-action.bash
105+
shell: bash
96106

97107
branding:
98108
icon: 'check-square'

entrypoint

Lines changed: 0 additions & 90 deletions
This file was deleted.

phpunit-action.bash

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
set -e
3+
github_action_path=$(dirname "$0")
4+
docker_tag=$(cat ./docker_tag)
5+
echo "Docker tag: $docker_tag" >> output.log 2>&1
6+
7+
phar_url="https://phar.phpunit.de/phpunit"
8+
if [ "$ACTION_VERSION" != "latest" ]
9+
then
10+
phar_url="${phar_url}-${ACTION_VERSION}"
11+
fi
12+
phar_url="${phar_url}.phar"
13+
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/phpunit.phar"
14+
chmod +x "${github_action_path}/phpunit.phar"
15+
16+
command_string=("phpunit")
17+
18+
if [ -n "$ACTION_CONFIGURATION" ]
19+
then
20+
command_string+=(--configuration "$ACTION_CONFIGURATION")
21+
fi
22+
23+
if [ -n "$ACTION_LOG_JUNIT" ]
24+
then
25+
command_string+=(--log-junit "$ACTION_LOG_JUNIT")
26+
fi
27+
28+
if [ -n "$ACTION_TESTDOX_HTML" ]
29+
then
30+
command_string+=(--testdox-html "$ACTION_TESTDOX_HTML")
31+
fi
32+
33+
if [ -n "$ACTION_TESTDOX_TEXT" ]
34+
then
35+
command_string+=(--testdox-text "$ACTION_TESTDOX_TEXT")
36+
fi
37+
38+
if [ -n "$ACTION_TESTDOX_XML" ]
39+
then
40+
command_string+=(--testdox-xml "$ACTION_TESTDOX_XML")
41+
fi
42+
43+
if [ -n "$ACTION_BOOTSTRAP" ]
44+
then
45+
command_string+=(--bootstrap "$ACTION_BOOTSTRAP")
46+
fi
47+
48+
if [ -n "$ACTION_FILTER" ]
49+
then
50+
command_string+=(--filter "$ACTION_FILTER")
51+
fi
52+
53+
if [ -n "$ACTION_TESTSUITE" ]
54+
then
55+
command_string+=(--testsuite "$ACTION_TESTSUITE")
56+
fi
57+
58+
if [ -n "$ACTION_GROUP" ]
59+
then
60+
command_string+=(--group "$ACTION_GROUP")
61+
fi
62+
63+
if [ -n "$ACTION_EXCLUDE_GROUP" ]
64+
then
65+
command_string+=(--exclude-group "$ACTION_EXCLUDE_GROUP")
66+
fi
67+
68+
if [ -n "$ACTION_TEST_SUFFIX" ]
69+
then
70+
command_string+=(--test-suffix "$ACTION_TEST_SUFFIX")
71+
fi
72+
73+
if [ -n "$ACTION_WHITELIST" ]
74+
then
75+
command_string+=(--whitelist "$ACTION_WHITELIST")
76+
fi
77+
78+
if [ -n "$ACTION_MEMORY_LIMIT" ]
79+
then
80+
command_string+=(-d memory_limit="$ACTION_MEMORY_LIMIT")
81+
fi
82+
83+
if [ -n "$ACTION_ARGS" ]
84+
then
85+
command_string+=("$ACTION_ARGS")
86+
fi
87+
88+
echo "Command: " "${command_string[@]}" >> output.log 2>&1
89+
docker run --rm \
90+
--volume "${github_action_path}/phpunit.phar":/usr/local/bin/phpunit \
91+
--volume "${GITHUB_WORKSPACE}":/app \
92+
--workdir /app \
93+
${docker_tag} "${command_string[@]}"

switch-phpunit-version

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)