Merge pull request #105 from shivammathur/develop

1.6.0
This commit is contained in:
Shivam Mathur 2019-12-09 14:00:34 +05:30 committed by GitHub
commit 2cabcf2941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 225 additions and 155 deletions

View File

@ -0,0 +1,91 @@
name: Experimental workflow
on:
pull_request:
branches:
- nightly
- master
- develop
- verbose
paths-ignore:
- '**.md'
- 'examples/**'
push:
branches:
- nightly
- master
- develop
- verbose
paths-ignore:
- '**.md'
- 'examples/**'
jobs:
run:
name: Run
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest]
php-versions: ['8.0']
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Setup Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm install
- name: Prettier Format Check
run: npm run format-check
- name: ESLint Check
run: npm run lint
- name: Run tests
run: npm test
- name: Send Coverage
continue-on-error: true
timeout-minutes: 1
run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}-php${{ matrix.php-versions }}
- name: Setup PHP with extensions and custom config
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xdebug, pcov #optional
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
- name: Testing PHP version
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
php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}"
- name: Testing Extensions
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(! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
- name: Testing ini values
run: |
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');}"
- name: Test and Benchmark JIT
run: |
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
php -r "if(ini_get('opcache.jit_buffer_size')!='256M') {throw new Exception('opcache.jit_buffer_size not set');}"
php -r "if(ini_get('opcache.jit')!=1235) {throw new Exception('opcache.jit not set');}"
php -r "if(ini_get('pcre.jit')!=1) {throw new Exception('pcre.jit not set');}"
curl https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php | php

View File

@ -57,8 +57,8 @@ jobs:
run: node dist/index.js run: node dist/index.js
env: env:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xdebug, pcov #optional extensions: mbstring, xdebug, pcov #optional
ini-values-csv: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
- name: Testing PHP version - name: Testing PHP version
run: | run: |

View File

@ -13,7 +13,7 @@
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
</p> </p>
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. Setup PHP with required extensions, php.ini configuration, code-coverage support and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
## Contents ## Contents
@ -45,6 +45,9 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|7.2|`Stable`|`Security fixes only`| |7.2|`Stable`|`Security fixes only`|
|7.3|`Stable`|`Active`| |7.3|`Stable`|`Active`|
|7.4|`Stable`|`Active`| |7.4|`Stable`|`Active`|
|8.0|`Experimental`|`In development`|
**Note:** Specifying `8.0` in `php-version` input installs `PHP 8.0.0-dev`. This is an experimental feature on this action available on `ubuntu` and `macOS`. Currently some extensions might not be available for this version.
## :cloud: OS/Platform Support ## :cloud: OS/Platform Support
@ -81,14 +84,14 @@ with:
Specify `coverage: pcov` to use `PCOV`. Specify `coverage: pcov` to use `PCOV`.
It is much faster than `Xdebug`. It is much faster than `Xdebug`.
`PCOV` needs `PHP >= 7.1`. `PCOV` needs `PHP >= 7.1`.
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values-csv` input. If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
```yaml ```yaml
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.4' php-version: '7.4'
ini-values-csv: pcov.directory=api #optional, see above for usage. ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov coverage: pcov
``` ```
@ -113,8 +116,8 @@ with:
Inputs supported by this GitHub Action. Inputs supported by this GitHub Action.
- php-version `required` - php-version `required`
- extension-csv `optional` - extension `optional`
- ini-values-csv `optional` - ini-values `optional`
- coverage `optional` - coverage `optional`
- pecl `optional` - pecl `optional`
@ -122,6 +125,8 @@ See [action.yml](action.yml "Metadata for this GitHub Action") and usage below f
### Basic Usage ### Basic Usage
> Setup a particular PHP version
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
@ -131,23 +136,16 @@ steps:
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.4' php-version: '7.4'
extension-csv: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL pecl: false #optional, setup PECL
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m
``` ```
### Matrix Testing ### Matrix Testing
> Setup multiple PHP versions
```yaml ```yaml
jobs: jobs:
run: run:
@ -165,19 +163,10 @@ jobs:
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL pecl: false #optional, setup PECL
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m
``` ```
### Cache dependencies ### Cache dependencies
@ -246,10 +235,10 @@ If this action helped you.
## :bookmark: This action uses the following works ## :bookmark: This action uses the following works
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [Homebrew](https://brew.sh/ "MacOS package manager")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages") - [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") - [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Pre-compiled nightly PHP builds")
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds for MacOS")
## :bookmark_tabs: Further Reading ## :bookmark_tabs: Further Reading

View File

@ -10,8 +10,8 @@ jest.mock('../src/install', () => ({
version: string, version: string,
os_version: string os_version: string
): Promise<string> => { ): Promise<string> => {
const extension_csv: string = process.env['extension-csv'] || ''; const extension_csv: string = process.env['extensions'] || '';
const ini_values_csv: string = process.env['ini-values-csv'] || ''; const ini_values_csv: string = process.env['ini-values'] || '';
const coverage_driver: string = process.env['coverage'] || ''; const coverage_driver: string = process.env['coverage'] || '';
let script = 'initial script ' + filename + version + os_version; let script = 'initial script ' + filename + version + os_version;
@ -77,8 +77,8 @@ function setEnv(
): void { ): void {
process.env['php-version'] = version; process.env['php-version'] = version;
process.env['RUNNER_OS'] = os; process.env['RUNNER_OS'] = os;
process.env['extension-csv'] = extension_csv; process.env['extensions'] = extension_csv;
process.env['ini-values-csv'] = ini_values_csv; process.env['ini-values'] = ini_values_csv;
process.env['coverage'] = coverage_driver; process.env['coverage'] = coverage_driver;
process.env['pecl'] = pecl; process.env['pecl'] = pecl;
} }

View File

@ -26,23 +26,6 @@ describe('Utils tests', () => {
expect(await utils.getInput('DoesNotExist', false)).toBe(''); expect(await utils.getInput('DoesNotExist', false)).toBe('');
}); });
it('checking getVersion', async () => {
process.env['php-version'] = '7.3';
expect(await utils.getVersion()).toBe('7.3');
process.env['php-version'] = '7.4';
expect(await utils.getVersion()).toBe('7.4');
process.env['php-version'] = '8.0';
expect(await utils.getVersion()).toBe('7.4');
process.env['php-version'] = '8.0-dev';
expect(await utils.getVersion()).toBe('7.4');
process.env['php-version'] = '7.4nightly';
expect(await utils.getVersion()).toBe('7.4');
process.env['php-version'] = '7.4snapshot';
expect(await utils.getVersion()).toBe('7.4');
process.env['php-version'] = 'nightly';
expect(await utils.getVersion()).toBe('7.4');
});
it('checking asyncForEach', async () => { it('checking asyncForEach', async () => {
const array: Array<string> = ['a', 'b', 'c']; const array: Array<string> = ['a', 'b', 'c'];
let concat = ''; let concat = '';

View File

@ -8,10 +8,10 @@ inputs:
description: 'Setup PHP version.' description: 'Setup PHP version.'
default: '7.4' default: '7.4'
required: true required: true
extension-csv: extensions:
description: 'Setup PHP extensions.' description: 'Setup PHP extensions.'
required: false required: false
ini-values-csv: ini-values:
description: 'Add values to php.ini.' description: 'Add values to php.ini.'
required: false required: false
coverage: coverage:
@ -20,6 +20,15 @@ inputs:
pecl: pecl:
description: 'Setup PECL on ubuntu' description: 'Setup PECL on ubuntu'
required: false required: false
# Deprecated options, do not use. Will not be supported after February 1, 2019.
extension-csv:
description: 'Deprecated! Use extensions instead.'
deprecationMessage: 'The extension-csv property will not be supported after February 1, 2020. Use extensions instead.'
required: false
ini-values-csv:
description: 'Deprecated! Use ini-values instead.'
deprecationMessage: 'The ini-values-csv property will not be supported after February 1, 2020. Use ini-values instead.'
required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'

30
dist/index.js vendored
View File

@ -682,26 +682,6 @@ function getInput(name, mandatory) {
}); });
} }
exports.getInput = getInput; exports.getInput = getInput;
/**
* Function to read the PHP version.
*/
function getVersion() {
return __awaiter(this, void 0, void 0, function* () {
const version = yield getInput('php-version', true);
switch (version) {
case '8.0':
case '8.0-dev':
case '7.4':
case '7.4snapshot':
case '7.4nightly':
case 'nightly':
return '7.4';
default:
return version;
}
});
}
exports.getVersion = getVersion;
/** /**
* Async foreach loop * Async foreach loop
* *
@ -1501,8 +1481,10 @@ const utils = __importStar(__webpack_require__(163));
function build(filename, version, os_version) { function build(filename, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// taking inputs // taking inputs
const extension_csv = yield utils.getInput('extension-csv', false); const extension_csv = (yield utils.getInput('extensions', false)) ||
const ini_values_csv = yield utils.getInput('ini-values-csv', false); (yield utils.getInput('extension-csv', false));
const ini_values_csv = (yield utils.getInput('ini-values', false)) ||
(yield utils.getInput('ini-values-csv', false));
const coverage_driver = yield utils.getInput('coverage', false); const coverage_driver = yield utils.getInput('coverage', false);
let script = yield utils.readScript(filename, version, os_version); let script = yield utils.readScript(filename, version, os_version);
if (extension_csv) { if (extension_csv) {
@ -1525,7 +1507,7 @@ function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const os_version = process.platform; const os_version = process.platform;
const version = yield utils.getVersion(); const version = yield utils.getInput('php-version', true);
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
@ -1541,7 +1523,7 @@ function run() {
} }
case 'win32': case 'win32':
script_path = yield build('win32.ps1', version, os_version); script_path = yield build('win32.ps1', version, os_version);
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname); yield exec_1.exec('pwsh ' + script_path + ' -version ' + version);
break; break;
} }
} }

View File

@ -6,7 +6,7 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@ -15,7 +15,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, intl, curl, dom extensions: mbstring, intl, curl, dom
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -39,7 +39,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -41,7 +41,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -17,7 +17,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo extensions: mbstring, dom, fileinfo
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -31,7 +31,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -39,7 +39,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -33,7 +33,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -41,7 +41,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -17,7 +17,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -37,7 +37,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x. extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -38,7 +38,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -21,7 +21,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring extensions: mbstring
- name: Check node versions - name: Check node versions
run: node -v run: node -v
- name: Get yarn cache - name: Get yarn cache

View File

@ -6,7 +6,7 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@ -15,7 +15,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, simplexml, dom extensions: mbstring, simplexml, dom
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -18,7 +18,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.3'] php-versions: ['7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -26,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xml, ctype, iconv, mysql extensions: mbstring, xml, ctype, iconv, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -18,7 +18,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.3'] php-versions: ['7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -26,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xml, ctype, iconv, pgsql extensions: mbstring, xml, ctype, iconv, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.3'] php-versions: ['7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -17,7 +17,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xml, ctype, iconv extensions: mbstring, xml, ctype, iconv
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -36,7 +36,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, intl, gd, imagick, zip, dom, mysql extensions: mbstring, intl, gd, imagick, zip, dom, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -36,7 +36,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, intl, gd, imagick, zip, dom, pgsql extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

View File

@ -6,7 +6,7 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@ -15,7 +15,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, bcmath, curl, intl extensions: mbstring, bcmath, curl, intl
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache

30
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.5.8", "version": "1.6.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -2249,12 +2249,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2269,17 +2271,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2396,7 +2401,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2408,6 +2414,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2422,6 +2429,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2429,12 +2437,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2453,6 +2463,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2533,7 +2544,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2545,6 +2557,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2666,6 +2679,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.5.8", "version": "1.6.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -18,8 +18,12 @@ export async function build(
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
// taking inputs // taking inputs
const extension_csv: string = await utils.getInput('extension-csv', false); const extension_csv: string =
const ini_values_csv: string = await utils.getInput('ini-values-csv', false); (await utils.getInput('extensions', false)) ||
(await utils.getInput('extension-csv', false));
const ini_values_csv: string =
(await utils.getInput('ini-values', false)) ||
(await utils.getInput('ini-values-csv', false));
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
let script: string = await utils.readScript(filename, version, os_version); let script: string = await utils.readScript(filename, version, os_version);
@ -42,7 +46,7 @@ export async function build(
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const os_version: string = process.platform; const os_version: string = process.platform;
const version: string = await utils.getVersion(); const version: string = await utils.getInput('php-version', true);
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
@ -58,9 +62,7 @@ export async function run(): Promise<void> {
} }
case 'win32': case 'win32':
script_path = await build('win32.ps1', version, os_version); script_path = await build('win32.ps1', version, os_version);
await exec( await exec('pwsh ' + script_path + ' -version ' + version);
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
break; break;
} }
} catch (error) { } catch (error) {

View File

@ -29,7 +29,8 @@ ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file" sudo chmod 777 "$ini_file"
mkdir -p "$(pecl config-get ext_dir)" mkdir -p "$(pecl config-get ext_dir)"
composer global require hirak/prestissimo >/dev/null 2>&1 composer global require hirak/prestissimo >/dev/null 2>&1
add_log "$tick" "PHP" "Installed PHP $(php -v | head -n 1 | cut -c 5-10)" semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
add_log "$tick" "PHP" "Installed PHP $semver"
add_log "$tick" "Composer" "Installed" add_log "$tick" "Composer" "Installed"
add_extension() { add_extension() {
@ -46,10 +47,10 @@ add_extension() {
( (
eval "$install_command" && \ eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled" add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version" ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
else else
if ! php -m | grep -i -q "$extension"; then if ! php -m | grep -i -q "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL" add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
fi fi
fi fi
fi fi

View File

@ -17,35 +17,49 @@ add_log() {
fi fi
} }
existing_version=$(php-config --version | cut -c 1-3) existing_version=$(php-config --version | cut -c 1-3)
version=$1 semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
step_log "Setup PHP and Composer" step_log "Setup PHP and Composer"
sudo mkdir -p /var/run sudo mkdir -p /var/run
sudo mkdir -p /run/php sudo mkdir -p /run/php
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1 find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
if [ "$existing_version" != "$1" ]; then if [ "$existing_version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then if [ ! -e "/usr/bin/php$1" ]; then
if [ "$1" != "7.4" ]; then if [ "$1" = "7.4" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
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 sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
elif [ "$1" = "8.0" ]; then
tar_file=php_"$1"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$1"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libicu-dev >/dev/null 2>&1
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
sudo mkdir -m 777 -p ~/php
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 && rm -rf "$tar_file"
sudo ln -sf -S "$1" "$install_dir"/bin/* /usr/bin/ && sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
else
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
fi fi
status="installed" status="installed"
else else
status="switched" status="switched"
fi fi
for tool in php phar phar.phar php-cgi php-config phpize phpdbg; do for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$1" ]; then if [ -e "/usr/bin/$tool$1" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
fi fi
done done
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
if [ "$1" = "8.0" ]; then
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
fi
if [ "$status" != "switched" ]; then if [ "$status" != "switched" ]; then
status="Installed PHP $(php -v | head -n 1 | cut -c 5-10)" status="Installed PHP $semver"
else else
status="Switched to PHP $(php -v | head -n 1 | cut -c 5-10)" status="Switched to PHP $semver"
fi fi
else else
status="PHP $(php -v | head -n 1 | cut -c 5-10) Found" status="PHP $semver Found"
fi fi
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
@ -88,6 +102,6 @@ add_extension()
( (
eval "$install_command" && \ eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled" add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on php$version" ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi fi
} }

View File

@ -1,6 +1,5 @@
param ( param (
[Parameter(Mandatory = $true)][string]$version = "7.3", [Parameter(Mandatory = $true)][string]$version = "7.3"
[Parameter(Mandatory = $true)][string]$dir
) )
$tick = ([char]8730) $tick = ([char]8730)
@ -16,6 +15,10 @@ Function Add-Log($mark, $subject, $message) {
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
} }
if ($version -eq '8.0') {
$version = '7.4'
}
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser Install-Module -Name PhpManager -Force -Scope CurrentUser
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"
@ -85,6 +88,6 @@ Function Add-Extension {
} }
} }
catch { catch {
Add-Log $cross $extension "Could not enable" Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
} }
} }

View File

@ -22,24 +22,6 @@ export async function getInput(
} }
} }
/**
* Function to read the PHP version.
*/
export async function getVersion(): Promise<string> {
const version: string = await getInput('php-version', true);
switch (version) {
case '8.0':
case '8.0-dev':
case '7.4':
case '7.4snapshot':
case '7.4nightly':
case 'nightly':
return '7.4';
default:
return version;
}
}
/** /**
* Async foreach loop * Async foreach loop
* *