mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Bump version to 1.9.5
Switch to fixed getcomposer.org links Add composer fallback
This commit is contained in:
parent
5593bd4bd3
commit
f7fb800623
@ -1,21 +1,5 @@
|
|||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tools from '../src/tools';
|
import * as tools from '../src/tools';
|
||||||
|
|
||||||
httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
message: null,
|
|
||||||
readBody: jest.fn().mockImplementation(() => {
|
|
||||||
return JSON.stringify({
|
|
||||||
stable: [{path: '/composer-stable.phar'}],
|
|
||||||
preview: [{path: '/composer-preview.phar'}],
|
|
||||||
snapshot: [{path: '/composer.phar'}],
|
|
||||||
'1': [{path: '/composer-1.phar'}],
|
|
||||||
'2': [{path: '/composer-2.phar'}]
|
|
||||||
});
|
|
||||||
})
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Tools tests', () => {
|
describe('Tools tests', () => {
|
||||||
it('checking getCommand', async () => {
|
it('checking getCommand', async () => {
|
||||||
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||||
@ -424,7 +408,7 @@ describe('Tools tests', () => {
|
|||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||||
@ -458,7 +442,7 @@ describe('Tools tests', () => {
|
|||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
||||||
@ -501,7 +485,7 @@ describe('Tools tests', () => {
|
|||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||||
@ -531,7 +515,7 @@ describe('Tools tests', () => {
|
|||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||||
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||||
@ -546,12 +530,12 @@ describe('Tools tests', () => {
|
|||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://getcomposer.org/composer-1.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
|
||||||
);
|
);
|
||||||
|
|
||||||
script = await tools.addTools('composer:preview', '7.4', 'linux');
|
script = await tools.addTools('composer:preview', '7.4', 'linux');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://getcomposer.org/composer-preview.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer'
|
||||||
);
|
);
|
||||||
script = await tools.addTools(
|
script = await tools.addTools(
|
||||||
'composer:v1, composer:preview, composer:snapshot',
|
'composer:v1, composer:preview, composer:snapshot',
|
||||||
@ -559,7 +543,7 @@ describe('Tools tests', () => {
|
|||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://getcomposer.org/composer.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
940
dist/index.js
vendored
940
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
1353
package-lock.json
generated
1353
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.9.4",
|
"version": "1.9.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -26,26 +26,25 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.4",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/http-client": "^1.0.8",
|
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.9",
|
"@types/jest": "^26.0.10",
|
||||||
"@types/node": "^14.0.27",
|
"@types/node": "^14.0.27",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
"@typescript-eslint/eslint-plugin": "^3.9.0",
|
||||||
"@typescript-eslint/parser": "^3.8.0",
|
"@typescript-eslint/parser": "^3.9.0",
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^7.6.0",
|
"eslint": "^7.7.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.22.0",
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
"eslint-plugin-jest": "^23.20.0",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"husky": "^4.2.5",
|
"husky": "^4.2.5",
|
||||||
"jest": "^26.2.2",
|
"jest": "^26.4.0",
|
||||||
"jest-circus": "^26.2.2",
|
"jest-circus": "^26.4.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.0.5",
|
||||||
"ts-jest": "^26.1.4",
|
"ts-jest": "^26.2.0",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.7"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
@ -20,6 +20,8 @@ export async function build(
|
|||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// taking inputs
|
// taking inputs
|
||||||
|
const name = 'setup-php';
|
||||||
|
const url = 'setup-php.com/support';
|
||||||
const extension_csv: string =
|
const extension_csv: string =
|
||||||
(await utils.getInput('extensions', false)) ||
|
(await utils.getInput('extensions', false)) ||
|
||||||
(await utils.getInput('extension', false)) ||
|
(await utils.getInput('extension', false)) ||
|
||||||
@ -50,6 +52,9 @@ export async function build(
|
|||||||
script += await config.addINIValues(ini_values_csv, os_version);
|
script += await config.addINIValues(ini_values_csv, os_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script += '\n' + (await utils.stepLog('Support this project', os_version));
|
||||||
|
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
|
||||||
|
|
||||||
return await utils.writeScript(filename, script);
|
return await utils.writeScript(filename, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ get_pecl_version() {
|
|||||||
extension=$1
|
extension=$1
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
response=$(curl -sL "$pecl_rest$extension"/allreleases.xml)
|
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
|
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
if [ ! "$pecl_version" ]; then
|
if [ ! "$pecl_version" ]; then
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||||
@ -138,8 +138,13 @@ add_tool() {
|
|||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
IFS="," read -r -a urls <<< "$url"
|
||||||
|
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||||
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||||
|
else
|
||||||
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||||
|
fi
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x "$tool_path"
|
sudo chmod a+x "$tool_path"
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
@ -200,6 +205,7 @@ tick="✓"
|
|||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
|
curl_opts=(-sL)
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
|
||||||
cd xdebug || echo "Failed to clone Xdebug"
|
|
||||||
sudo ./rebuild.sh
|
|
@ -1,6 +0,0 @@
|
|||||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
|
||||||
cd xdebug || echo "Failed to clone Xdebug"
|
|
||||||
sudo phpize
|
|
||||||
sudo ./configure
|
|
||||||
sudo make
|
|
||||||
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
|
@ -16,7 +16,7 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to backup and cleanup package lists.
|
# Function to backup and cleanup package lists
|
||||||
cleanup_lists() {
|
cleanup_lists() {
|
||||||
if [ ! -e /etc/apt/sources.list.d.save ]; then
|
if [ ! -e /etc/apt/sources.list.d.save ]; then
|
||||||
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save || true
|
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save || true
|
||||||
@ -51,7 +51,7 @@ get_pecl_version() {
|
|||||||
extension=$1
|
extension=$1
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
response=$(curl -sL "$pecl_rest$extension"/allreleases.xml)
|
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
|
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
if [ ! "$pecl_version" ]; then
|
if [ ! "$pecl_version" ]; then
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||||
@ -169,7 +169,13 @@ add_tool() {
|
|||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
if [ "$tool" = "composer" ]; then
|
||||||
|
IFS="," read -r -a urls <<< "$url"
|
||||||
|
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||||
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||||
|
else
|
||||||
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||||
|
fi
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x "$tool_path"
|
sudo chmod a+x "$tool_path"
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
@ -184,6 +190,7 @@ add_tool() {
|
|||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
[ "$tool" = "composer" ] && exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +217,7 @@ add_devtools() {
|
|||||||
|
|
||||||
# Function to setup the nightly build from master branch
|
# Function to setup the nightly build from master branch
|
||||||
setup_master() {
|
setup_master() {
|
||||||
curl -sL https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
|
curl "${curl_opts[@]}" https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PECL
|
# Function to setup PECL
|
||||||
@ -250,6 +257,7 @@ version=$1
|
|||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
|
curl_opts=(-sL)
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
|
@ -145,8 +145,6 @@ Function Add-Tool() {
|
|||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$url,
|
$url,
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
@ -157,6 +155,7 @@ Function Add-Tool() {
|
|||||||
if (Test-Path $php_dir\$tool) {
|
if (Test-Path $php_dir\$tool) {
|
||||||
Remove-Item $php_dir\$tool
|
Remove-Item $php_dir\$tool
|
||||||
}
|
}
|
||||||
|
if($url.Count -gt 1) { $url = $url[0] }
|
||||||
if ($tool -eq "symfony") {
|
if ($tool -eq "symfony") {
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
||||||
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
|
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
|
||||||
|
22
src/tools.ts
22
src/tools.ts
@ -1,6 +1,4 @@
|
|||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get command to setup tools
|
* Function to get command to setup tools
|
||||||
@ -305,23 +303,21 @@ 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 getComposerUrlHelper = async function (
|
const cache_url =
|
||||||
version: string
|
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
|
||||||
): Promise<string> {
|
version.replace('latest', 'stable') +
|
||||||
const client: httpm.HttpClient = new httpm.HttpClient('setup-php');
|
'.phar,';
|
||||||
const response: hcr = await client.get('https://getcomposer.org/versions');
|
|
||||||
const data = JSON.parse(await response.readBody());
|
|
||||||
return 'https://getcomposer.org' + data[version][0]['path'];
|
|
||||||
};
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'snapshot':
|
case 'snapshot':
|
||||||
return 'https://getcomposer.org/composer.phar';
|
return cache_url + 'https://getcomposer.org/composer.phar';
|
||||||
case 'preview':
|
case 'preview':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
return await getComposerUrlHelper(version);
|
return (
|
||||||
|
cache_url + 'https://getcomposer.org/composer-' + version + '.phar'
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return 'https://getcomposer.org/composer-stable.phar';
|
return cache_url + 'https://getcomposer.org/composer-stable.phar';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user