TEST: Workflow test #61
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
name: 'macOS' | |
on: | |
push: | |
branches: [ 'test' ] | |
pull_request: | |
branches: [ 'test' ] | |
jobs: | |
tests: | |
continue-on-error: false | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ 'macos-13' ] | |
php-version: [ '8.2', '8.3' ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: 'PHP version check' | |
uses: 'actions/checkout@v3' | |
- run: | | |
notify_message() { | |
echo -e "\\033[33m$*\\033[0m" | |
} | |
success_message() { | |
echo -e "\\033[32m$*\\033[0m" | |
} | |
error_message() { | |
echo -e "\\033[31m$*\\033[0m" | |
} | |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 | |
notify_message "Checking PHP" | |
php -v | |
initial_php_version=$(php -v | grep -e '^PHP' | cut -d ' ' -f2 | cut -d '.' -f1,2) | |
notify_message "Checking Brew" | |
brew --version | |
notify_message "Adding shivammathur/php tap" | |
brew tap shivammathur/php | |
notify_message "Initial PHP version is ${initial_php_version} (Matrix PHP version is: ${{ matrix.php-version }})" | |
if [[ "${{ matrix.php-version }}" == "${initial_php_version}" ]]; then | |
notify_message "Initial PHP version is the same as Matrix PHP version." | |
notify_message "Installing PHP 5.6" | |
brew install shivammathur/php/[email protected] | |
./brew-php-switcher.sh 5.6 | |
echo "Currently PHP version is $(php -v | grep -e '^PHP' | cut -d ' ' -f2 | cut -d '.' -f1,2)" | |
else | |
notify_message "Initial PHP version and Matrix PHP version are different" | |
fi | |
brew services list | |
notify_message "Installing shivammathur/php/php@${{ matrix.php-version }}" | |
brew install shivammathur/php/php@${{ matrix.php-version }} | |
./brew-php-switcher.sh ${{ matrix.php-version }} | |
version=$(php -v | grep -e '^PHP' | cut -d ' ' -f2 | cut -d '.' -f1,2) | |
if [[ "${{ matrix.php-version }}" != "${version}" ]]; then | |
error_message "Expected ${{ matrix.php-version }} got ${version}" | |
exit 1 | |
else | |
success_message "PHP CLI version was properly switched to ${{ matrix.php-version }}" | |
fi | |
exit 0 | |
service="php@${version}" | |
if [[ "${version}" == "8.3" ]]; then | |
service="php" | |
fi | |
brew services start "${service}" | |
status=$(brew services list | grep "${service}" | grep "started") | |
if [[ -z "${status}" ]]; then | |
echo "PHP-FPM service with version ${version} is not started" | |
exit 1 | |
else | |
echo "PHP-FPM service with version ${version} was started properly" | |
fi |