From 2b027bd9bc5303cafb6fc55454c8b8e0e2efb951 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 14 Dec 2019 10:13:01 +0530 Subject: [PATCH] Fix reading unquoted versions --- .github/workflows/experimental-workflow.yml | 2 +- .github/workflows/workflow.yml | 2 +- __tests__/install.test.ts | 11 +++++++++-- dist/index.js | 3 ++- src/install.ts | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/experimental-workflow.yml b/.github/workflows/experimental-workflow.yml index 500e5b0e..d5fa054b 100644 --- a/.github/workflows/experimental-workflow.yml +++ b/.github/workflows/experimental-workflow.yml @@ -26,7 +26,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest] - php-versions: ['8.0'] + php-versions: [8.0] steps: - name: Checkout uses: actions/checkout@v1 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2ee9edbf..612f332e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest, windows-latest, macOS-latest] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + php-versions: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4] steps: - name: Checkout uses: actions/checkout@v1 diff --git a/__tests__/install.test.ts b/__tests__/install.test.ts index a4077873..9842a38e 100644 --- a/__tests__/install.test.ts +++ b/__tests__/install.test.ts @@ -31,7 +31,8 @@ jest.mock('../src/install', () => ({ run: jest.fn().mockImplementation( async (): Promise => { const os_version: string = process.env['RUNNER_OS'] || ''; - const version: string = process.env['php-version'] || ''; + let version: string = process.env['php-version'] || ''; + version = version.length > 1 ? version : version + '.0'; let script = ''; switch (os_version) { case 'darwin': @@ -85,10 +86,16 @@ function setEnv( describe('Install', () => { it('Test install on windows', async () => { - setEnv('7.3', 'win32', '', '', '', ''); + setEnv('7.0', 'win32', '', '', '', ''); // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); + expect(script).toContain('pwsh script.ps1 -version 7.0 -dir ' + __dirname); + + setEnv('7.3', 'win32', '', '', '', ''); + // @ts-ignore + script = await install.run(); + expect(script).toContain('initial script'); expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname); setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); diff --git a/dist/index.js b/dist/index.js index 9471a006..2deebbb8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1831,7 +1831,8 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const os_version = process.platform; - const version = yield utils.getInput('php-version', true); + let version = yield utils.getInput('php-version', true); + version = version.length > 1 ? version : version + '.0'; // check the os version and run the respective script let script_path = ''; switch (os_version) { diff --git a/src/install.ts b/src/install.ts index 34172400..2070ee2f 100644 --- a/src/install.ts +++ b/src/install.ts @@ -46,7 +46,8 @@ export async function build( export async function run(): Promise { try { const os_version: string = process.platform; - const version: string = await utils.getInput('php-version', true); + let version: string = await utils.getInput('php-version', true); + version = version.length > 1 ? version : version + '.0'; // check the os version and run the respective script let script_path = ''; switch (os_version) {