diff --git a/lib/config/definitions.js b/lib/config/definitions.js index d992043174c2eb94c248624b209bf391a5dd8b84..069eece75a5de2491f9342ee0b4c9e01c74ca61c 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 2de271820f4bc997e8cf363e234f1ec9185501d0..83c1a70a36476e14f61c1377498f7e595039bbb3 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 91bae2918b69fd2cb153a774f1e837bd6e474f79..1af7663054d20e8fe71912752fb3c984587c151c 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 1827baebceaecb51f898de3bd9bc5d335db4c9ee..6bf9453df16b97b2d6a3393896ebbcdfd89ecb6f 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 f5e59e0f9ef1292e64378792c03fad05df349778..762ab39e601f01c616b638a349319c9fa5a4e81b 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 771bf5b29bfdac6ba537bcc2bbf3a448f16d7192..33b9b71da81eec9a283814fa701e0e7261ae42fb 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 9128dd7399bc63b91e6a4f71355ad2890b1fe4a3..3d77e7d5d930f1d7c4920b4dd8eb1e9ec6839a27 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 d447b79943d498db6131acb4ba3306398fe9fc24..a8400bb730816c7b1f41708b3549534d842ef0e0 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.