-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make working dir part of cache key and improve error handling
- Loading branch information
Showing
38 changed files
with
281 additions
and
740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
composer_path="${1:-$(which composer)}" | ||
working_directory="${2:-.}" | ||
php_path="${3:-$(which php)}" | ||
|
||
function test_composer { | ||
"${php_path}" "${composer_path}" --version > /dev/null 2>&1 | ||
} | ||
|
||
function validate_composer { | ||
"${php_path}" "${composer_path}" \ | ||
validate \ | ||
--no-check-publish \ | ||
--no-check-version \ | ||
--working-dir "${working_directory}" \ | ||
> /dev/null 2>&1 | ||
} | ||
|
||
if ! test_composer; then | ||
echo "::error title=Composer Not Found::Unable to find Composer at '${composer_path}'" | ||
exit 1 | ||
fi | ||
|
||
composer_json="composer.json" | ||
composer_lock="composer.lock" | ||
|
||
if [ -n "${working_directory}" ]; then | ||
if [ ! -d "${working_directory}" ]; then | ||
echo "::error title=Working Directory Not Found::Unable to find working directory at '${working_directory}'" | ||
exit 1 | ||
fi | ||
|
||
composer_json="${working_directory}/composer.json" | ||
composer_lock="${working_directory}/composer.lock" | ||
fi | ||
|
||
if [ ! -f "${composer_json}" ]; then | ||
echo "::error title=composer.json Not Found::Unable to find composer.json at '${composer_json}'" | ||
exit 1 | ||
fi | ||
|
||
if ! validate_composer; then | ||
echo "::error title=Invalid composer.json::The composer.json file at '${composer_json}' does not validate; run 'composer validate' to check for errors" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "${composer_lock}" ]; then | ||
echo "::notice title=composer.lock Not Found::Unable to find composer.lock at '${composer_lock}'" | ||
composer_lock="" | ||
fi | ||
|
||
cache_dir="$($composer_path config cache-dir)" | ||
|
||
echo "::notice title=Composer Path::Composer path is '${composer_path}'" | ||
echo "::notice title=Composer Cache::Composer cache directory found at '${cache_dir}'" | ||
echo "::notice title=composer.json::File composer.json found at '${composer_json}'" | ||
echo "::notice title=composer.lock::File composer.lock path computed as '${composer_lock}'" | ||
echo "::set-output name=command::${composer_path}" | ||
echo "::set-output name=cache-dir::${cache_dir}" | ||
echo "::set-output name=json::${composer_json}" | ||
echo "::set-output name=lock::${composer_lock}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
php_version=$(php -r 'echo phpversion();') | ||
php_path="${1:-$(which php)}" | ||
|
||
# Test PHP command. | ||
function test_php { | ||
$php_path -v > /dev/null 2>&1 | ||
} | ||
|
||
if ! test_php; then | ||
echo "::error title=PHP Not Found::Unable to find PHP at '${php_path}'" | ||
exit 1 | ||
fi | ||
|
||
php_version=$($php_path -r 'echo phpversion();') | ||
|
||
echo "::notice title=PHP Path::PHP path is '${php_path}'" | ||
echo "::notice title=PHP Version::PHP version is '${php_version}'" | ||
echo "::set-output name=php::${php_version}" | ||
echo "::set-output name=path::${php_path}" | ||
echo "::set-output name=version::${php_version}" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.