Revise isGhes logic (#511)
Some checks failed
Validate 'setup-go' / stable (macos-latest) (push) Waiting to run
Validate 'setup-go' / stable (windows-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (windows-latest) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.10, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.10, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.3, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.3, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (macos-latest) (push) Waiting to run
Basic validation / Basic validation (push) Failing after 0s
Validate 'setup-go' / go-version-file-with-gowork (windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21.10, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21.10, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.22.3, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.22.3, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (1.20.14, macos-latest) (push) Waiting to run
Check dist/ / Check dist/ (push) Failing after 0s
Validate 'setup-go' / architecture (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (1.21, windows-latest) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (false, 1.20.1) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (true, 1.20.1) (push) Waiting to run
Validate Windows installation / Find default go version (push) Waiting to run
Validate Windows installation / Validate if symlink is not created for default go (false) (push) Blocked by required conditions
Validate Windows installation / Validate if symlink is not created for default go (true) (push) Blocked by required conditions
Validate Windows installation / Validate if hostedtoolcache works as expected (false, 1.20.1) (push) Waiting to run
Licensed / Licensed (push) Failing after 0s
CodeQL analysis / CodeQL analysis (push) Failing after 2s
Validate 'setup-go' / stable (ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / oldstable (ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, oldstable) (push) Failing after 35s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, stable) (push) Failing after 35s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, oldstable) (push) Failing after 35s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, stable) (push) Failing after 35s
Validate 'setup-go' / Setup local-cache version (1.20.14, ubuntu-latest) (push) Failing after 37s
Validate 'setup-go' / Setup local-cache version (1.21.10, ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / Setup local-cache version (1.22.3, ubuntu-latest) (push) Failing after 15s
Validate 'setup-go' / check-latest (1.20.14, ubuntu-latest) (push) Failing after 36s
Validate 'setup-go' / check-latest (1.21, ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / go-version-file (ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / go-version-file-with-gowork (ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21.10, ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.22.3, ubuntu-latest) (push) Failing after 34s
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.20.14, ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / Setup ${{ matrix.go }} ${{ matrix.os }} (1.21, ubuntu-latest) (push) Failing after 34s
Validate 'setup-go' / architecture (1.20.14, ubuntu-latest) (push) Failing after 35s
Validate 'setup-go' / architecture (1.21, ubuntu-latest) (push) Successful in 39m18s

* Revise `isGhes` logic

* ran `npm run format`

* added unit test

* tweaked unit test

* ran `npm run format`
This commit is contained in:
John Wesley Walker III
2024-10-21 18:56:08 +02:00
committed by GitHub
parent d60b41a563
commit 941977282c
4 changed files with 55 additions and 3 deletions

View File

@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => {
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
});
});
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(cacheUtils.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(cacheUtils.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(cacheUtils.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(cacheUtils.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(cacheUtils.isGhes()).toBeTruthy();
});
});