mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Refactor composer setup
This commit is contained in:
parent
d1510a82d5
commit
925ede2589
@ -193,7 +193,7 @@ These tools can be setup globally using the `tools` input.
|
|||||||
tools: php-cs-fixer, phpunit
|
tools: php-cs-fixer, phpunit
|
||||||
```
|
```
|
||||||
|
|
||||||
- To set up a particular version of a tool, specify it in the form `tool:version`. The latest stable version of `composer` is set up by default. You can set up the required version by specifying `v1`, `v2`, `snapshot` or `preview` as version.
|
- To set up a particular version of a tool, specify it in the form `tool:version`. The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying `v1`, `v2`, `snapshot` or `preview` as versions or the exact version in semver format.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with composer v2
|
- name: Setup PHP with composer v2
|
||||||
@ -203,6 +203,8 @@ These tools can be setup globally using the `tools` input.
|
|||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- If you have specified composer plugins `prestissimo` or `composer-prefetcher` in tools, the latest stable version of `composer v1` will be setup. Unless some of your packages require `composer v1`, it is recommended to drop `prestissimo` and use `composer v2`.
|
||||||
|
|
||||||
- The latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
|
- The latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
|
||||||
|
|
||||||
- Version for other tools should be in `semver` format and a valid release of the tool. This is useful for installing tools for older versions of PHP. For example to set up `PHPUnit` on `PHP 7.2`.
|
- Version for other tools should be in `semver` format and a valid release of the tool. This is useful for installing tools for older versions of PHP. For example to set up `PHPUnit` on `PHP 7.2`.
|
||||||
|
@ -278,9 +278,15 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getComposerUrl('1.7.2')).toContain(
|
expect(await tools.getComposerUrl('1.7.2')).toContain(
|
||||||
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
|
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
|
||||||
);
|
);
|
||||||
|
expect(await tools.getComposerUrl('1.7.2')).toContain(
|
||||||
|
'https://getcomposer.org/composer-1.7.2.phar'
|
||||||
|
);
|
||||||
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
|
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
|
||||||
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
|
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
|
||||||
);
|
);
|
||||||
|
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
|
||||||
|
'https://getcomposer.org/composer-2.0.0-RC2.phar'
|
||||||
|
);
|
||||||
expect(await tools.getComposerUrl('wrong')).toContain(
|
expect(await tools.getComposerUrl('wrong')).toContain(
|
||||||
'https://getcomposer.org/composer-stable.phar'
|
'https://getcomposer.org/composer-stable.phar'
|
||||||
);
|
);
|
||||||
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@ -2047,22 +2047,17 @@ exports.addComposer = addComposer;
|
|||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
async function getComposerUrl(version) {
|
async function getComposerUrl(version) {
|
||||||
const cache_url = 'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
|
let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace('latest', 'stable')}.phar`;
|
||||||
version.replace('latest', 'stable') +
|
switch (true) {
|
||||||
'.phar,';
|
case /^snapshot$/.test(version):
|
||||||
switch (version) {
|
return `${cache_url},https://getcomposer.org/composer.phar`;
|
||||||
case 'snapshot':
|
case /^preview$|^[1-2]$/.test(version):
|
||||||
return cache_url + 'https://getcomposer.org/composer.phar';
|
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||||
case 'preview':
|
case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
|
||||||
case '1':
|
cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
|
||||||
case '2':
|
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||||
return (cache_url + 'https://getcomposer.org/composer-' + version + '.phar');
|
|
||||||
default:
|
default:
|
||||||
if (/^\d+\.\d+\.\d+[\w-]*$/.test(version)) {
|
return `${cache_url},https://getcomposer.org/composer-stable.phar`;
|
||||||
return (cache_url +
|
|
||||||
`https://github.com/composer/composer/releases/download/${version}/composer.phar`);
|
|
||||||
}
|
|
||||||
return cache_url + 'https://getcomposer.org/composer-stable.phar';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getComposerUrl = getComposerUrl;
|
exports.getComposerUrl = getComposerUrl;
|
||||||
|
33
src/tools.ts
33
src/tools.ts
@ -330,27 +330,20 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
|
|||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
export async function getComposerUrl(version: string): Promise<string> {
|
export async function getComposerUrl(version: string): Promise<string> {
|
||||||
const cache_url =
|
let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace(
|
||||||
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
|
'latest',
|
||||||
version.replace('latest', 'stable') +
|
'stable'
|
||||||
'.phar,';
|
)}.phar`;
|
||||||
switch (version) {
|
switch (true) {
|
||||||
case 'snapshot':
|
case /^snapshot$/.test(version):
|
||||||
return cache_url + 'https://getcomposer.org/composer.phar';
|
return `${cache_url},https://getcomposer.org/composer.phar`;
|
||||||
case 'preview':
|
case /^preview$|^[1-2]$/.test(version):
|
||||||
case '1':
|
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||||
case '2':
|
case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
|
||||||
return (
|
cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
|
||||||
cache_url + 'https://getcomposer.org/composer-' + version + '.phar'
|
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
if (/^\d+\.\d+\.\d+[\w-]*$/.test(version)) {
|
return `${cache_url},https://getcomposer.org/composer-stable.phar`;
|
||||||
return (
|
|
||||||
cache_url +
|
|
||||||
`https://github.com/composer/composer/releases/download/${version}/composer.phar`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return cache_url + 'https://getcomposer.org/composer-stable.phar';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user