mirror of https://github.com/actions/setup-python
Compare commits
1 Commits
a8303a29ae
...
36885b60d3
Author | SHA1 | Date |
---|---|---|
John Wesley Walker III | 36885b60d3 |
|
@ -13,7 +13,6 @@ import {
|
||||||
getVersionInputFromPlainFile,
|
getVersionInputFromPlainFile,
|
||||||
getVersionInputFromTomlFile,
|
getVersionInputFromTomlFile,
|
||||||
getNextPageUrl,
|
getNextPageUrl,
|
||||||
isGhes,
|
|
||||||
IS_WINDOWS,
|
IS_WINDOWS,
|
||||||
getDownloadFileName
|
getDownloadFileName
|
||||||
} from '../src/utils';
|
} from '../src/utils';
|
||||||
|
@ -196,41 +195,3 @@ describe('getDownloadFileName', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isGhes', () => {
|
|
||||||
const pristineEnv = process.env;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.resetModules();
|
|
||||||
process.env = {...pristineEnv};
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
process.env = pristineEnv;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
|
|
||||||
delete process.env['GITHUB_SERVER_URL'];
|
|
||||||
expect(isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
|
||||||
expect(isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
|
||||||
expect(isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
|
||||||
expect(isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
|
||||||
expect(isGhes()).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
@ -92017,11 +92017,7 @@ function validatePythonVersionFormatForPyPy(version) {
|
||||||
exports.validatePythonVersionFormatForPyPy = validatePythonVersionFormatForPyPy;
|
exports.validatePythonVersionFormatForPyPy = validatePythonVersionFormatForPyPy;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
const isGitHubHost = hostname === 'GITHUB.COM';
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
|
||||||
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
|
|
10
src/utils.ts
10
src/utils.ts
|
@ -117,12 +117,12 @@ export function isGhes(): boolean {
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||||
const isGitHubHost = hostname === 'GITHUB.COM';
|
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM')
|
||||||
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
const isLocalHost = hostname.endsWith('.LOCALHOST')
|
||||||
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
|
|
Loading…
Reference in New Issue