diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 09dc38bc540f13ee708c1333f8cd64f9c590aa9f..abf13a2eaea6853e5a3bfd6a7a1b346eca8e234f 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -3378,6 +3378,7 @@ Table with options: | `gomodTidy1.17` | Run `go mod tidy -compat=1.17` after Go module updates. | | `gomodTidyE` | Run `go mod tidy -e` after Go module updates. | | `gomodUpdateImportPaths` | Update source import paths on major module updates, using [mod](https://github.com/marwan-at-work/mod). | +| `gomodSkipVendor` | Never run `go mod vendor` after Go module updates. | | `helmUpdateSubChartArchives` | Update subchart archives in the `/charts` folder. | | `npmDedupe` | Run `npm install` with `--prefer-dedupe` for npm >= 7 or `npm dedupe` after `package-lock.json` update for npm <= 6. | | `pnpmDedupe` | Run `pnpm dedupe --config.ignore-scripts=true` after `pnpm-lock.yaml` updates. | diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 62a8c89ec25b926d442cbf0ba771785d0d3fa777..9d921620150a4e35d472daed90b5dc90873696b0 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2508,6 +2508,7 @@ const options: RenovateOptions[] = [ 'gomodTidy1.17', 'gomodTidyE', 'gomodUpdateImportPaths', + 'gomodSkipVendor', 'helmUpdateSubChartArchives', 'npmDedupe', 'pnpmDedupe', diff --git a/lib/modules/manager/gomod/artifacts.spec.ts b/lib/modules/manager/gomod/artifacts.spec.ts index d584ed2dbdf93d75f8cbc1ebf72702a87fe59440..9246997792a3f29200db86bba279a8ecb8f24eff 100644 --- a/lib/modules/manager/gomod/artifacts.spec.ts +++ b/lib/modules/manager/gomod/artifacts.spec.ts @@ -278,6 +278,56 @@ describe('modules/manager/gomod/artifacts', () => { ]); }); + it('skips vendor directory update with gomodSkipVendor', async () => { + const foo = join('vendor/github.com/foo/foo/go.mod'); + const bar = join('vendor/github.com/bar/bar/go.mod'); + const baz = join('vendor/github.com/baz/baz/go.mod'); + + fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); + const execSnapshots = mockExecAll(); + git.getRepoStatus.mockResolvedValueOnce( + partial<StatusResult>({ + modified: ['go.sum', foo], + not_added: [bar], + deleted: [baz], + }), + ); + fs.readLocalFile.mockResolvedValueOnce('New go.sum'); + fs.readLocalFile.mockResolvedValueOnce('New go.mod'); + const res = await gomod.updateArtifacts({ + packageFileName: 'go.mod', + updatedDeps: [], + newPackageFileContent: gomod1, + config: { + ...config, + postUpdateOptions: ['gomodSkipVendor'], + }, + }); + expect(res).toEqual([ + { + file: { + contents: 'New go.sum', + path: 'go.sum', + type: 'addition', + }, + }, + { + file: { + contents: 'New go.mod', + path: 'go.mod', + type: 'addition', + }, + }, + ]); + + expect(execSnapshots).toMatchObject([ + { + cmd: 'go get -d -t ./...', + options: { cwd: '/tmp/github/some/repo' }, + }, + ]); + }); + it('supports vendor directory update with go.work', async () => { const foo = join('vendor/github.com/foo/foo/go.mod'); const bar = join('vendor/github.com/bar/bar/go.mod'); diff --git a/lib/modules/manager/gomod/artifacts.ts b/lib/modules/manager/gomod/artifacts.ts index ad9b0447461b02595efba0cd60b42af259164aaf..bf5f65a41d1920eab605c2b3c67d54b3442f865c 100644 --- a/lib/modules/manager/gomod/artifacts.ts +++ b/lib/modules/manager/gomod/artifacts.ts @@ -133,7 +133,9 @@ export async function updateArtifacts({ const vendorDir = upath.join(goModDir, 'vendor/'); const vendorModulesFileName = upath.join(vendorDir, 'modules.txt'); - const useVendor = (await readLocalFile(vendorModulesFileName)) !== null; + const useVendor = + !config.postUpdateOptions?.includes('gomodSkipVendor') && + (await readLocalFile(vendorModulesFileName)) !== null; let massagedGoMod = newGoModContent;