Skip to content

Commit

Permalink
Merge pull request #87 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.5.4
  • Loading branch information
shivammathur authored Nov 26, 2019
2 parents 2b938d9 + 7964656 commit cade5f7
Show file tree
Hide file tree
Showing 51 changed files with 3,664 additions and 2,997 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": { "node": true, "jest": true },
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 2020, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": ["@typescript-eslint", "jest"],
"rules": {
"camelcase": "off",
"require-atomic-updates": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
11 changes: 10 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ Due to time constraints, you may not always get a quick response. Please do not

## Coding Guidelines

This project comes with a `.prettierrc.json` configuration file. Please run the following command to format the code before committing it.
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to format the code before committing it.

```bash
$ npm run format
$ npm run lint
```

## Using setup-php from a Git checkout
Expand All @@ -47,6 +48,14 @@ After following the steps shown above, The `setup-php` tests in the `__tests__`
$ npm test
```

## Creating a release

Create a release before you push your changes.

```bash
$ npm run release
```

## Reporting issues

Please submit the issue using the appropriate template provided for a bug report or a feature request:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I want to improve [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ This PR [briefly explain what it does]
- [ ] I have written test cases for the changes in this pull request
- [ ] I have run `npm run format` before the commit.
- [ ] I have run `npm run lint` before the commit.
- [ ] I have run `npm run release` before the commit.
- [ ] `npm test` returns with no unit test errors.

<!--
Expand Down
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/FIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ This PR [briefly explain what it does]

> In case this PR introduced TypeScript/JavaScript code changes:
- [ ] I have written test cases for the changes in this pull request
- [ ] I have written test cases for the changes in this pull request.
- [ ] I have run `npm run format` before the commit.
- [ ] I have run `npm run lint` before the commit.
- [ ] I have run `npm run release` before the commit.
- [ ] `npm test` returns with no unit test errors.

<!--
Expand Down
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/IMPROVEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ This PR [briefly explain what it does]

> In case this PR introduced TypeScript/JavaScript code changes:
- [ ] I have written test cases for the changes in this pull request
- [ ] I have written test cases for the changes in this pull request.
- [ ] I have run `npm run format` before the commit.
- [ ] I have run `npm run lint` before the commit.
- [ ] I have run `npm run release` before the commit.
- [ ] `npm test` returns with no unit test errors.

<!--
Expand Down
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/NEW_FEATURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ This PR [briefly explain what it does]

> In case this PR introduced TypeScript/JavaScript code changes:
- [ ] I have written test cases for the changes in this pull request
- [ ] I have written test cases for the changes in this pull request.
- [ ] I have run `npm run format` before the commit.
- [ ] I have run `npm run lint` before the commit.
- [ ] I have run `npm run release` before the commit.
- [ ] `npm test` returns with no unit test errors.

<!--
Expand Down
37 changes: 30 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
name: Main workflow
on: [push, pull_request]
on:
pull_request:
branches:
- master
- develop
- verbose
paths-ignore:
- '**.md'
push:
branches:
- master
- develop
- verbose
paths-ignore:
- '**.md'
jobs:
run:
name: Run
Expand All @@ -20,11 +34,14 @@ jobs:
with:
node-version: 12.x

- name: Cache node modules
uses: actions/cache@preview
id: cache
- name: Get npm cache directory
id: npm-cache
run: echo "::set-output name=dir::$(npm config get cache)"

- name: Install dependencies
uses: actions/cache@v1
with:
path: node_modules
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
Expand All @@ -33,16 +50,22 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
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: 2
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 lib/install.js
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xdebug, pcov #optional
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Explicitly not ignoring node_modules so that they are included in package downloaded by runner
!node_modules/
node_modules/
__tests__/runner/*
lib/

# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
Expand Down
22 changes: 12 additions & 10 deletions __tests__/coverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as config from '../src/config';
import * as coverage from '../src/coverage';
import * as extensions from '../src/coverage';

jest.mock('../src/extensions', () => ({
addExtension: jest.fn().mockImplementation(extension => {
Expand All @@ -24,48 +22,52 @@ describe('Config tests', () => {
});

it('checking addCoverage with PCOV on linux', async () => {
let linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
expect(linux).toContain('addExtension pcov');
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug');
});

it('checking addCoverage with PCOV on darwin', async () => {
let darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
expect(darwin).toContain('addExtension pcov');
});

it('checking addCoverage with Xdebug on windows', async () => {
let win32: string = await coverage.addCoverage('xdebug', '7.3', 'win32');
const win32: string = await coverage.addCoverage('xdebug', '7.3', 'win32');
expect(win32).toContain('addExtension xdebug');
});

it('checking addCoverage with Xdebug on linux', async () => {
let linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain('addExtension xdebug');
});

it('checking addCoverage with Xdebug on darwin', async () => {
let darwin: string = await coverage.addCoverage('xdebug', '7.4', 'darwin');
const darwin: string = await coverage.addCoverage(
'xdebug',
'7.4',
'darwin'
);
expect(darwin).toContain('addExtension xdebug');
});

it('checking disableCoverage windows', async () => {
let win32 = await coverage.addCoverage('none', '7.4', 'win32');
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Disable-PhpExtension xdebug');
expect(win32).toContain('Disable-PhpExtension pcov');
});

it('checking disableCoverage on linux', async () => {
let linux: string = await coverage.addCoverage('none', '7.4', 'linux');
const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug');
expect(linux).toContain('sudo phpdismod -v 7.4 pcov');
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
expect(linux).toContain('sudo sed -i "/pcov/d" $ini_file');
});

it('checking disableCoverage on darwin', async () => {
let darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file');
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file');
});
Expand Down
17 changes: 4 additions & 13 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,18 @@ describe('Extension tests', () => {
'7.2',
'win32'
);
expect(win32).toContain('Install-PhpExtension xdebug');
expect(win32).toContain('Install-PhpExtension pcov');
expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov');
win32 = await extensions.addExtension('xdebug, pcov', '7.4', 'win32');
const extension_url: string =
'https://xdebug.org/files/php_xdebug-2.8.0-7.4-vc15.dll';
expect(win32).toContain(
'Invoke-WebRequest -Uri ' +
extension_url +
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
);
expect(win32).toContain('Install-PhpExtension pcov');
expect(win32).toContain('Add-Extension xdebug');

win32 = await extensions.addExtension(
'does_not_exist',
'7.2',
'win32',
true
);
expect(win32).toContain(
'Add-Extension does_not_exist "Install-PhpExtension does_not_exist" extension'
);
expect(win32).toContain('Add-Extension does_not_exist');

win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(win32).toContain('Platform fedora is not supported');
Expand Down
23 changes: 12 additions & 11 deletions __tests__/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jest.mock('../src/install', () => ({
version: string,
os_version: string
): Promise<string> => {
let extension_csv: string = process.env['extension-csv'] || '';
let ini_values_csv: string = process.env['ini-values-csv'] || '';
let coverage_driver: string = process.env['coverage'] || '';
const extension_csv: string = process.env['extension-csv'] || '';
const ini_values_csv: string = process.env['ini-values-csv'] || '';
const coverage_driver: string = process.env['coverage'] || '';

let script: string = 'initial script';
let script = 'initial script ' + filename + version + os_version;
if (extension_csv) {
script += 'install extensions';
}
Expand All @@ -30,19 +30,20 @@ jest.mock('../src/install', () => ({
),
run: jest.fn().mockImplementation(
async (): Promise<string> => {
let os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || '';
let script: string = '';
const os_version: string = process.env['RUNNER_OS'] || '';
const version: string = process.env['php-version'] || '';
let script = '';
switch (os_version) {
case 'darwin':
script = await install.build(os_version + '.sh', version, os_version);
script += 'sh script.sh ' + version + ' ' + __dirname;
break;
case 'linux':
let pecl: string = process.env['pecl'] || '';
case 'linux': {
const pecl: string = process.env['pecl'] || '';
script = await install.build(os_version + '.sh', version, os_version);
script += 'sh script.sh ' + version + ' ' + pecl + ' ' + __dirname;
break;
}
case 'win32':
script = await install.build(os_version + '.sh', version, os_version);
script +=
Expand Down Expand Up @@ -72,7 +73,7 @@ function setEnv(
extension_csv: string,
ini_values_csv: string,
coverage_driver: string,
pecl: any
pecl: string
): void {
process.env['php-version'] = version;
process.env['RUNNER_OS'] = os;
Expand Down Expand Up @@ -116,7 +117,7 @@ describe('Install', () => {
expect(script).toContain('set coverage driver');
expect(script).toContain('sh script.sh 7.3 true');

setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', true);
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true');
// @ts-ignore
script = await install.run();
expect(script).toContain('initial script');
Expand Down
Loading

0 comments on commit cade5f7

Please sign in to comment.