diff --git a/.github/workflows/experimental-workflow.yml b/.github/workflows/experimental-workflow.yml index 500e5b0e..a2993568 100644 --- a/.github/workflows/experimental-workflow.yml +++ b/.github/workflows/experimental-workflow.yml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest] + operating-system: [ubuntu-latest, windows-latest, macOS-latest] php-versions: ['8.0'] steps: - name: Checkout @@ -59,9 +59,9 @@ jobs: run: node dist/index.js env: php-version: ${{ matrix.php-versions }} - extensions: mbstring, xdebug, pcov #optional + extensions: xml, opcache, xdebug, pcov #optional ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional - coverage: xdebug + coverage: pcov - name: Testing PHP version run: | @@ -76,17 +76,19 @@ jobs: 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 + - name: Test 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 \ No newline at end of file + - name: Benchmark JIT + run: | + curl -o bench.php https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php + php bench.php \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2ee9edbf..e7b62138 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -57,7 +57,7 @@ jobs: run: node dist/index.js env: php-version: ${{ matrix.php-versions }} - extensions: mbstring, xdebug, pcov #optional + extensions: xml, opcache, xdebug, pcov #optional ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional - name: Testing PHP version @@ -72,7 +72,7 @@ jobs: - name: Testing Extensions run: | php -m - php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}" + php -r "if(! extension_loaded('xml')) {throw new Exception('xml 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 diff --git a/README.md b/README.md index ca7ff3b3..400e2b2c 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,11 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support - [PCOV](#pcov) - [Disable coverage](#disable-coverage) - [Usage](#memo-usage) - - [Basic Usage](#basic-usage) - - [Matrix Testing](#matrix-testing) + - [Basic Setup](#basic-setup) + - [Matrix Setup](#matrix-setup) + - [Experimental Setup](#experimental-setup) - [Cache dependencies](#cache-dependencies) + - [Problem Matchers](#problem-matchers) - [Examples](#examples) - [License](#scroll-license) - [Contributions](#1-contributions) @@ -47,7 +49,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support |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. +**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT` support. See [experimental setup](#experimental-setup) for more information. ## :cloud: OS/Platform Support @@ -70,7 +72,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support ### Xdebug Specify `coverage: xdebug` to use `Xdebug`. -Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") +Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`. ```yaml uses: shivammathur/setup-php@v1 @@ -123,9 +125,9 @@ Inputs supported by this GitHub Action. See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info. -### Basic Usage +### Basic Setup -> Setup a particular PHP version +> Setup a particular PHP version. ```yaml steps: @@ -142,9 +144,9 @@ steps: pecl: false #optional, setup PECL ``` -### Matrix Testing +### Matrix Setup -> Setup multiple PHP versions +> Setup multiple PHP versions on multiple operating systems. ```yaml jobs: @@ -169,6 +171,29 @@ jobs: pecl: false #optional, setup PECL ``` +### Experimental Setup + +> Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP. + +- This version is currently in development and is an experimental feature on this action. +- `PECL` is installed by default with this version on `ubuntu`. +- Some extensions might not support this version currently. +- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. + +```yaml +steps: +- name: Checkout + uses: actions/checkout@v1 + +- name: Setup PHP + uses: shivammathur/setup-php@v1 + with: + php-version: '8.0' + extensions: mbstring #optional, setup extensions + ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration + coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet. +``` + ### Cache dependencies You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time. @@ -191,6 +216,15 @@ You can persist composer's internal cache directory using the [`action/cache`](h run: composer install --prefer-dist ``` +### Problem Matchers + +You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. + +```yaml +- name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" +``` + ### Examples Examples for setting up this GitHub Action with different PHP Frameworks/Packages. diff --git a/__tests__/matchers.test.ts b/__tests__/matchers.test.ts new file mode 100644 index 00000000..23e74830 --- /dev/null +++ b/__tests__/matchers.test.ts @@ -0,0 +1,34 @@ +import * as io from '@actions/io'; +import * as path from 'path'; +import * as fs from 'fs'; +import * as matchers from '../src/matchers'; + +async function cleanup(path: string): Promise { + fs.unlink(path, error => { + if (error) { + console.log(error); + } + }); +} + +jest.mock('@actions/io'); + +describe('Matchers', () => { + it('Add matchers', async () => { + process.env['RUNNER_TOOL_CACHE'] = __dirname; + await matchers.addMatchers(); + const spy = jest.spyOn(io, 'cp'); + expect(spy).toHaveBeenCalledTimes(1); + }); + + it('Test Regex', async () => { + const regex1 = /^\d+\)\s.*$/; + const regex2 = /^(.*)$/; + const regex3 = /^\s*$/; + const regex4 = /^(.*):(\d+)$/; + expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true); + expect(regex2.test('Failed asserting that false is true')).toBe(true); + expect(regex3.test('\n')).toBe(true); + expect(regex4.test('/path/to/file.php:42')).toBe(true); + }); +}); diff --git a/action.yml b/action.yml index 6bf077c8..673c7e8b 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,7 @@ inputs: pecl: description: 'Setup PECL on ubuntu' required: false - # Deprecated options, do not use. Will not be supported after February 1, 2019. + # Deprecated options, do not use. Will not be supported after February 1, 2020. extension-csv: description: 'Deprecated! Use extensions instead.' deprecationMessage: 'The extension-csv property will not be supported after February 1, 2020. Use extensions instead.' diff --git a/dist/index.js b/dist/index.js index 2deebbb8..e943c162 100644 --- a/dist/index.js +++ b/dist/index.js @@ -932,6 +932,46 @@ class ExecState extends events.EventEmitter { } //# sourceMappingURL=toolrunner.js.map +/***/ }), + +/***/ 86: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __importStar(__webpack_require__(622)); +const utils = __importStar(__webpack_require__(163)); +const io = __importStar(__webpack_require__(1)); +/** + * Cache json files for problem matchers + */ +function addMatchers() { + return __awaiter(this, void 0, void 0, function* () { + const config_path = path.join(__dirname, '..', 'src', 'configs', 'phpunit.json'); + const runner_dir = yield utils.getInput('RUNNER_TOOL_CACHE', false); + yield io.cp(config_path, runner_dir); + }); +} +exports.addMatchers = addMatchers; + + /***/ }), /***/ 87: @@ -1795,6 +1835,7 @@ const config = __importStar(__webpack_require__(641)); const coverage = __importStar(__webpack_require__(635)); const extensions = __importStar(__webpack_require__(911)); const utils = __importStar(__webpack_require__(163)); +const matchers = __importStar(__webpack_require__(86)); /** * Build the script * @@ -1810,6 +1851,7 @@ function build(filename, version, os_version) { 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 setup_matchers = yield utils.getInput('matchers', false); let script = yield utils.readScript(filename, version, os_version); if (extension_csv) { script += yield extensions.addExtension(extension_csv, version, os_version); @@ -1848,9 +1890,10 @@ function run() { } case 'win32': script_path = yield build('win32.ps1', version, os_version); - yield exec_1.exec('pwsh ' + script_path + ' -version ' + version); + yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname); break; } + yield matchers.addMatchers(); } catch (error) { core.setFailed(error.message); diff --git a/package-lock.json b/package-lock.json index 8a6612c6..83d564e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.6.1", + "version": "1.6.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -32,15 +32,15 @@ } }, "@babel/core": { - "version": "7.7.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.5.tgz", - "integrity": "sha512-M42+ScN4+1S9iB6f+TL7QBpoQETxbclx+KNoKJABghnKYE+fMzSGqst0BZJc8CpI625bwPwYgUyRvxZ+0mZzpw==", + "version": "7.7.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.7.tgz", + "integrity": "sha512-jlSjuj/7z138NLZALxVgrx13AOtqip42ATZP7+kYl53GvDV6+4dCek1mVUo8z8c8Xnw/mx2q3d9HWh3griuesQ==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.4", + "@babel/generator": "^7.7.7", "@babel/helpers": "^7.7.4", - "@babel/parser": "^7.7.5", + "@babel/parser": "^7.7.7", "@babel/template": "^7.7.4", "@babel/traverse": "^7.7.4", "@babel/types": "^7.7.4", @@ -68,9 +68,9 @@ } }, "@babel/generator": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.4.tgz", - "integrity": "sha512-m5qo2WgdOJeyYngKImbkyQrnUN1mPceaG5BV+G0E3gWsa4l/jCSryWJdM2x8OuGAOyh+3d5pVYfZWCiNFtynxg==", + "version": "7.7.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.7.tgz", + "integrity": "sha512-/AOIBpHh/JU1l0ZFS4kiRCBnLi6OTHzh0RPk3h9isBxkkqELtQNFi1Vr/tiG9p1yfoUdKVwISuXWQR+hwwM4VQ==", "dev": true, "requires": { "@babel/types": "^7.7.4", @@ -145,9 +145,9 @@ } }, "@babel/parser": { - "version": "7.7.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.5.tgz", - "integrity": "sha512-KNlOe9+/nk4i29g0VXgl8PEXIRms5xKLJeuZ6UptN0fHv+jDiriG+y94X6qAgWTR0h3KaoM1wK5G5h7MHFRSig==", + "version": "7.7.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.7.tgz", + "integrity": "sha512-WtTZMZAZLbeymhkd/sEaPD8IQyGAhmuTuvTzLiCFM7iXiVdY0gc0IaI+cW0fh1BnSMbJSzXX6/fHllgHKwHhXw==", "dev": true }, "@babel/plugin-syntax-object-rest-spread": { @@ -503,9 +503,9 @@ } }, "@types/jest": { - "version": "24.0.23", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.23.tgz", - "integrity": "sha512-L7MBvwfNpe7yVPTXLn32df/EK+AMBFAFvZrRuArGs7npEWnlziUXK+5GMIUTI4NIuwok3XibsjXCs5HxviYXjg==", + "version": "24.0.24", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.24.tgz", + "integrity": "sha512-vgaG968EDPSJPMunEDdZvZgvxYSmeH8wKqBlHSkBt1pV2XlLEVDzsj1ZhLuI4iG4Pv841tES61txSBF0obh4CQ==", "dev": true, "requires": { "jest-diff": "^24.3.0" @@ -518,9 +518,9 @@ "dev": true }, "@types/node": { - "version": "12.12.17", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", - "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", + "version": "12.12.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.21.tgz", + "integrity": "sha512-8sRGhbpU+ck1n0PGAUgVrWrWdjSW2aqNeyC15W88GRsMpSwzv6RJGlLhE7s2RhVSOdyDmxbqlWSeThq4/7xqlA==", "dev": true }, "@types/normalize-package-data": { @@ -551,12 +551,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.11.0.tgz", - "integrity": "sha512-G2HHA1vpMN0EEbUuWubiCCfd0R3a30BB+UdvnFkxwZIxYEGOrWEXDv8tBFO9f44CWc47Xv9lLM3VSn4ORLI2bA==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.12.0.tgz", + "integrity": "sha512-1t4r9rpLuEwl3hgt90jY18wJHSyb0E3orVL3DaqwmpiSDHmHiSspVsvsFF78BJ/3NNG3qmeso836jpuBWYziAA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.11.0", + "@typescript-eslint/experimental-utils": "2.12.0", "eslint-utils": "^1.4.3", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -564,32 +564,32 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.11.0.tgz", - "integrity": "sha512-YxcA/y0ZJaCc/fB/MClhcDxHI0nOBB7v2/WxBju2cOTanX7jO9ttQq6Fy4yW9UaY5bPd9xL3cun3lDVqk67sPQ==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.12.0.tgz", + "integrity": "sha512-jv4gYpw5N5BrWF3ntROvCuLe1IjRenLy5+U57J24NbPGwZFAjhnM45qpq0nDH1y/AZMb3Br25YiNVwyPbz6RkA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.11.0", + "@typescript-eslint/typescript-estree": "2.12.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.11.0.tgz", - "integrity": "sha512-DyGXeqhb3moMioEFZIHIp7oXBBh7dEfPTzGrlyP0Mi9ScCra4SWEGs3kPd18mG7Sy9Wy8z88zmrw5tSGL6r/6A==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.12.0.tgz", + "integrity": "sha512-lPdkwpdzxEfjI8TyTzZqPatkrswLSVu4bqUgnB03fHSOwpC7KSerPgJRgIAf11UGNf7HKjJV6oaPZI4AghLU6g==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.11.0", - "@typescript-eslint/typescript-estree": "2.11.0", + "@typescript-eslint/experimental-utils": "2.12.0", + "@typescript-eslint/typescript-estree": "2.12.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.11.0.tgz", - "integrity": "sha512-HGY4+d4MagO6cKMcKfIKaTMxcAv7dEVnji2Zi+vi5VV8uWAM631KjAB5GxFcexMYrwKT0EekRiiGK1/Sd7VFGA==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.12.0.tgz", + "integrity": "sha512-rGehVfjHEn8Frh9UW02ZZIfJs6SIIxIu/K1bbci8rFfDE/1lQ8krIJy5OXOV3DVnNdDPtoiPOdEANkLMrwXbiQ==", "dev": true, "requires": { "debug": "^4.1.1", @@ -1815,9 +1815,9 @@ } }, "eslint-plugin-prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.1.tgz", - "integrity": "sha512-A+TZuHZ0KU0cnn56/9mfR7/KjUJ9QNVXUhwvRFSR7PGPe0zQR6PTkmyqg1AtUUEOzTqeRsUwyKFh0oVZKVCrtA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", + "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", "dev": true, "requires": { "prettier-linter-helpers": "^1.0.0" @@ -3210,9 +3210,9 @@ "dev": true }, "inquirer": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz", - "integrity": "sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz", + "integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", @@ -3224,7 +3224,7 @@ "lodash": "^4.17.15", "mute-stream": "0.0.8", "run-async": "^2.2.0", - "rxjs": "^6.4.0", + "rxjs": "^6.5.3", "string-width": "^4.1.0", "strip-ansi": "^5.1.0", "through": "^2.3.6" @@ -3307,9 +3307,9 @@ } }, "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", "dev": true }, "is-descriptor": { @@ -3406,12 +3406,12 @@ "dev": true }, "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", "dev": true, "requires": { - "has": "^1.0.1" + "has": "^1.0.3" } }, "is-stream": { @@ -5054,9 +5054,9 @@ "dev": true }, "resolve": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", - "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz", + "integrity": "sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -5613,9 +5613,9 @@ } }, "string.prototype.trimleft": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", - "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", "dev": true, "requires": { "define-properties": "^1.1.3", @@ -5623,9 +5623,9 @@ } }, "string.prototype.trimright": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", - "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", "dev": true, "requires": { "define-properties": "^1.1.3", diff --git a/package.json b/package.json index d6ddeeb0..8615419b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.6.1", + "version": "1.6.2", "private": false, "description": "Setup PHP for use with GitHub Actions", "main": "dist/index.js", @@ -26,6 +26,7 @@ "dependencies": { "@actions/core": "^1.2.0", "@actions/exec": "^1.0.2", + "@actions/io": "^1.0.1", "fs": "0.0.1-security" }, "devDependencies": { diff --git a/src/configs/phpunit.json b/src/configs/phpunit.json new file mode 100644 index 00000000..44b9db6b --- /dev/null +++ b/src/configs/phpunit.json @@ -0,0 +1,24 @@ +{ + "problemMatcher": [ + { + "owner": "phpunit", + "pattern": [ + { + "regexp": "^\\d+\\)\\s.*$" + }, + { + "regexp": "^(.*)$", + "message": 1 + }, + { + "regexp": "^\\s*$" + }, + { + "regexp": "^(.*):(\\d+)$", + "file": 1, + "line": 2 + } + ] + } + ] +} diff --git a/src/ext/php_pcov.dll b/src/ext/php_pcov.dll index a63db08d..f6becd73 100644 Binary files a/src/ext/php_pcov.dll and b/src/ext/php_pcov.dll differ diff --git a/src/install.ts b/src/install.ts index 2070ee2f..b36434d8 100644 --- a/src/install.ts +++ b/src/install.ts @@ -4,6 +4,7 @@ import * as config from './config'; import * as coverage from './coverage'; import * as extensions from './extensions'; import * as utils from './utils'; +import * as matchers from './matchers'; /** * Build the script @@ -25,6 +26,7 @@ export async function build( (await utils.getInput('ini-values', false)) || (await utils.getInput('ini-values-csv', false)); const coverage_driver: string = await utils.getInput('coverage', false); + const setup_matchers: string = await utils.getInput('matchers', false); let script: string = await utils.readScript(filename, version, os_version); if (extension_csv) { @@ -63,9 +65,12 @@ export async function run(): Promise { } case 'win32': script_path = await build('win32.ps1', version, os_version); - await exec('pwsh ' + script_path + ' -version ' + version); + await exec( + 'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname + ); break; } + await matchers.addMatchers(); } catch (error) { core.setFailed(error.message); } diff --git a/src/matchers.ts b/src/matchers.ts new file mode 100644 index 00000000..500f2101 --- /dev/null +++ b/src/matchers.ts @@ -0,0 +1,18 @@ +import * as path from 'path'; +import * as utils from './utils'; +import * as io from '@actions/io'; + +/** + * Cache json files for problem matchers + */ +export async function addMatchers(): Promise { + const config_path = path.join( + __dirname, + '..', + 'src', + 'configs', + 'phpunit.json' + ); + const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false); + await io.cp(config_path, runner_dir); +} diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index c918c8cb..f5f6934f 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -17,8 +17,22 @@ add_log() { fi } +get_extension_regex() { + extension=$1 + case $extension in + "opcache") + echo "^Zend\sOPcache$" + ;; + "xdebug") + echo "^Xdebug$" + ;; + *) + echo ^"$extension"$ + ;; + esac +} + step_log "Setup PHP and Composer" -version=$1 export HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew tap shivammathur/homebrew-php >/dev/null 2>&1 brew install shivammathur/php/php@"$1" composer >/dev/null 2>&1 @@ -37,11 +51,12 @@ add_extension() { extension=$1 install_command=$2 prefix=$3 - if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then - echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled" - elif php -m | grep -i -q ^"$extension"$; then + extension_regex="$(get_extension_regex "$extension")" + if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then + echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" + elif php -m | grep -i -q "$extension_regex"; then add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q ^"$extension"$; then + elif ! php -m | grep -i -q "$extension_regex"; then exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) if [ "$exists" = "200" ]; then ( @@ -49,7 +64,7 @@ add_extension() { add_log "$tick" "$extension" "Installed and enabled" ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" else - if ! php -m | grep -i -q ^"$extension"$; then + if ! php -m | grep -i -q "$extension_regex"; then add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL" fi fi diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 499a2958..0e89a247 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -16,6 +16,22 @@ add_log() { printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" fi } + +get_extension_regex() { + extension=$1 + case $extension in + "opcache") + echo "^Zend\sOPcache$" + ;; + "xdebug") + echo "^Xdebug$" + ;; + *) + echo ^"$extension"$ + ;; + esac +} + existing_version=$(php-config --version | cut -c 1-3) semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') step_log "Setup PHP and Composer" @@ -96,11 +112,12 @@ add_extension() extension=$1 install_command=$2 prefix=$3 - if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then + extension_regex="$(get_extension_regex "$extension")" + if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled" - elif php -m | grep -i -q ^"$extension"$; then + elif php -m | grep -i -q "$extension_regex"; then add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q ^"$extension"$; then + elif ! php -m | grep -i -q "$extension_regex"; then ( eval "$install_command" && \ add_log "$tick" "$extension" "Installed and enabled" diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 28187395..7193d900 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -1,10 +1,14 @@ param ( - [Parameter(Mandatory = $true)][string]$version = "7.3" + [Parameter(Mandatory = $true)][string]$version = "7.4", + [Parameter(Mandatory=$true)][string]$dir ) $tick = ([char]8730) $cross = ([char]10007) $php_dir = 'C:\tools\php' +$ext_dir = $php_dir + '\ext' +$ProgressPreference = 'SilentlyContinue' +$master_version = '8.0' Function Step-Log($message) { printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message @@ -15,10 +19,6 @@ 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 } -if ($version -eq '8.0') { - $version = '7.4' -} - Step-Log "Setup PhpManager" Install-Module -Name PhpManager -Force -Scope CurrentUser Add-Log $tick "PhpManager" "Installed" @@ -33,11 +33,16 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) { } Step-Log "Setup PHP and Composer" if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) { + $arch='x64' if ($version -lt '7.0') { Install-Module -Name VcRedist -Force + $arch='x86' + } + if ($version -eq $master_version) { + $version = 'master' } - Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 + Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 $installed = Get-Php -Path $php_dir $status = "Installed PHP $($installed.FullVersion)" } @@ -46,12 +51,17 @@ else { } Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir -Enable-PhpExtension -Extension openssl, curl -Path $php_dir +Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir Update-PhpCAInfo -Path $php_dir -Source CurrentUser Add-Log $tick "PHP" $status Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir Add-Log $tick "Composer" "Installed" +if ($version -eq 'master') { + Copy-Item $dir"\..\src\ext\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" + Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir + Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir +} Function Add-Extension { Param (