From 9a93c8e99a48a4412c7c91a73d1814c8051840de Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 7 Mar 2019 15:15:01 +0100 Subject: [PATCH] feat: postUpdateOptions Adds new config option postUpateOptions. Currently supports one value - gomodTidy. --- lib/config/definitions.js | 13 +++++++++---- lib/config/file.js | 1 + lib/config/migration.js | 8 ++++++++ lib/manager/gomod/artifacts.js | 5 ++++- test/config/__snapshots__/migration.spec.js.snap | 3 +++ test/config/migration.spec.js | 1 + .../updates/__snapshots__/flatten.spec.js.snap | 16 ++++++++-------- website/docs/configuration-options.md | 6 ++++-- 8 files changed, 38 insertions(+), 15 deletions(-) diff --git a/lib/config/definitions.js b/lib/config/definitions.js index d992043174..069eece75a 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -1078,10 +1078,15 @@ const options = [ mergeable: true, }, { - name: 'gomodTidy', - description: 'Enable to run `go mod tidy` after Go module updates', - type: 'boolean', - default: false, + name: 'postUpdateOptions', + description: + 'Enable various post-update options to be run after package/artifact updating', + type: 'list', + default: [], + allowedValues: ['gomodTidy'], + cli: false, + env: false, + mergeable: true, }, { name: 'ruby', diff --git a/lib/config/file.js b/lib/config/file.js index 2de271820f..83c1a70a36 100644 --- a/lib/config/file.js +++ b/lib/config/file.js @@ -9,6 +9,7 @@ function getConfig(env) { let configFile = env.RENOVATE_CONFIG_FILE || 'config'; if (!path.isAbsolute(configFile)) { configFile = `${process.cwd()}/${configFile}`; + logger.debug('Checking for config file in ' + configFile); } let config = {}; try { diff --git a/lib/config/migration.js b/lib/config/migration.js index 91bae2918b..1af7663054 100644 --- a/lib/config/migration.js +++ b/lib/config/migration.js @@ -57,6 +57,14 @@ function migrateConfig(config) { ); } delete migratedConfig.pathRules; + } else if (key === 'gomodTidy') { + isMigrated = true; + if (val) { + migratedConfig.postUpdateOptions = + migratedConfig.postUpdateOptions || []; + migratedConfig.postUpdateOptions.push('gomodTidy'); + } + delete migratedConfig.gomodTidy; } else if (key === 'gitFs') { if (val === false) { isMigrated = true; diff --git a/lib/manager/gomod/artifacts.js b/lib/manager/gomod/artifacts.js index 1827baebce..6bf9453df1 100644 --- a/lib/manager/gomod/artifacts.js +++ b/lib/manager/gomod/artifacts.js @@ -79,7 +79,10 @@ async function getArtifacts( 'Generated lockfile' ); // istanbul ignore if - if (config.gomodTidy) { + if ( + config.postUpdateOptions && + config.postUpdateOptions.includes('gomodTidy') + ) { if (config.gitFs) { args = 'mod tidy'; logger.debug({ cmd, args }, 'go mod tidy command'); diff --git a/test/config/__snapshots__/migration.spec.js.snap b/test/config/__snapshots__/migration.spec.js.snap index f5e59e0f9e..762ab39e60 100644 --- a/test/config/__snapshots__/migration.spec.js.snap +++ b/test/config/__snapshots__/migration.spec.js.snap @@ -121,6 +121,9 @@ Object { "patch": Object { "automerge": true, }, + "postUpdateOptions": Array [ + "gomodTidy", + ], "prTitle": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some pr title", "rangeStrategy": "bump", "schedule": "on the first day of the month", diff --git a/test/config/migration.spec.js b/test/config/migration.spec.js index 771bf5b29b..33b9b71da8 100644 --- a/test/config/migration.spec.js +++ b/test/config/migration.spec.js @@ -18,6 +18,7 @@ describe('config/migration', () => { automergeMajor: false, automergeMinor: true, automergePatch: true, + gomodTidy: true, upgradeInRange: true, automergeType: 'branch-push', baseBranch: 'next', diff --git a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap index 9128dd7399..3d77e7d5d9 100644 --- a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap +++ b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap @@ -27,7 +27,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -44,6 +43,7 @@ Array [ "npmrc": null, "packageFile": "package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -125,7 +125,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -142,6 +141,7 @@ Array [ "npmrc": null, "packageFile": "package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -221,7 +221,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -237,6 +236,7 @@ Array [ "npmrc": null, "packageFile": "package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -321,7 +321,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -338,6 +337,7 @@ Array [ "npmrc": null, "packageFile": "backend/package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -417,7 +417,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -433,6 +432,7 @@ Array [ "npmrc": null, "packageFile": "backend/package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -517,7 +517,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}}", @@ -534,6 +533,7 @@ Array [ "npmrc": null, "packageFile": "frontend/package.json", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -615,7 +615,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}} Docker tags", @@ -632,6 +631,7 @@ Array [ "npmrc": null, "packageFile": "Dockerfile", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", @@ -713,7 +713,6 @@ Array [ "gitAuthor": null, "gitFs": null, "gitPrivateKey": null, - "gomodTidy": false, "group": Object { "branchTopic": "{{{groupSlug}}}", "commitMessageTopic": "{{{groupName}}} Docker tags", @@ -730,6 +729,7 @@ Array [ "npmrc": null, "packageFile": "Dockerfile", "platform": "github", + "postUpdateOptions": Array [], "prBodyColumns": Array [ "Package", "Type", diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md index d447b79943..a8400bb730 100644 --- a/website/docs/configuration-options.md +++ b/website/docs/configuration-options.md @@ -247,8 +247,6 @@ Configuration added here applies for all Go-related updates, however currently t Configuration for Go Modules (`go mod`). Supersedes anything in the `go` config object. -## gomodTidy - ## gradle Configuration for Java gradle projects @@ -670,6 +668,10 @@ Add configuration here to change pipenv settings, e.g. to change the file patter Warning: 'pipenv' support is currently in beta, so it is not enabled by default. You will need to configure `{ "pipenv": { "enabled": true }}" to enable. +## postUpdateOptions + +`gomodTidy`: Enable to run `go mod tidy` after Go module updates + ## prBodyColumns Use this array to provide a list of column names you wish to include in the PR tables. -- GitLab