mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-25 21:13:04 +07:00
Set up codeception using composer
Add fixes for global composer tools
This commit is contained in:
parent
0a5e543af7
commit
d27996462b
@ -112,93 +112,6 @@ describe('Tools tests', () => {
|
||||
).toBe('releases/download/v1.2.3/tool.phar');
|
||||
});
|
||||
|
||||
it('checking getCodeceptionUriBuilder', async () => {
|
||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe(
|
||||
'releases/3.2.1/php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php54')).toBe(
|
||||
'releases/3.2.1/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe(
|
||||
'releases/3.2.1/codecept.phar'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking getCodeceptionUri', async () => {
|
||||
expect(await tools.getCodeceptionUri('latest', '5.6')).toBe(
|
||||
'php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('latest', '7.0')).toBe(
|
||||
'php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('latest', '7.1')).toBe(
|
||||
'php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('latest', '7.2')).toBe(
|
||||
'codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('latest', '7.3')).toBe(
|
||||
'codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
|
||||
'codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('4.0.0', '7.4')).toBe(
|
||||
'releases/4.0.0/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe(
|
||||
'releases/4.0.0/php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe(
|
||||
'releases/4.0.0/php56/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe(
|
||||
'releases/3.1.0/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe(
|
||||
'releases/3.1.0/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe(
|
||||
'releases/2.5.4/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe(
|
||||
'releases/2.5.4/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe(
|
||||
'releases/2.3.4/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe(
|
||||
'releases/2.3.4/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe(
|
||||
'releases/2.2.4/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe(
|
||||
'releases/2.2.4/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe(
|
||||
'releases/2.2.4/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe(
|
||||
'releases/2.1.7/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe(
|
||||
'releases/2.1.7/php54/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe(
|
||||
'releases/2.1.5/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe(
|
||||
'releases/2.1.5/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe(
|
||||
'releases/1.6.9/codecept.phar'
|
||||
);
|
||||
expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe(
|
||||
'releases/1.5.0/codecept.phar'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking addPhive', async () => {
|
||||
let script: string = await tools.addPhive('1.2.3', '7.4', 'linux');
|
||||
expect(script).toContain(
|
||||
@ -495,7 +408,7 @@ describe('Tools tests', () => {
|
||||
});
|
||||
it('checking addTools on windows', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'codeception, cs2pr, deployer, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exist, composer',
|
||||
'cs2pr, deployer, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exist, composer',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
@ -524,7 +437,7 @@ describe('Tools tests', () => {
|
||||
});
|
||||
it('checking addTools with composer tool using user/tool as input', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx',
|
||||
'codeception/codeception, hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
|
80
dist/index.js
vendored
80
dist/index.js
vendored
@ -1696,7 +1696,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = exports.getCommand = void 0;
|
||||
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getUri = exports.parseTool = exports.getToolVersion = exports.getCommand = void 0;
|
||||
const utils = __importStar(__webpack_require__(163));
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
@ -1781,77 +1781,6 @@ async function getUri(tool, extension, version, prefix, version_prefix, verb) {
|
||||
}
|
||||
}
|
||||
exports.getUri = getUri;
|
||||
/**
|
||||
* Helper function to get the codeception url
|
||||
*
|
||||
* @param version
|
||||
* @param suffix
|
||||
*/
|
||||
async function getCodeceptionUriBuilder(version, suffix) {
|
||||
return ['releases', version, suffix, 'codecept.phar']
|
||||
.filter(Boolean)
|
||||
.join('/');
|
||||
}
|
||||
exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
|
||||
/**
|
||||
* Function to get the codeception url
|
||||
*
|
||||
* @param version
|
||||
* @param php_version
|
||||
*/
|
||||
async function getCodeceptionUri(version, php_version) {
|
||||
const codecept = await getCodeceptionUriBuilder(version, '');
|
||||
const codecept54 = await getCodeceptionUriBuilder(version, 'php54');
|
||||
const codecept56 = await getCodeceptionUriBuilder(version, 'php56');
|
||||
// Refer to https://codeception.com/builds
|
||||
switch (true) {
|
||||
case /latest/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6|7\.[0|1]/.test(php_version):
|
||||
return 'php56/codecept.phar';
|
||||
case /7\.[2-4]/.test(php_version):
|
||||
default:
|
||||
return 'codecept.phar';
|
||||
}
|
||||
case /(^[4-9]|\d{2,})\..*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6|7\.[0|1]/.test(php_version):
|
||||
return codecept56;
|
||||
case /7\.[2-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6/.test(php_version):
|
||||
return codecept54;
|
||||
case /7\.[0-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /^2\.3\.\d+.*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.[4-6]/.test(php_version):
|
||||
return codecept54;
|
||||
case /^7\.[0-4]$/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.[4-5]/.test(php_version):
|
||||
return codecept54;
|
||||
case /5.6|7\.[0-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||
return codecept;
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
}
|
||||
exports.getCodeceptionUri = getCodeceptionUri;
|
||||
/**
|
||||
* Helper function to get script to setup phive
|
||||
*
|
||||
@ -1999,7 +1928,7 @@ async function getCleanedToolsList(tools_csv) {
|
||||
.map(function (extension) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
|
||||
.replace(/codeception\/|hirak\/|robmorgan\/|narrowspark\/automatic-/, '');
|
||||
})
|
||||
.filter(Boolean);
|
||||
return [...new Set(tools_list)];
|
||||
@ -2104,10 +2033,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
||||
script += await addArchive('composer', url, os_version);
|
||||
break;
|
||||
case 'codeception':
|
||||
url =
|
||||
'https://codeception.com/' +
|
||||
(await getCodeceptionUri(version, php_version));
|
||||
script += await addArchive(tool, url, os_version);
|
||||
script += await addPackage(tool, release, 'codeception/', os_version);
|
||||
break;
|
||||
case 'phpcpd':
|
||||
case 'phpunit':
|
||||
|
@ -146,6 +146,10 @@ configure_composer() {
|
||||
add_log "$cross" "composer" "Could not download composer"
|
||||
exit 1;
|
||||
fi
|
||||
if ! [ -e "$composer_json" ]; then
|
||||
echo '{}' | tee "$composer_json" >/dev/null 2>&1
|
||||
sudo chmod 644 "$composer_json"
|
||||
fi
|
||||
composer -q config -g process-timeout 0
|
||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
@ -200,6 +204,7 @@ add_composertool() {
|
||||
release=$2
|
||||
prefix=$3
|
||||
(
|
||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
@ -259,6 +264,8 @@ dist=$2
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sL)
|
||||
composer_bin="$HOME/.composer/vendor/bin"
|
||||
composer_json="$HOME/.composer/composer.json"
|
||||
composer_lock="$HOME/.composer/composer.lock"
|
||||
brew_prefix="$(brew --prefix)"
|
||||
brew_repo="$(brew --repository)"
|
||||
tap_dir="$brew_repo"/Library/Taps
|
||||
|
@ -155,6 +155,10 @@ configure_composer() {
|
||||
add_log "$cross" "composer" "Could not download composer"
|
||||
exit 1;
|
||||
fi
|
||||
if ! [ -e "$composer_json" ]; then
|
||||
echo '{}' | tee "$composer_json" >/dev/null 2>&1
|
||||
sudo chmod 644 "$composer_json"
|
||||
fi
|
||||
composer -q config -g process-timeout 0
|
||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
@ -205,6 +209,7 @@ add_composertool() {
|
||||
release=$2
|
||||
prefix=$3
|
||||
(
|
||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
@ -276,6 +281,8 @@ apt_install="sudo $debconf_fix apt-fast install -y"
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sL)
|
||||
composer_bin="$HOME/.composer/vendor/bin"
|
||||
composer_json="$HOME/.composer/composer.json"
|
||||
composer_lock="$HOME/.composer/composer.lock"
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
# Setup PHP
|
||||
|
@ -155,6 +155,9 @@ Function Edit-ComposerConfig() {
|
||||
Add-Log "$cross" "composer" "Could not download composer"
|
||||
exit 1;
|
||||
}
|
||||
if (-not(Test-Path $composer_json)) {
|
||||
Set-Content -Path $composer_json -Value "{}"
|
||||
}
|
||||
composer -q config -g process-timeout 0
|
||||
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||
if (Test-Path env:COMPOSER_TOKEN) {
|
||||
@ -236,6 +239,9 @@ Function Add-Composertool() {
|
||||
[string]
|
||||
$prefix
|
||||
)
|
||||
if(Test-Path $composer_lock) {
|
||||
Remove-Item -Path $composer_lock -Force
|
||||
}
|
||||
composer -q global require $prefix$release 2>&1 | out-null
|
||||
if($?) {
|
||||
Add-Log $tick $tool "Added"
|
||||
@ -260,6 +266,8 @@ $current_profile = "$PSHOME\Profile.ps1"
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$github = 'https://github.com'
|
||||
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
||||
$composer_json = "$env:APPDATA\Composer\composer.json"
|
||||
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
||||
$master_version = '8.0'
|
||||
$arch = 'x64'
|
||||
$ts = $env:PHPTS -eq 'ts'
|
||||
|
87
src/tools.ts
87
src/tools.ts
@ -99,83 +99,6 @@ export async function getUri(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the codeception url
|
||||
*
|
||||
* @param version
|
||||
* @param suffix
|
||||
*/
|
||||
export async function getCodeceptionUriBuilder(
|
||||
version: string,
|
||||
suffix: string
|
||||
): Promise<string> {
|
||||
return ['releases', version, suffix, 'codecept.phar']
|
||||
.filter(Boolean)
|
||||
.join('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the codeception url
|
||||
*
|
||||
* @param version
|
||||
* @param php_version
|
||||
*/
|
||||
export async function getCodeceptionUri(
|
||||
version: string,
|
||||
php_version: string
|
||||
): Promise<string> {
|
||||
const codecept: string = await getCodeceptionUriBuilder(version, '');
|
||||
const codecept54: string = await getCodeceptionUriBuilder(version, 'php54');
|
||||
const codecept56: string = await getCodeceptionUriBuilder(version, 'php56');
|
||||
// Refer to https://codeception.com/builds
|
||||
switch (true) {
|
||||
case /latest/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6|7\.[0|1]/.test(php_version):
|
||||
return 'php56/codecept.phar';
|
||||
case /7\.[2-4]/.test(php_version):
|
||||
default:
|
||||
return 'codecept.phar';
|
||||
}
|
||||
case /(^[4-9]|\d{2,})\..*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6|7\.[0|1]/.test(php_version):
|
||||
return codecept56;
|
||||
case /7\.[2-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.6/.test(php_version):
|
||||
return codecept54;
|
||||
case /7\.[0-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /^2\.3\.\d+.*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.[4-6]/.test(php_version):
|
||||
return codecept54;
|
||||
case /^7\.[0-4]$/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
|
||||
switch (true) {
|
||||
case /5\.[4-5]/.test(php_version):
|
||||
return codecept54;
|
||||
case /5.6|7\.[0-4]/.test(php_version):
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||
return codecept;
|
||||
default:
|
||||
return codecept;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get script to setup phive
|
||||
*
|
||||
@ -348,7 +271,10 @@ export async function getCleanedToolsList(
|
||||
.map(function (extension: string) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
|
||||
.replace(
|
||||
/codeception\/|hirak\/|robmorgan\/|narrowspark\/automatic-/,
|
||||
''
|
||||
);
|
||||
})
|
||||
.filter(Boolean);
|
||||
return [...new Set(tools_list)];
|
||||
@ -487,10 +413,7 @@ export async function addTools(
|
||||
script += await addArchive('composer', url, os_version);
|
||||
break;
|
||||
case 'codeception':
|
||||
url =
|
||||
'https://codeception.com/' +
|
||||
(await getCodeceptionUri(version, php_version));
|
||||
script += await addArchive(tool, url, os_version);
|
||||
script += await addPackage(tool, release, 'codeception/', os_version);
|
||||
break;
|
||||
case 'phpcpd':
|
||||
case 'phpunit':
|
||||
|
Loading…
Reference in New Issue
Block a user