Loading __tests__/util.test.ts +40 −1 Changes for __tests__/util.test.ts: 40 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ import * as core from '@actions/core'; import { convertVersionToSemver, isVersionSatisfies, isCacheFeatureAvailable isCacheFeatureAvailable, isGhes } from '../src/util'; jest.mock('@actions/cache'); Loading Loading @@ -80,3 +81,41 @@ describe('convertVersionToSemver', () => { expect(actual).toBe(expected); }); }); 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(); }); }); dist/cleanup/index.js +5 −1 Changes for dist/cleanup/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -88552,7 +88552,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { dist/setup/index.js +5 −1 Changes for dist/setup/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -126328,7 +126328,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { src/util.ts +7 −1 Changes for src/util.ts: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -92,7 +92,13 @@ export function isGhes(): boolean { const ghUrl = new URL( process.env['GITHUB_SERVER_URL'] || 'https://github.com' ); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } export function isCacheFeatureAvailable(): boolean { Loading Loading
__tests__/util.test.ts +40 −1 Changes for __tests__/util.test.ts: 40 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ import * as core from '@actions/core'; import { convertVersionToSemver, isVersionSatisfies, isCacheFeatureAvailable isCacheFeatureAvailable, isGhes } from '../src/util'; jest.mock('@actions/cache'); Loading Loading @@ -80,3 +81,41 @@ describe('convertVersionToSemver', () => { expect(actual).toBe(expected); }); }); 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(); }); });
dist/cleanup/index.js +5 −1 Changes for dist/cleanup/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -88552,7 +88552,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() {
dist/setup/index.js +5 −1 Changes for dist/setup/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -126328,7 +126328,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() {
src/util.ts +7 −1 Changes for src/util.ts: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -92,7 +92,13 @@ export function isGhes(): boolean { const ghUrl = new URL( process.env['GITHUB_SERVER_URL'] || 'https://github.com' ); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === 'GITHUB.COM'; const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); const isLocalHost = hostname.endsWith('.LOCALHOST'); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } export function isCacheFeatureAvailable(): boolean { Loading