feat(changelogs): Add `github-changelog` and `gitlab-changelog` hosttypes (#13695)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Родитель
356fdcb3f5
Коммит
000142e5d5
|
@ -5,6 +5,8 @@ import { GitlabPackagesDatasource } from '../datasource/gitlab-packages';
|
|||
import { GitlabReleasesDatasource } from '../datasource/gitlab-releases';
|
||||
import { id as GL_TAGS_DS } from '../datasource/gitlab-tags';
|
||||
import { id as POD_DS } from '../datasource/pod';
|
||||
import { id as GITHUB_CHANGELOG_ID } from '../workers/pr/changelog/github';
|
||||
import { id as GITLAB_CHANGELOG_ID } from '../workers/pr/changelog/gitlab';
|
||||
import {
|
||||
BITBUCKET_API_USING_HOST_TYPES,
|
||||
GITHUB_API_USING_HOST_TYPES,
|
||||
|
@ -21,6 +23,9 @@ describe('constants/platform', () => {
|
|||
expect(
|
||||
GITLAB_API_USING_HOST_TYPES.includes(GitlabPackagesDatasource.id)
|
||||
).toBeTrue();
|
||||
expect(
|
||||
GITLAB_API_USING_HOST_TYPES.includes(GITLAB_CHANGELOG_ID)
|
||||
).toBeTrue();
|
||||
expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeTrue();
|
||||
});
|
||||
|
||||
|
@ -32,6 +37,9 @@ describe('constants/platform', () => {
|
|||
expect(GITHUB_API_USING_HOST_TYPES.includes(GH_TAGS_DS)).toBeTrue();
|
||||
expect(GITHUB_API_USING_HOST_TYPES.includes(GH_RELEASES_DS)).toBeTrue();
|
||||
expect(GITHUB_API_USING_HOST_TYPES.includes(POD_DS)).toBeTrue();
|
||||
expect(
|
||||
GITHUB_API_USING_HOST_TYPES.includes(GITHUB_CHANGELOG_ID)
|
||||
).toBeTrue();
|
||||
expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeTrue();
|
||||
});
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ export const GITHUB_API_USING_HOST_TYPES = [
|
|||
'github-releases',
|
||||
'github-tags',
|
||||
'pod',
|
||||
'github-changelog',
|
||||
];
|
||||
|
||||
export const GITLAB_API_USING_HOST_TYPES = [
|
||||
|
@ -20,6 +21,7 @@ export const GITLAB_API_USING_HOST_TYPES = [
|
|||
'gitlab-releases',
|
||||
'gitlab-tags',
|
||||
'gitlab-packages',
|
||||
'gitlab-changelog',
|
||||
];
|
||||
|
||||
export const BITBUCKET_API_USING_HOST_TYPES = [
|
||||
|
|
|
@ -39,12 +39,6 @@ describe('util/http/host-rules', () => {
|
|||
token: 'abc',
|
||||
});
|
||||
|
||||
hostRules.add({
|
||||
hostType: 'github-releases',
|
||||
username: 'some',
|
||||
password: 'xxx',
|
||||
});
|
||||
|
||||
hostRules.add({
|
||||
hostType: PlatformId.Bitbucket,
|
||||
token: 'cdef',
|
||||
|
@ -135,7 +129,25 @@ describe('util/http/host-rules', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('no fallback', () => {
|
||||
it('no fallback to github', () => {
|
||||
hostRules.add({
|
||||
hostType: 'github-tags',
|
||||
username: 'some2',
|
||||
password: 'xxx2',
|
||||
});
|
||||
hostRules.add({
|
||||
hostType: 'github-changelog',
|
||||
token: 'changelogtoken',
|
||||
});
|
||||
hostRules.add({
|
||||
hostType: 'pod',
|
||||
token: 'pod-token',
|
||||
});
|
||||
hostRules.add({
|
||||
hostType: 'github-releases',
|
||||
username: 'some',
|
||||
password: 'xxx',
|
||||
});
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'github-releases' })
|
||||
).toEqual({
|
||||
|
@ -143,19 +155,57 @@ describe('util/http/host-rules', () => {
|
|||
username: 'some',
|
||||
password: 'xxx',
|
||||
});
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'github-tags' })
|
||||
).toEqual({
|
||||
hostType: 'github-tags',
|
||||
username: 'some2',
|
||||
password: 'xxx2',
|
||||
});
|
||||
expect(applyHostRules(url, { ...options, hostType: 'pod' })).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'pod',
|
||||
token: 'pod-token',
|
||||
});
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'github-changelog' })
|
||||
).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'github-changelog',
|
||||
token: 'changelogtoken',
|
||||
});
|
||||
});
|
||||
|
||||
it('fallback to github', () => {
|
||||
expect(applyHostRules(url, { ...options, hostType: 'github-tags' }))
|
||||
.toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"context": Object {
|
||||
"authType": undefined,
|
||||
},
|
||||
"hostType": "github-tags",
|
||||
"token": "token",
|
||||
}
|
||||
`);
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'github-tags' })
|
||||
).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'github-tags',
|
||||
token: 'token',
|
||||
});
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'github-changelog' })
|
||||
).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'github-changelog',
|
||||
token: 'token',
|
||||
});
|
||||
expect(applyHostRules(url, { ...options, hostType: 'pod' })).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'pod',
|
||||
token: 'token',
|
||||
});
|
||||
});
|
||||
|
||||
it('no fallback to gitlab', () => {
|
||||
|
@ -228,6 +278,15 @@ describe('util/http/host-rules', () => {
|
|||
hostType: 'gitlab-packages',
|
||||
token: 'abc',
|
||||
});
|
||||
expect(
|
||||
applyHostRules(url, { ...options, hostType: 'gitlab-changelog' })
|
||||
).toEqual({
|
||||
context: {
|
||||
authType: undefined,
|
||||
},
|
||||
hostType: 'gitlab-changelog',
|
||||
token: 'abc',
|
||||
});
|
||||
});
|
||||
|
||||
it('no fallback to bitbucket', () => {
|
||||
|
|
|
@ -11,7 +11,8 @@ import { GithubHttp } from '../../../../util/http/github';
|
|||
import { ensureTrailingSlash } from '../../../../util/url';
|
||||
import type { ChangeLogFile, ChangeLogNotes } from '../types';
|
||||
|
||||
const http = new GithubHttp();
|
||||
export const id = 'github-changelog';
|
||||
const http = new GithubHttp(id);
|
||||
|
||||
export async function getTags(
|
||||
endpoint: string,
|
||||
|
|
|
@ -7,7 +7,8 @@ import { GitlabHttp } from '../../../../util/http/gitlab';
|
|||
import { ensureTrailingSlash } from '../../../../util/url';
|
||||
import type { ChangeLogFile, ChangeLogNotes } from '../types';
|
||||
|
||||
const http = new GitlabHttp();
|
||||
export const id = 'gitlab-changelog';
|
||||
const http = new GitlabHttp(id);
|
||||
|
||||
export async function getTags(
|
||||
endpoint: string,
|
||||
|
|
Загрузка…
Ссылка в новой задаче