fix: automatically detect if using GitHub enterprise (#1356)

This commit is contained in:
Tom Hu
2024-04-05 11:12:44 -07:00
committed by GitHub
parent 7afa10ed9b
commit 55e8381a3e
4 changed files with 66 additions and 14 deletions

View File

@@ -7,9 +7,19 @@ import {
buildUploadExec,
} from './buildExec';
const context = github.context;
let OLDOS = process.env.RUNNER_OS;
beforeEach(() => {
jest.resetModules();
OLDOS = process.env.RUNNER_OS;
});
afterAll(() => {
process.env.RUNNER_OS = OLDOS;
});
test('general args', async () => {
const envs = {
codecov_yml_path: 'dev/codecov.yml',
@@ -271,3 +281,23 @@ test('commit args using context', async () => {
expect(commitExecArgs).toEqual(expectedArgs);
expect(commitCommand).toEqual('create-commit');
});
test('commit args using github server url', async () => {
const expectedArgs :string[] = [
'--git-service',
'github_enterprise',
];
process.env.GITHUB_SERVER_URL = 'https://example.com';
const {commitExecArgs, commitCommand} = await buildCommitExec();
if (context.eventName == 'pull_request') {
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
}
if (context.eventName == 'pull_request_target') {
expectedArgs.push('-P', `${context.payload.number}`);
}
expect(commitExecArgs).toEqual(expectedArgs);
expect(commitCommand).toEqual('create-commit');
});