Skip to content
Snippets Groups Projects
Unverified Commit 000142e5 authored by Richard Versteeg's avatar Richard Versteeg Committed by GitHub
Browse files

feat(changelogs): Add `github-changelog` and `gitlab-changelog` hosttypes (#13695)

parent 356fdcb3
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,8 @@ import { GitlabPackagesDatasource } from '../datasource/gitlab-packages'; ...@@ -5,6 +5,8 @@ import { GitlabPackagesDatasource } from '../datasource/gitlab-packages';
import { GitlabReleasesDatasource } from '../datasource/gitlab-releases'; import { GitlabReleasesDatasource } from '../datasource/gitlab-releases';
import { id as GL_TAGS_DS } from '../datasource/gitlab-tags'; import { id as GL_TAGS_DS } from '../datasource/gitlab-tags';
import { id as POD_DS } from '../datasource/pod'; 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 { import {
BITBUCKET_API_USING_HOST_TYPES, BITBUCKET_API_USING_HOST_TYPES,
GITHUB_API_USING_HOST_TYPES, GITHUB_API_USING_HOST_TYPES,
...@@ -21,6 +23,9 @@ describe('constants/platform', () => { ...@@ -21,6 +23,9 @@ describe('constants/platform', () => {
expect( expect(
GITLAB_API_USING_HOST_TYPES.includes(GitlabPackagesDatasource.id) GITLAB_API_USING_HOST_TYPES.includes(GitlabPackagesDatasource.id)
).toBeTrue(); ).toBeTrue();
expect(
GITLAB_API_USING_HOST_TYPES.includes(GITLAB_CHANGELOG_ID)
).toBeTrue();
expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeTrue(); expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeTrue();
}); });
...@@ -32,6 +37,9 @@ describe('constants/platform', () => { ...@@ -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_TAGS_DS)).toBeTrue();
expect(GITHUB_API_USING_HOST_TYPES.includes(GH_RELEASES_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(POD_DS)).toBeTrue();
expect(
GITHUB_API_USING_HOST_TYPES.includes(GITHUB_CHANGELOG_ID)
).toBeTrue();
expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeTrue(); expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeTrue();
}); });
......
...@@ -13,6 +13,7 @@ export const GITHUB_API_USING_HOST_TYPES = [ ...@@ -13,6 +13,7 @@ export const GITHUB_API_USING_HOST_TYPES = [
'github-releases', 'github-releases',
'github-tags', 'github-tags',
'pod', 'pod',
'github-changelog',
]; ];
export const GITLAB_API_USING_HOST_TYPES = [ export const GITLAB_API_USING_HOST_TYPES = [
...@@ -20,6 +21,7 @@ export const GITLAB_API_USING_HOST_TYPES = [ ...@@ -20,6 +21,7 @@ export const GITLAB_API_USING_HOST_TYPES = [
'gitlab-releases', 'gitlab-releases',
'gitlab-tags', 'gitlab-tags',
'gitlab-packages', 'gitlab-packages',
'gitlab-changelog',
]; ];
export const BITBUCKET_API_USING_HOST_TYPES = [ export const BITBUCKET_API_USING_HOST_TYPES = [
......
...@@ -39,12 +39,6 @@ describe('util/http/host-rules', () => { ...@@ -39,12 +39,6 @@ describe('util/http/host-rules', () => {
token: 'abc', token: 'abc',
}); });
hostRules.add({
hostType: 'github-releases',
username: 'some',
password: 'xxx',
});
hostRules.add({ hostRules.add({
hostType: PlatformId.Bitbucket, hostType: PlatformId.Bitbucket,
token: 'cdef', token: 'cdef',
...@@ -135,7 +129,25 @@ describe('util/http/host-rules', () => { ...@@ -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( expect(
applyHostRules(url, { ...options, hostType: 'github-releases' }) applyHostRules(url, { ...options, hostType: 'github-releases' })
).toEqual({ ).toEqual({
...@@ -143,19 +155,57 @@ describe('util/http/host-rules', () => { ...@@ -143,19 +155,57 @@ describe('util/http/host-rules', () => {
username: 'some', username: 'some',
password: 'xxx', 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', () => { it('fallback to github', () => {
expect(applyHostRules(url, { ...options, hostType: 'github-tags' })) expect(
.toMatchInlineSnapshot(` applyHostRules(url, { ...options, hostType: 'github-tags' })
Object { ).toEqual({
"context": Object { context: {
"authType": undefined, authType: undefined,
}, },
"hostType": "github-tags", hostType: 'github-tags',
"token": "token", 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', () => { it('no fallback to gitlab', () => {
...@@ -228,6 +278,15 @@ describe('util/http/host-rules', () => { ...@@ -228,6 +278,15 @@ describe('util/http/host-rules', () => {
hostType: 'gitlab-packages', hostType: 'gitlab-packages',
token: 'abc', token: 'abc',
}); });
expect(
applyHostRules(url, { ...options, hostType: 'gitlab-changelog' })
).toEqual({
context: {
authType: undefined,
},
hostType: 'gitlab-changelog',
token: 'abc',
});
}); });
it('no fallback to bitbucket', () => { it('no fallback to bitbucket', () => {
......
...@@ -11,7 +11,8 @@ import { GithubHttp } from '../../../../util/http/github'; ...@@ -11,7 +11,8 @@ import { GithubHttp } from '../../../../util/http/github';
import { ensureTrailingSlash } from '../../../../util/url'; import { ensureTrailingSlash } from '../../../../util/url';
import type { ChangeLogFile, ChangeLogNotes } from '../types'; import type { ChangeLogFile, ChangeLogNotes } from '../types';
const http = new GithubHttp(); export const id = 'github-changelog';
const http = new GithubHttp(id);
export async function getTags( export async function getTags(
endpoint: string, endpoint: string,
......
...@@ -7,7 +7,8 @@ import { GitlabHttp } from '../../../../util/http/gitlab'; ...@@ -7,7 +7,8 @@ import { GitlabHttp } from '../../../../util/http/gitlab';
import { ensureTrailingSlash } from '../../../../util/url'; import { ensureTrailingSlash } from '../../../../util/url';
import type { ChangeLogFile, ChangeLogNotes } from '../types'; import type { ChangeLogFile, ChangeLogNotes } from '../types';
const http = new GitlabHttp(); export const id = 'gitlab-changelog';
const http = new GitlabHttp(id);
export async function getTags( export async function getTags(
endpoint: string, endpoint: string,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment