Add support for jolicode/castor

This commit is contained in:
Loïck Piera 2023-06-23 16:13:17 +02:00
parent 4bd44f22a9
commit 7ce22e0264
No known key found for this signature in database
GPG Key ID: 694BD15C4779FF35
5 changed files with 86 additions and 2 deletions

View File

@ -224,7 +224,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
These tools can be set up globally using the `tools` input. It accepts a string in csv-format. These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
[`behat`], [`blackfire`], [`blackfire-player`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`] [`behat`], [`blackfire`], [`blackfire-player`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
```yaml ```yaml
- name: Setup PHP with tools - name: Setup PHP with tools
@ -1028,6 +1028,7 @@ These companies generously provide setup-php their products and services to aid
[`behat`]: https://docs.behat.org/en/latest/ [`behat`]: https://docs.behat.org/en/latest/
[`blackfire`]: https://blackfire.io/docs/php/index [`blackfire`]: https://blackfire.io/docs/php/index
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player [`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
[`castor`]: https://github.com/jolicode/castor
[`churn`]: https://github.com/bmitch/churn-php [`churn`]: https://github.com/bmitch/churn-php
[`codeception`]: https://codeception.com/ [`codeception`]: https://codeception.com/
[`composer`]: https://getcomposer.org/ [`composer`]: https://getcomposer.org/

View File

@ -526,6 +526,25 @@ describe('Tools tests', () => {
} }
); );
it.each`
version | os | uri
${'latest'} | ${'linux'} | ${'releases/latest/download/castor.linux-amd64.phar'}
${'0.5.1'} | ${'linux'} | ${'releases/download/v0.5.1/castor.linux-amd64.phar'}
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'}
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'}
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'}
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar'}
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
const data = getData({
tool: 'castor',
php_version: '8.1',
version: version,
os: os
});
expect(await tools.addCastor(data)).toContain(uri);
});
it.each` it.each`
tools_csv | script tools_csv | script
${'none'} | ${''} ${'none'} | ${''}

26
dist/index.js vendored
View File

@ -682,7 +682,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0; exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addCastor = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const fetch = __importStar(__nccwpck_require__(2387)); const fetch = __importStar(__nccwpck_require__(2387));
@ -837,6 +837,29 @@ async function addBlackfirePlayer(data) {
return addArchive(data); return addArchive(data);
} }
exports.addBlackfirePlayer = addBlackfirePlayer; exports.addBlackfirePlayer = addBlackfirePlayer;
async function addCastor(data) {
let filename;
switch (data['os']) {
case 'linux':
case 'darwin':
filename = 'castor.' + data['os'] + '-amd64.phar';
break;
case 'win32':
filename = 'castor.windows-amd64.phar';
break;
default:
return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error');
}
if (data['version'] === 'latest') {
data['uri'] = ['releases/latest/download', filename].join('/');
}
else {
data['uri'] = ['releases/download', 'v' + data['version'], filename].join('/');
}
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
return await addArchive(data);
}
exports.addCastor = addCastor;
async function addComposer(data) { async function addComposer(data) {
const channel = data['version'].replace('latest', 'stable'); const channel = data['version'].replace('latest', 'stable');
const github = data['github']; const github = data['github'];
@ -1015,6 +1038,7 @@ async function getData(release, php_version, os) {
} }
exports.getData = getData; exports.getData = getData;
exports.functionRecord = { exports.functionRecord = {
castor: addCastor,
composer: addComposer, composer: addComposer,
deployer: addDeployer, deployer: addDeployer,
dev_tools: addDevTools, dev_tools: addDevTools,

View File

@ -222,6 +222,12 @@
"version_prefix": "v", "version_prefix": "v",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"castor": {
"type": "custom-function",
"domain": "https://github.com",
"repository": "jolicode/castor",
"function": "castor"
},
"composer": { "composer": {
"type": "custom-function", "type": "custom-function",
"domain": "https://getcomposer.org", "domain": "https://getcomposer.org",

View File

@ -230,6 +230,39 @@ export async function addBlackfirePlayer(data: RS): Promise<string> {
return addArchive(data); return addArchive(data);
} }
/**
* Function to add Castor
*
* @param data
*/
export async function addCastor(data: RS): Promise<string> {
let filename: string;
switch (data['os']) {
case 'linux':
case 'darwin':
filename = 'castor.' + data['os'] + '-amd64.phar';
break;
case 'win32':
filename = 'castor.windows-amd64.phar';
break;
default:
return await utils.log(
'Platform ' + data['os'] + ' is not supported',
data['os'],
'error'
);
}
if (data['version'] === 'latest') {
data['uri'] = ['releases/latest/download', filename].join('/');
} else {
data['uri'] = ['releases/download', 'v' + data['version'], filename].join(
'/'
);
}
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
return await addArchive(data);
}
/** /**
* Function to add composer * Function to add composer
* *
@ -479,6 +512,7 @@ export async function getData(
} }
export const functionRecord: Record<string, (data: RS) => Promise<string>> = { export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
castor: addCastor,
composer: addComposer, composer: addComposer,
deployer: addDeployer, deployer: addDeployer,
dev_tools: addDevTools, dev_tools: addDevTools,