mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-11-24 21:22:02 +00:00
Deployer GitHub releases (#1149)
* Download Deployer from GitHub releases Resolve the Deployer phar URL from the deployphp/deployer GitHub releases instead of fetching the deployer.org manifest, keeping deployer.org as a fallback for versions not published on GitHub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Use real Deployer version in checksum test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0b3aa3e956
commit
7456d5cfaf
+21
-22
@@ -45,11 +45,7 @@ jest.unstable_mockModule('../src/fetch.js', () => ({
|
|||||||
.fn<typeof import('../src/fetch.js').fetch>()
|
.fn<typeof import('../src/fetch.js').fetch>()
|
||||||
.mockImplementation(
|
.mockImplementation(
|
||||||
async (url: string, token?: string): Promise<Record<string, string>> => {
|
async (url: string, token?: string): Promise<Record<string, string>> => {
|
||||||
if (url.includes('deployer')) {
|
if (url.includes('atom') && !url.includes('no-')) {
|
||||||
return {
|
|
||||||
data: '[{"version": "1.2.3", "url": "https://deployer.org/releases/v1.2.3/deployer.phar"}]'
|
|
||||||
};
|
|
||||||
} else if (url.includes('atom') && !url.includes('no-')) {
|
|
||||||
return {
|
return {
|
||||||
data: '"releases/tag/1.2.3", "releases/tag/3.2.1", "releases/tag/2.3.1"'
|
data: '"releases/tag/1.2.3", "releases/tag/3.2.1", "releases/tag/2.3.1"'
|
||||||
};
|
};
|
||||||
@@ -485,13 +481,15 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | url
|
version | url
|
||||||
${'latest'} | ${'https://deployer.org/deployer.phar'}
|
${'latest'} | ${'https://github.com/deployphp/deployer/releases/latest/download/deployer.phar,https://deployer.org/deployer.phar deployer'}
|
||||||
${'1.2.3'} | ${'https://deployer.org/releases/v1.2.3/deployer.phar'}
|
${'7.5.12'} | ${'https://github.com/deployphp/deployer/releases/download/v7.5.12/deployer.phar,https://deployer.org/releases/v7.5.12/deployer.phar deployer'}
|
||||||
${'3.2.1'} | ${'Version missing in deployer manifest'}
|
${'6.8.0'} | ${'https://github.com/deployphp/deployer/releases/download/v6.8.0/deployer.phar,https://deployer.org/releases/v6.8.0/deployer.phar deployer'}
|
||||||
`('checking addDeployer: $version', async ({version, url}) => {
|
`('checking addDeployer: $version', async ({version, url}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
tool: 'deployer',
|
tool: 'deployer',
|
||||||
domain: 'https://deployer.org',
|
domain: 'https://deployer.org',
|
||||||
|
repository: 'deployphp/deployer',
|
||||||
|
version_prefix: 'v',
|
||||||
version: version
|
version: version
|
||||||
});
|
});
|
||||||
expect(await tools.addDeployer(data)).toContain(url);
|
expect(await tools.addDeployer(data)).toContain(url);
|
||||||
@@ -779,7 +777,7 @@ describe('Tools tests', () => {
|
|||||||
'blackfire-player is not a windows tool',
|
'blackfire-player is not a windows tool',
|
||||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
||||||
'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||||
'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
|
'Add-Tool https://github.com/deployphp/deployer/releases/latest/download/deployer.phar,https://deployer.org/deployer.phar deployer "-V"',
|
||||||
'Tool does_not_exist is not supported',
|
'Tool does_not_exist is not supported',
|
||||||
'Add-ComposerTool flex flex symfony/ global',
|
'Add-ComposerTool flex flex symfony/ global',
|
||||||
'Add-Mago',
|
'Add-Mago',
|
||||||
@@ -865,19 +863,20 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
tools_csv | os | script
|
tools_csv | os | script
|
||||||
${'phpunit:9.5.0@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_tool https://phar.phpunit.de/phpunit-9.5.0.phar,https://phar.phpunit.de/phpunit-9.phar phpunit "--version" sha256:' + 'a'.repeat(64)}
|
${'phpunit:9.5.0@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_tool https://phar.phpunit.de/phpunit-9.5.0.phar,https://phar.phpunit.de/phpunit-9.phar phpunit "--version" sha256:' + 'a'.repeat(64)}
|
||||||
${'phpunit:9.5.0@sha256:' + 'a'.repeat(64)} | ${'win32'} | ${'Add-Tool https://phar.phpunit.de/phpunit-9.5.0.phar,https://phar.phpunit.de/phpunit-9.phar phpunit "--version" sha256:' + 'a'.repeat(64)}
|
${'phpunit:9.5.0@sha256:' + 'a'.repeat(64)} | ${'win32'} | ${'Add-Tool https://phar.phpunit.de/phpunit-9.5.0.phar,https://phar.phpunit.de/phpunit-9.phar phpunit "--version" sha256:' + 'a'.repeat(64)}
|
||||||
${'composer:2.9.8@sha256:' + 'b'.repeat(64)} | ${'linux'} | ${'composer 2.9.8 sha256:' + 'b'.repeat(64)}
|
${'composer:2.9.8@sha256:' + 'b'.repeat(64)} | ${'linux'} | ${'composer 2.9.8 sha256:' + 'b'.repeat(64)}
|
||||||
${'cs2pr:1.2.3@sha256:' + 'd'.repeat(64)} | ${'linux'} | ${'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V" sha256:' + 'd'.repeat(64)}
|
${'cs2pr:1.2.3@sha256:' + 'd'.repeat(64)} | ${'linux'} | ${'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V" sha256:' + 'd'.repeat(64)}
|
||||||
${'phive:0.15.3@sha512:' + 'c'.repeat(128)} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status" sha512:' + 'c'.repeat(128)}
|
${'deployer:7.5.12@sha256:' + 'e'.repeat(64)} | ${'linux'} | ${'add_tool https://github.com/deployphp/deployer/releases/download/v7.5.12/deployer.phar,https://deployer.org/releases/v7.5.12/deployer.phar deployer "-V" sha256:' + 'e'.repeat(64)}
|
||||||
${'phinx:1.2.3@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "phinx" "Checksum verification is not supported for phinx"'}
|
${'phive:0.15.3@sha512:' + 'c'.repeat(128)} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status" sha512:' + 'c'.repeat(128)}
|
||||||
${'pecl:1.2.3@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "pecl" "Checksum verification is not supported for pecl"'}
|
${'phinx:1.2.3@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "phinx" "Checksum verification is not supported for phinx"'}
|
||||||
${'phpunit:9.5.0@sha256:invalid'} | ${'linux'} | ${'add_log "$cross" "phpunit" "Invalid sha256 checksum, expected 64 hexadecimal characters"'}
|
${'pecl:1.2.3@sha256:' + 'a'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "pecl" "Checksum verification is not supported for pecl"'}
|
||||||
${'composer:2.9.8@SHA256:' + 'b'.repeat(64)} | ${'linux'} | ${'composer 2.9.8 sha256:' + 'b'.repeat(64)}
|
${'phpunit:9.5.0@sha256:invalid'} | ${'linux'} | ${'add_log "$cross" "phpunit" "Invalid sha256 checksum, expected 64 hexadecimal characters"'}
|
||||||
${'composer:2.9.8@sha384:' + 'b'.repeat(96)} | ${'linux'} | ${'add_log "$cross" "composer" "Unsupported checksum algorithm sha384, expected sha256 or sha512"'}
|
${'composer:2.9.8@SHA256:' + 'b'.repeat(64)} | ${'linux'} | ${'composer 2.9.8 sha256:' + 'b'.repeat(64)}
|
||||||
${'composer:2.9.8@md5:' + 'b'.repeat(32)} | ${'linux'} | ${'add_log "$cross" "composer" "Unsupported checksum algorithm md5, expected sha256 or sha512"'}
|
${'composer:2.9.8@sha384:' + 'b'.repeat(96)} | ${'linux'} | ${'add_log "$cross" "composer" "Unsupported checksum algorithm sha384, expected sha256 or sha512"'}
|
||||||
${'composer:2.9.8@sha256' + 'b'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "composer" "Invalid checksum syntax, expected @sha256:<hash> or @sha512:<hash>"'}
|
${'composer:2.9.8@md5:' + 'b'.repeat(32)} | ${'linux'} | ${'add_log "$cross" "composer" "Unsupported checksum algorithm md5, expected sha256 or sha512"'}
|
||||||
|
${'composer:2.9.8@sha256' + 'b'.repeat(64)} | ${'linux'} | ${'add_log "$cross" "composer" "Invalid checksum syntax, expected @sha256:<hash> or @sha512:<hash>"'}
|
||||||
`(
|
`(
|
||||||
'checking addTools with checksum: $tools_csv, $os',
|
'checking addTools with checksum: $tools_csv, $os',
|
||||||
async ({tools_csv, os, script}) => {
|
async ({tools_csv, os, script}) => {
|
||||||
|
|||||||
+11
-31
@@ -156,14 +156,6 @@ interface GitHubRef {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deployer manifest entry
|
|
||||||
*/
|
|
||||||
interface DeployerManifestEntry {
|
|
||||||
version: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function skipGitHubAuthForComposerVersion(version: string): boolean {
|
export function skipGitHubAuthForComposerVersion(version: string): boolean {
|
||||||
if (!/^\d+\.\d+\.\d+(?:-[\w-]+)?$/.test(version)) {
|
if (!/^\d+\.\d+\.\d+(?:-[\w-]+)?$/.test(version)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -545,29 +537,17 @@ export async function addComposer(data: ToolData): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addDeployer(data: ToolData): Promise<string> {
|
export async function addDeployer(data: ToolData): Promise<string> {
|
||||||
if (data.version === 'latest') {
|
const github_url = await getUrl({
|
||||||
data.url = data.domain + '/deployer.phar';
|
...data,
|
||||||
} else {
|
domain: data.github,
|
||||||
const manifest = await fetch.fetch('https://deployer.org/manifest.json');
|
prefix: 'releases',
|
||||||
const version_data: Record<string, DeployerManifestEntry> = JSON.parse(
|
verb: 'download'
|
||||||
manifest.data
|
});
|
||||||
);
|
const source_url =
|
||||||
const version_key: string | undefined = Object.keys(version_data).find(
|
data.version === 'latest'
|
||||||
(key: string) => {
|
? `${data.domain}/deployer.phar`
|
||||||
return version_data[key].version === data.version;
|
: `${data.domain}/releases/v${data.version}/deployer.phar`;
|
||||||
}
|
data.url = `${github_url},${source_url}`;
|
||||||
);
|
|
||||||
if (version_key) {
|
|
||||||
data.url = version_data[version_key].url;
|
|
||||||
} else {
|
|
||||||
return await utils.addLog(
|
|
||||||
'$cross',
|
|
||||||
'deployer',
|
|
||||||
'Version missing in deployer manifest',
|
|
||||||
data.os
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user