Skip to content

Commit

Permalink
Merge pull request #95 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.5.6
  • Loading branch information
shivammathur authored Nov 30, 2019
2 parents 5a08135 + 7f32ab3 commit 3039a72
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 73 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down Expand Up @@ -61,13 +61,22 @@ jobs:
ini-values-csv: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional

- name: Testing PHP version
run: php -v
run: |
php -v
php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}"
- name: Testing Composer version
run: composer -V
run: |
composer -V
php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}"
- name: Testing Extensions
run: php -m
run: |
php -m
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
- name: Testing ini values
run: |
printf "post_max_size: %s\n" $(php -r "echo ini_get('post_max_size');")
printf "short_open_tag: %s\n" $(php -r "echo ini_get('short_open_tag');")
printf "date.timezone: %s\n" $(php -r "echo ini_get('date.timezone');")
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
```yaml
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
php-version: '7.4'
coverage: xdebug
```
Expand All @@ -87,7 +87,7 @@ If your source code directory is other than `src`, `lib` or, `app`, specify `pco
```yaml
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
php-version: '7.4'
ini-values-csv: pcov.directory=api #optional, see above for usage.
coverage: pcov
```
Expand All @@ -104,7 +104,7 @@ Consider disabling the coverage using this PHP action for these reasons.
```yaml
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
php-version: '7.4'
coverage: none
```

Expand All @@ -130,7 +130,7 @@ steps:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
php-version: '7.4'
extension-csv: mbstring, intl #optional, setup extensions
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver
Expand All @@ -155,7 +155,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand Down Expand Up @@ -250,7 +250,6 @@ If this action helped you.
- [Homebrew](https://brew.sh/ "MacOS package manager")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages")
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated "Pre-compiled deprecated PHP for macOS")
- [phpbrew](https://github.com/phpbrew/phpbrew "PHP packages manager")

## :bookmark_tabs: Further Reading

Expand Down
9 changes: 1 addition & 8 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ describe('Utils tests', () => {
});

it('checking readScripts', async () => {
const rc: string = fs.readFileSync(
path.join(__dirname, '../src/scripts/7.4.sh'),
'utf8'
);
const darwin: string = fs.readFileSync(
path.join(__dirname, '../src/scripts/darwin.sh'),
'utf8'
Expand All @@ -76,15 +72,12 @@ describe('Utils tests', () => {
path.join(__dirname, '../src/scripts/win32.ps1'),
'utf8'
);
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
'Platform fedora is not supported'
);
});

it('checking writeScripts', async () => {
Expand Down
14 changes: 1 addition & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,19 +810,7 @@ exports.addLog = addLog;
*/
function readScript(filename, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'darwin':
switch (version) {
case '7.4':
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
}
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
case 'linux':
case 'win32':
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
});
}
exports.readScript = readScript;
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "1.5.5",
"version": "1.5.6",
"private": false,
"description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ add_log() {
fi
}

step_log "Setup PHP and Composer"
version=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
fi
step_log "Setup PHP and Composer"
if [ "$1" = "7.4" ]; then
brew update >/dev/null 2>&1
fi
brew install php@"$1" composer >/dev/null 2>&1
brew link --force --overwrite php@"$1" >/dev/null 2>&1
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
Expand All @@ -31,7 +34,7 @@ ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file"
mkdir -p "$(pecl config-get ext_dir)"
composer global require hirak/prestissimo >/dev/null 2>&1
add_log "$tick" "PHP" "Installed PHP$version"
add_log "$tick" "PHP" "Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
add_log "$tick" "Composer" "Installed"

add_extension() {
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_log() {
}
existing_version=$(php-config --version | cut -c 1-3)
version=$1
status="Switched to PHP$version"
step_log "Setup PHP and Composer"
sudo mkdir -p /var/run
sudo mkdir -p /run/php
Expand All @@ -30,14 +29,23 @@ if [ "$existing_version" != "$1" ]; then
else
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
fi
status="Installed PHP$version"
status="installed"
else
status="switched"
fi

for tool in php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$1" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
fi
done
if [ "$status" != "switched" ]; then
status="Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
else
status="Switched to PHP $(php -v | head -n 1 | cut -c 5-10)"
fi
else
status="PHP $(php -v | head -n 1 | cut -c 5-10) Found"
fi

ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
$status = "Installed PHP $($installed.FullVersion)"
}
else {
$status = "Switched to PHP $($installed.FullVersion)"
$status = "PHP $($installed.FullVersion) Found"
}

Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Expand Down
30 changes: 4 additions & 26 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,32 +173,10 @@ export async function readScript(
version: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'darwin':
switch (version) {
case '7.4':
return fs.readFileSync(
path.join(__dirname, '../src/scripts/7.4.sh'),
'utf8'
);
}
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
case 'linux':
case 'win32':
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
}

/**
Expand Down

0 comments on commit 3039a72

Please sign in to comment.