Add extension dependency support for Darwin
Refactor extension.sh to 3 scripts Update dependencies Minor fixes in cache.ts and tests Improve get_api_version in cache.sh Improve logs Use @actions/cache to cache dependencies Refactor linux.sh Refactor Node.js code Do not setup dependencies for old PHP Remove duplicate dependency extensions in linux Bump version to 1.6.0
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import path from 'path';
|
||||
import * as cache from '../src/cache';
|
||||
import * as utils from '../src/utils';
|
||||
|
||||
@@ -6,17 +7,14 @@ import * as utils from '../src/utils';
|
||||
*/
|
||||
jest.mock('../src/cache', () => ({
|
||||
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
||||
let version: string = process.env['php-version'] || '';
|
||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||
const version: string = await utils.parseVersion(
|
||||
process.env['php-version'] || ''
|
||||
);
|
||||
const extensions = await utils.filterExtensions(
|
||||
process.env['extensions'] || ''
|
||||
);
|
||||
const key: string = process.env['key'] || '';
|
||||
const script_path = 'extensions.sh';
|
||||
|
||||
return (
|
||||
'bash ' + script_path + ' "' + extensions + '" ' + key + ' ' + version
|
||||
);
|
||||
return await utils.scriptCall('test', extensions, key, version);
|
||||
})
|
||||
}));
|
||||
|
||||
@@ -38,21 +36,22 @@ function setEnv(
|
||||
}
|
||||
|
||||
describe('Install', () => {
|
||||
const spath: string = path.join(__dirname, '../src/scripts/cache.sh');
|
||||
it('Test Run', async () => {
|
||||
setEnv('7.0', 'xdebug, pcov', 'cache-v1');
|
||||
const script: string = '' + (await cache.run());
|
||||
expect(script).toContain('bash extensions.sh "xdebug, pcov" cache-v1 7.0');
|
||||
expect(script).toContain(`bash ${spath} test "xdebug, pcov" cache-v1 7.0`);
|
||||
});
|
||||
|
||||
it('Test Run', async () => {
|
||||
setEnv('7.4', 'xdebug, zip', 'cache-v2');
|
||||
const script: string = '' + (await cache.run());
|
||||
expect(script).toContain('bash extensions.sh "xdebug, zip" cache-v2 7.4');
|
||||
expect(script).toContain(`bash ${spath} test "xdebug, zip" cache-v2 7.4`);
|
||||
});
|
||||
|
||||
it('Test Run', async () => {
|
||||
setEnv('7.4', 'xdebug, :zip', 'cache-v2');
|
||||
const script: string = '' + (await cache.run());
|
||||
expect(script).toContain('bash extensions.sh "xdebug" cache-v2 7.4');
|
||||
expect(script).toContain(`bash ${spath} test "xdebug" cache-v2 7.4`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
|
||||
jest.mock('@actions/core', () => ({
|
||||
@@ -6,6 +8,14 @@ jest.mock('@actions/core', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
async function cleanup(path: string): Promise<void> {
|
||||
fs.unlink(path, error => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe('Utils tests', () => {
|
||||
it('checking readEnv', async () => {
|
||||
process.env['test'] = 'setup-php';
|
||||
@@ -20,11 +30,19 @@ describe('Utils tests', () => {
|
||||
'cache-extensions'
|
||||
);
|
||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||
expect(async () => {
|
||||
await expect(async () => {
|
||||
await utils.getInput('DoesNotExist', true);
|
||||
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
|
||||
});
|
||||
|
||||
it('checking getOutput', async () => {
|
||||
const temp_dir: string = process.env['RUNNER_TEMP'] || '';
|
||||
const file_path: string = path.join(temp_dir, 'test');
|
||||
fs.writeFileSync(file_path, 'test', {mode: 0o755});
|
||||
expect(await utils.getOutput('test')).toBe('test');
|
||||
await cleanup(file_path);
|
||||
});
|
||||
|
||||
it('checking parseVersion', async () => {
|
||||
expect(await utils.parseVersion('7')).toBe('7.0');
|
||||
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
||||
@@ -32,7 +50,7 @@ describe('Utils tests', () => {
|
||||
});
|
||||
|
||||
it('checking filterExtensions', async () => {
|
||||
expect(await utils.filterExtensions('a,:b,c')).toBe('a,c');
|
||||
expect(await utils.filterExtensions('a, :b, c')).toBe('a, c');
|
||||
expect(await utils.filterExtensions('a,:b,c')).toBe('"a,c"');
|
||||
expect(await utils.filterExtensions('a, :b, c')).toBe('"a, c"');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user