Skip to content

Commit cade5f7

Browse files
authored
Merge pull request #87 from shivammathur/develop
1.5.4
2 parents 2b938d9 + 7964656 commit cade5f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3664
-2997
lines changed

.eslintrc.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": { "node": true, "jest": true },
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": { "ecmaVersion": 2020, "sourceType": "module" },
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:import/errors",
10+
"plugin:import/warnings",
11+
"plugin:import/typescript",
12+
"plugin:prettier/recommended",
13+
"prettier/@typescript-eslint"
14+
],
15+
"plugins": ["@typescript-eslint", "jest"],
16+
"rules": {
17+
"camelcase": "off",
18+
"require-atomic-updates": "off",
19+
"@typescript-eslint/ban-ts-ignore": "off",
20+
"@typescript-eslint/camelcase": "off",
21+
"@typescript-eslint/no-unused-vars": "off"
22+
}
23+
}

.github/CONTRIBUTING.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Due to time constraints, you may not always get a quick response. Please do not
1717

1818
## Coding Guidelines
1919

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

2222
```bash
2323
$ npm run format
24+
$ npm run lint
2425
```
2526

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

51+
## Creating a release
52+
53+
Create a release before you push your changes.
54+
55+
```bash
56+
$ npm run release
57+
```
58+
5059
## Reporting issues
5160

5261
Please submit the issue using the appropriate template provided for a bug report or a feature request:

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88
---
99

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

1313
**Describe the solution you'd like**
1414
A clear and concise description of what you want to happen.

.github/PULL_REQUEST_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This PR [briefly explain what it does]
2424
2525
- [ ] I have written test cases for the changes in this pull request
2626
- [ ] I have run `npm run format` before the commit.
27+
- [ ] I have run `npm run lint` before the commit.
28+
- [ ] I have run `npm run release` before the commit.
2729
- [ ] `npm test` returns with no unit test errors.
2830

2931
<!--

.github/PULL_REQUEST_TEMPLATE/FIX.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ This PR [briefly explain what it does]
2222

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

2931
<!--

.github/PULL_REQUEST_TEMPLATE/IMPROVEMENT.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ This PR [briefly explain what it does]
2222

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

2931
<!--

.github/PULL_REQUEST_TEMPLATE/NEW_FEATURE.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ This PR [briefly explain what it does]
2222

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

2931
<!--

.github/workflows/workflow.yml

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
name: Main workflow
2-
on: [push, pull_request]
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
- develop
7+
- verbose
8+
paths-ignore:
9+
- '**.md'
10+
push:
11+
branches:
12+
- master
13+
- develop
14+
- verbose
15+
paths-ignore:
16+
- '**.md'
317
jobs:
418
run:
519
name: Run
@@ -20,11 +34,14 @@ jobs:
2034
with:
2135
node-version: 12.x
2236

23-
- name: Cache node modules
24-
uses: actions/cache@preview
25-
id: cache
37+
- name: Get npm cache directory
38+
id: npm-cache
39+
run: echo "::set-output name=dir::$(npm config get cache)"
40+
41+
- name: Install dependencies
42+
uses: actions/cache@v1
2643
with:
27-
path: node_modules
44+
path: ${{ steps.npm-cache.outputs.dir }}
2845
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
2946
restore-keys: |
3047
${{ runner.os }}-node-
@@ -33,16 +50,22 @@ jobs:
3350
if: steps.cache.outputs.cache-hit != 'true'
3451
run: npm install
3552

53+
- name: Prettier Format Check
54+
run: npm run format-check
55+
56+
- name: ESLint Check
57+
run: npm run lint
58+
3659
- name: Run tests
3760
run: npm test
3861

3962
- name: Send Coverage
4063
continue-on-error: true
41-
timeout-minutes: 2
64+
timeout-minutes: 1
4265
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 }}
4366

4467
- name: Setup PHP with extensions and custom config
45-
run: node lib/install.js
68+
run: node dist/index.js
4669
env:
4770
php-version: ${{ matrix.php-versions }}
4871
extension-csv: mbstring, xdebug, pcov #optional

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Explicitly not ignoring node_modules so that they are included in package downloaded by runner
2-
!node_modules/
2+
node_modules/
33
__tests__/runner/*
4+
lib/
45

56
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
67
# Logs

__tests__/coverage.test.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import * as config from '../src/config';
21
import * as coverage from '../src/coverage';
3-
import * as extensions from '../src/coverage';
42

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

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

3331
it('checking addCoverage with PCOV on darwin', async () => {
34-
let darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
32+
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
3533
expect(darwin).toContain('addExtension pcov');
3634
});
3735

3836
it('checking addCoverage with Xdebug on windows', async () => {
39-
let win32: string = await coverage.addCoverage('xdebug', '7.3', 'win32');
37+
const win32: string = await coverage.addCoverage('xdebug', '7.3', 'win32');
4038
expect(win32).toContain('addExtension xdebug');
4139
});
4240

4341
it('checking addCoverage with Xdebug on linux', async () => {
44-
let linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
42+
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
4543
expect(linux).toContain('addExtension xdebug');
4644
});
4745

4846
it('checking addCoverage with Xdebug on darwin', async () => {
49-
let darwin: string = await coverage.addCoverage('xdebug', '7.4', 'darwin');
47+
const darwin: string = await coverage.addCoverage(
48+
'xdebug',
49+
'7.4',
50+
'darwin'
51+
);
5052
expect(darwin).toContain('addExtension xdebug');
5153
});
5254

5355
it('checking disableCoverage windows', async () => {
54-
let win32 = await coverage.addCoverage('none', '7.4', 'win32');
56+
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
5557
expect(win32).toContain('Disable-PhpExtension xdebug');
5658
expect(win32).toContain('Disable-PhpExtension pcov');
5759
});
5860

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

6769
it('checking disableCoverage on darwin', async () => {
68-
let darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
70+
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
6971
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file');
7072
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file');
7173
});

__tests__/extensions.test.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,18 @@ describe('Extension tests', () => {
77
'7.2',
88
'win32'
99
);
10-
expect(win32).toContain('Install-PhpExtension xdebug');
11-
expect(win32).toContain('Install-PhpExtension pcov');
10+
expect(win32).toContain('Add-Extension xdebug');
11+
expect(win32).toContain('Add-Extension pcov');
1212
win32 = await extensions.addExtension('xdebug, pcov', '7.4', 'win32');
13-
const extension_url: string =
14-
'https://xdebug.org/files/php_xdebug-2.8.0-7.4-vc15.dll';
15-
expect(win32).toContain(
16-
'Invoke-WebRequest -Uri ' +
17-
extension_url +
18-
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
19-
);
20-
expect(win32).toContain('Install-PhpExtension pcov');
13+
expect(win32).toContain('Add-Extension xdebug');
2114

2215
win32 = await extensions.addExtension(
2316
'does_not_exist',
2417
'7.2',
2518
'win32',
2619
true
2720
);
28-
expect(win32).toContain(
29-
'Add-Extension does_not_exist "Install-PhpExtension does_not_exist" extension'
30-
);
21+
expect(win32).toContain('Add-Extension does_not_exist');
3122

3223
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
3324
expect(win32).toContain('Platform fedora is not supported');

__tests__/install.test.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jest.mock('../src/install', () => ({
1010
version: string,
1111
os_version: string
1212
): Promise<string> => {
13-
let extension_csv: string = process.env['extension-csv'] || '';
14-
let ini_values_csv: string = process.env['ini-values-csv'] || '';
15-
let coverage_driver: string = process.env['coverage'] || '';
13+
const extension_csv: string = process.env['extension-csv'] || '';
14+
const ini_values_csv: string = process.env['ini-values-csv'] || '';
15+
const coverage_driver: string = process.env['coverage'] || '';
1616

17-
let script: string = 'initial script';
17+
let script = 'initial script ' + filename + version + os_version;
1818
if (extension_csv) {
1919
script += 'install extensions';
2020
}
@@ -30,19 +30,20 @@ jest.mock('../src/install', () => ({
3030
),
3131
run: jest.fn().mockImplementation(
3232
async (): Promise<string> => {
33-
let os_version: string = process.env['RUNNER_OS'] || '';
34-
let version: string = process.env['php-version'] || '';
35-
let script: string = '';
33+
const os_version: string = process.env['RUNNER_OS'] || '';
34+
const version: string = process.env['php-version'] || '';
35+
let script = '';
3636
switch (os_version) {
3737
case 'darwin':
3838
script = await install.build(os_version + '.sh', version, os_version);
3939
script += 'sh script.sh ' + version + ' ' + __dirname;
4040
break;
41-
case 'linux':
42-
let pecl: string = process.env['pecl'] || '';
41+
case 'linux': {
42+
const pecl: string = process.env['pecl'] || '';
4343
script = await install.build(os_version + '.sh', version, os_version);
4444
script += 'sh script.sh ' + version + ' ' + pecl + ' ' + __dirname;
4545
break;
46+
}
4647
case 'win32':
4748
script = await install.build(os_version + '.sh', version, os_version);
4849
script +=
@@ -72,7 +73,7 @@ function setEnv(
7273
extension_csv: string,
7374
ini_values_csv: string,
7475
coverage_driver: string,
75-
pecl: any
76+
pecl: string
7677
): void {
7778
process.env['php-version'] = version;
7879
process.env['RUNNER_OS'] = os;
@@ -116,7 +117,7 @@ describe('Install', () => {
116117
expect(script).toContain('set coverage driver');
117118
expect(script).toContain('sh script.sh 7.3 true');
118119

119-
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', true);
120+
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true');
120121
// @ts-ignore
121122
script = await install.run();
122123
expect(script).toContain('initial script');

0 commit comments

Comments
 (0)