Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(host-rules): call set global host rules before init platform #25521

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/workers/global/initialize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { git, mockedFunction } from '../../../test/util';
import type { AllConfig, RenovateConfig } from '../../config/types';
import { initPlatform as _initPlatform } from '../../modules/platform';
import * as hostRules from '../../util/host-rules';
import { globalInitialize } from './initialize';

jest.mock('../../util/git');
Expand Down Expand Up @@ -39,4 +40,43 @@ describe('workers/global/initialize', () => {
await expect(globalInitialize(config)).toResolve();
});
});

describe('setGlobalHostRules', () => {
beforeEach(() => {
hostRules.clear();
});

it('should have run before initPlatform', async () => {
const hostRule = {
hostType: 'github',
matchHost: 'https://some.github-enterprise.host',
httpsPrivateKey: 'private-key',
httpsCertificate: 'certificate',
httpsCertificateAuthority: 'certificate-authority',
};

initPlatform.mockReset();
initPlatform.mockImplementationOnce((r) => {
const foundRule = hostRules.find({
hostType: hostRule.hostType,
url: hostRule.matchHost,
});

expect(foundRule.httpsPrivateKey).toEqual(hostRule.httpsPrivateKey);
expect(foundRule.httpsCertificateAuthority).toEqual(
hostRule.httpsCertificateAuthority
);
expect(foundRule.httpsCertificate).toEqual(hostRule.httpsCertificate);

return Promise.resolve(r);
});

const config: RenovateConfig = {
hostRules: [hostRule],
};

git.validateGitVersion.mockResolvedValueOnce(true);
await expect(globalInitialize(config)).toResolve();
});
});
});
1 change: 1 addition & 0 deletions lib/workers/global/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export async function globalInitialize(
): Promise<RenovateConfig> {
let config = config_;
await checkVersions();
setGlobalHostRules(config);
config = await initPlatform(config);
config = await setDirectories(config);
await packageCache.init(config);
Expand Down