Skip to content

Commit

Permalink
feat: Add configuration option githubTokenWarn (#14902)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
Keysox and rarkins committed Apr 13, 2022
1 parent c220ff0 commit 37d3b1d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ Possible values:
- `ssh`: use SSH URLs provided by the platform for Git
- `endpoint`: ignore URLs provided by the platform and use the configured endpoint directly

## githubTokenWarn

By default, Renovate logs and displays a warning when the `GITHUB_COM_TOKEN` is not set.
By setting `githubTokenWarn` to `false`, Renovate suppresses these warnings on Pull Requests, etc.
Disabling the warning is helpful for self-hosted environments that can't access the `github.com` domain, because the warning is useless in these environments.

## globalExtends

Unlike the `extends` field, which is passed through unresolved to be part of repository config, any presets in `globalExtends` are resolved immediately as part of global config.
Expand Down
1 change: 1 addition & 0 deletions lib/config/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class GlobalConfig {
'dryRun',
'exposeAllEnv',
'executionTimeout',
'githubTokenWarn',
'localDir',
'migratePresets',
'privateKey',
Expand Down
7 changes: 7 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ const options: RenovateOptions[] = [
default: '',
globalOnly: true,
},
{
name: 'githubTokenWarn',
description: 'Display warnings about GitHub token not being set.',
type: 'boolean',
default: true,
globalOnly: true,
},
{
name: 'requireConfig',
description:
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface RepoGlobalConfig {
dryRun?: DryRunConfig;
executionTimeout?: number;
exposeAllEnv?: boolean;
githubTokenWarn?: boolean;
migratePresets?: Record<string, string>;
privateKey?: string;
privateKeyOld?: string;
Expand Down
2 changes: 2 additions & 0 deletions lib/workers/repository/update/pr/changelog/github.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as httpMock from '../../../../../../test/http-mock';
import { GlobalConfig } from '../../../../../config/global';
import { PlatformId } from '../../../../../constants';
import * as semverVersioning from '../../../../../modules/versioning/semver';
import * as hostRules from '../../../../../util/host-rules';
Expand Down Expand Up @@ -203,6 +204,7 @@ describe('workers/repository/update/pr/changelog/github', () => {
});

it('handles missing Github token', async () => {
GlobalConfig.set({ githubTokenWarn: true });
expect(
await getChangeLogJSON({
...upgrade,
Expand Down
2 changes: 2 additions & 0 deletions lib/workers/repository/update/pr/changelog/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as httpMock from '../../../../../../test/http-mock';
import { partial } from '../../../../../../test/util';
import { GlobalConfig } from '../../../../../config/global';
import { PlatformId } from '../../../../../constants';
import * as semverVersioning from '../../../../../modules/versioning/semver';
import * as hostRules from '../../../../../util/host-rules';
Expand Down Expand Up @@ -230,6 +231,7 @@ describe('workers/repository/update/pr/changelog/index', () => {
});

it('handles missing Github token', async () => {
GlobalConfig.set({ githubTokenWarn: true });
expect(
await getChangeLogJSON({
...upgrade,
Expand Down
8 changes: 8 additions & 0 deletions lib/workers/repository/update/pr/changelog/source-github.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import URL from 'url';
import { GlobalConfig } from '../../../../../config/global';
import { PlatformId } from '../../../../../constants';
import { logger } from '../../../../../logger';
import type { Release } from '../../../../../modules/datasource/types';
Expand Down Expand Up @@ -54,6 +55,13 @@ export async function getChangeLogJSON({
// istanbul ignore if
if (!config.token) {
if (host.endsWith('github.com')) {
if (!GlobalConfig.get().githubTokenWarn) {
logger.debug(
{ manager, depName, sourceUrl },
'GitHub token warning has been suppressed. Skipping release notes retrieval'
);
return null;
}
logger.warn(
{ manager, depName, sourceUrl },
'No github.com token has been configured. Skipping release notes retrieval'
Expand Down

0 comments on commit 37d3b1d

Please sign in to comment.