mirror of
https://github.com/renovatebot/renovate.git
synced 2025-03-14 08:12:56 +00:00
test: prepare buildpack (#17212)
This commit is contained in:
parent
13642350c9
commit
b2e763e012
5 changed files with 784 additions and 1509 deletions
lib/modules/manager
composer
gomod
|
@ -1,387 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`modules/manager/composer/artifacts adds all ignorePlatformReq items 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-req ext-posix --ignore-platform-req ext-sodium --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts catches errors 1`] = `
|
||||
[
|
||||
{
|
||||
"artifactError": {
|
||||
"lockFile": "composer.lock",
|
||||
"stderr": "not found",
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts catches unmet requirements errors 1`] = `
|
||||
[
|
||||
{
|
||||
"artifactError": {
|
||||
"lockFile": "composer.lock",
|
||||
"stderr": "fooYour requirements could not be resolved to an installable set of packages.bar",
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts disable plugins when configured locally 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts disables ignorePlatformReqs 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts does not disable plugins when configured globally 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts installs before running the update when symfony flex is installed 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer install --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts installs before running the update when symfony flex is installed as dev 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer install --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts performs lockFileMaintenance 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts returns null if unchanged 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts returns updated composer.lock 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts supports docker mode 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "docker pull renovate/php:7.3",
|
||||
"options": {
|
||||
"encoding": "utf-8",
|
||||
},
|
||||
},
|
||||
{
|
||||
"cmd": "docker ps --filter name=renovate_php -aq",
|
||||
"options": {
|
||||
"encoding": "utf-8",
|
||||
},
|
||||
},
|
||||
{
|
||||
"cmd": "docker run --rm --name=renovate_php --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e COMPOSER_CACHE_DIR -e BUILDPACK_CACHE_DIR -w "/tmp/github/some/repo" renovate/php:7.3 bash -l -c "install-tool composer 1.10.17 && composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins"",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"BUILDPACK_CACHE_DIR": "/tmp/renovate/cache/buildpack",
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts supports global mode 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts supports vendor directory update 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`modules/manager/composer/artifacts uses hostRules to set COMPOSER_AUTH 1`] = `
|
||||
[
|
||||
{
|
||||
"cmd": "composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins",
|
||||
"options": {
|
||||
"cwd": "/tmp/github/some/repo",
|
||||
"encoding": "utf-8",
|
||||
"env": {
|
||||
"COMPOSER_AUTH": "{"github-oauth":{"github.com":"github-token"},"gitlab-token":{"gitlab.com":"gitlab-token"},"gitlab-domains":["gitlab.com"],"http-basic":{"packagist.renovatebot.com":{"username":"some-username","password":"some-password"},"artifactory.yyyyyyy.com":{"username":"some-other-username","password":"some-other-password"}},"bearer":{"packages-bearer.example.com":"abcdef0123456789"}}",
|
||||
"COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer",
|
||||
"HOME": "/home/user",
|
||||
"HTTPS_PROXY": "https://example.com",
|
||||
"HTTP_PROXY": "http://example.com",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
|
@ -17,6 +17,8 @@ jest.mock('../../datasource');
|
|||
jest.mock('../../../util/fs');
|
||||
jest.mock('../../../util/git');
|
||||
|
||||
process.env.BUILDPACK = 'true';
|
||||
|
||||
const datasource = mocked(_datasource);
|
||||
|
||||
const config: UpdateArtifactsConfig = {
|
||||
|
@ -93,7 +95,17 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
config,
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
COMPOSER_CACHE_DIR: '/tmp/renovate/cache/others/composer',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('uses hostRules to set COMPOSER_AUTH', async () => {
|
||||
|
@ -145,7 +157,19 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
config: authConfig,
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
COMPOSER_AUTH:
|
||||
'{"github-oauth":{"github.com":"github-token"},"gitlab-token":{"gitlab.com":"gitlab-token"},"gitlab-domains":["gitlab.com"],"http-basic":{"packagist.renovatebot.com":{"username":"some-username","password":"some-password"},"artifactory.yyyyyyy.com":{"username":"some-other-username","password":"some-other-password"}},"bearer":{"packages-bearer.example.com":"abcdef0123456789"}}',
|
||||
COMPOSER_CACHE_DIR: '/tmp/renovate/cache/others/composer',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns updated composer.lock', async () => {
|
||||
|
@ -163,8 +187,21 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{}',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports vendor directory update', async () => {
|
||||
|
@ -190,14 +227,42 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config,
|
||||
});
|
||||
expect(res).not.toBeNull();
|
||||
expect(res?.map(({ file }) => file)).toEqual([
|
||||
{ type: 'addition', path: 'composer.lock', contents: '{ }' },
|
||||
{ type: 'addition', path: foo, contents: 'Foo' },
|
||||
{ type: 'addition', path: bar, contents: 'Bar' },
|
||||
{ type: 'deletion', path: baz },
|
||||
expect(res).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
contents: 'Foo',
|
||||
path: 'vendor/foo/Foo.php',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
contents: 'Bar',
|
||||
path: 'vendor/bar/Bar.php',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
path: 'vendor/baz/Baz.php',
|
||||
type: 'deletion',
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('performs lockFileMaintenance', async () => {
|
||||
|
@ -218,8 +283,21 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
isLockFileMaintenance: true,
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo', encoding: 'utf-8' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports docker mode', async () => {
|
||||
|
@ -252,9 +330,107 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config: { ...config, constraints: { composer: '^1.10.0', php: '7.3' } },
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toHaveLength(3);
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'docker pull renovate/php:7.3',
|
||||
options: {
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
},
|
||||
{
|
||||
cmd: 'docker ps --filter name=renovate_php -aq',
|
||||
options: {
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
},
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_php --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/renovate/cache":"/tmp/renovate/cache" ' +
|
||||
'-e COMPOSER_CACHE_DIR ' +
|
||||
'-e BUILDPACK_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'renovate/php:7.3' +
|
||||
' bash -l -c "' +
|
||||
'install-tool composer 1.10.17' +
|
||||
' && ' +
|
||||
'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins' +
|
||||
'"',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
BUILDPACK_CACHE_DIR: '/tmp/renovate/cache/buildpack',
|
||||
COMPOSER_CACHE_DIR: '/tmp/renovate/cache/others/composer',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports install mode', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'install' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||
|
||||
const execSnapshots = mockExecAll();
|
||||
|
||||
fs.readLocalFile.mockResolvedValueOnce('{ }');
|
||||
|
||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||
releases: [
|
||||
{ version: '7.2.34' },
|
||||
{ version: '7.3' }, // composer versioning bug
|
||||
{ version: '7.3.29' },
|
||||
{ version: '7.4.22' },
|
||||
{ version: '8.0.6' },
|
||||
],
|
||||
});
|
||||
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
...repoStatus,
|
||||
modified: ['composer.lock'],
|
||||
});
|
||||
|
||||
expect(
|
||||
await composer.updateArtifacts({
|
||||
packageFileName: 'composer.json',
|
||||
updatedDeps: [],
|
||||
newPackageFileContent: '{}',
|
||||
config: { ...config, constraints: { composer: '^1.10.0', php: '7.3' } },
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'install-tool composer 1.10.17',
|
||||
},
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
BUILDPACK_CACHE_DIR: '/tmp/renovate/cache/buildpack',
|
||||
COMPOSER_CACHE_DIR: '/tmp/renovate/cache/others/composer',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports global mode', async () => {
|
||||
|
@ -273,11 +449,25 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('catches errors', async () => {
|
||||
const execSnapshots = mockExecAll();
|
||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||
fs.writeLocalFile.mockImplementationOnce(() => {
|
||||
throw new Error('not found');
|
||||
|
@ -289,10 +479,19 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config,
|
||||
})
|
||||
).toMatchSnapshot([{ artifactError: { lockFile: 'composer.lock' } }]);
|
||||
).toEqual([
|
||||
{
|
||||
artifactError: {
|
||||
lockFile: 'composer.lock',
|
||||
stderr: 'not found',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toBeEmptyArray();
|
||||
});
|
||||
|
||||
it('catches unmet requirements errors', async () => {
|
||||
const execSnapshots = mockExecAll();
|
||||
const stderr =
|
||||
'fooYour requirements could not be resolved to an installable set of packages.bar';
|
||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||
|
@ -306,12 +505,12 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
newPackageFileContent: '{}',
|
||||
config,
|
||||
})
|
||||
).toMatchSnapshot([
|
||||
{ artifactError: { lockFile: 'composer.lock', stderr } },
|
||||
]);
|
||||
).toEqual([{ artifactError: { lockFile: 'composer.lock', stderr } }]);
|
||||
expect(execSnapshots).toBeEmptyArray();
|
||||
});
|
||||
|
||||
it('throws for disk space', async () => {
|
||||
const execSnapshots = mockExecAll();
|
||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||
fs.writeLocalFile.mockImplementationOnce(() => {
|
||||
throw new Error(
|
||||
|
@ -326,6 +525,7 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
config,
|
||||
})
|
||||
).rejects.toThrow();
|
||||
expect(execSnapshots).toBeEmptyArray();
|
||||
});
|
||||
|
||||
it('disables ignorePlatformReqs', async () => {
|
||||
|
@ -346,8 +546,21 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
composerIgnorePlatformReqs: undefined,
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('adds all ignorePlatformReq items', async () => {
|
||||
|
@ -368,8 +581,21 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
composerIgnorePlatformReqs: ['ext-posix', 'ext-sodium'],
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-req ext-posix --ignore-platform-req ext-sodium --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('installs before running the update when symfony flex is installed', async () => {
|
||||
|
@ -391,9 +617,25 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
...config,
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toHaveLength(2);
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer install --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('installs before running the update when symfony flex is installed as dev', async () => {
|
||||
|
@ -415,9 +657,25 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
...config,
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toHaveLength(2);
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: '{ }',
|
||||
path: 'composer.lock',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer install --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo', encoding: 'utf-8' },
|
||||
},
|
||||
{
|
||||
cmd: 'composer update --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo', encoding: 'utf-8' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not disable plugins when configured globally', async () => {
|
||||
|
@ -434,7 +692,12 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
config,
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('disable plugins when configured locally', async () => {
|
||||
|
@ -454,6 +717,11 @@ describe('modules/manager/composer/artifacts', () => {
|
|||
},
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,8 @@ jest.mock('../../../util/host-rules');
|
|||
jest.mock('../../../util/http');
|
||||
jest.mock('../../../util/fs');
|
||||
|
||||
process.env.BUILDPACK = 'true';
|
||||
|
||||
const hostRules = mocked(_hostRules);
|
||||
|
||||
const gomod1 = `module github.com/renovate-tests/gomod1
|
||||
|
@ -85,13 +87,12 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
config,
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toBeEmptyArray();
|
||||
});
|
||||
|
||||
it('returns null if unchanged', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: [] as string[],
|
||||
|
@ -105,18 +106,34 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
config,
|
||||
})
|
||||
).toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
CGO_ENABLED: '1',
|
||||
GOFLAGS: '-modcacherw',
|
||||
GOINSECURE: 'insecure.example.com/*',
|
||||
GONOPROXY: 'noproxy.example.com/*',
|
||||
GONOSUMDB: '1',
|
||||
GOPRIVATE: 'private.example.com/*',
|
||||
GOPROXY: 'proxy.example.com',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns updated go.sum', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -124,8 +141,32 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
CGO_ENABLED: '1',
|
||||
GOFLAGS: '-modcacherw',
|
||||
GOINSECURE: 'insecure.example.com/*',
|
||||
GONOPROXY: 'noproxy.example.com/*',
|
||||
GONOSUMDB: '1',
|
||||
GOPRIVATE: 'private.example.com/*',
|
||||
GOPROXY: 'proxy.example.com',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports vendor directory update', async () => {
|
||||
|
@ -154,27 +195,77 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
postUpdateOptions: ['gomodTidy'],
|
||||
},
|
||||
});
|
||||
expect(res).not.toBeNull();
|
||||
expect(res?.map(({ file }) => file)).toEqual([
|
||||
{ type: 'addition', path: 'go.sum', contents: 'New go.sum' },
|
||||
{ type: 'addition', path: foo, contents: 'Foo go.sum' },
|
||||
{ type: 'addition', path: bar, contents: 'Bar go.sum' },
|
||||
{ type: 'deletion', path: baz },
|
||||
{ type: 'addition', path: 'go.mod', contents: 'New go.mod' },
|
||||
expect(res).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
contents: 'Foo go.sum',
|
||||
path: 'vendor/github.com/foo/foo/go.mod',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
contents: 'Bar go.sum',
|
||||
path: 'vendor/github.com/bar/bar/go.mod',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
path: 'vendor/github.com/baz/baz/go.mod',
|
||||
type: 'deletion',
|
||||
},
|
||||
},
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.mod',
|
||||
path: 'go.mod',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod vendor',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('supports docker mode without credentials', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -182,20 +273,95 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull renovate/go:latest' },
|
||||
{ cmd: 'docker ps --filter name=renovate_go -aq' },
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_go --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/renovate/cache":"/tmp/renovate/cache" ' +
|
||||
'-e GOPROXY ' +
|
||||
'-e GOPRIVATE ' +
|
||||
'-e GONOPROXY ' +
|
||||
'-e GONOSUMDB ' +
|
||||
'-e GOINSECURE ' +
|
||||
'-e GOFLAGS ' +
|
||||
'-e CGO_ENABLED ' +
|
||||
'-e BUILDPACK_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'renovate/go:latest' +
|
||||
' bash -l -c "' +
|
||||
'go get -d -t ./...' +
|
||||
'"',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
BUILDPACK_CACHE_DIR: '/tmp/renovate/cache/buildpack',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports install mode without credentials', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'install' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
updatedDeps: [],
|
||||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
BUILDPACK_CACHE_DIR: '/tmp/renovate/cache/buildpack',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports global mode', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'global' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -203,8 +369,21 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports docker mode with credentials', async () => {
|
||||
|
@ -221,13 +400,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ token: 'some-other-token', matchHost: 'https://gitea.com' },
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -235,8 +414,75 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull renovate/go:latest' },
|
||||
{ cmd: 'docker ps --filter name=renovate_go -aq' },
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_go --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/renovate/cache":"/tmp/renovate/cache" ' +
|
||||
'-e GOPROXY ' +
|
||||
'-e GOPRIVATE ' +
|
||||
'-e GONOPROXY ' +
|
||||
'-e GONOSUMDB ' +
|
||||
'-e GOINSECURE ' +
|
||||
'-e GOFLAGS ' +
|
||||
'-e CGO_ENABLED ' +
|
||||
'-e GIT_CONFIG_KEY_0 ' +
|
||||
'-e GIT_CONFIG_VALUE_0 ' +
|
||||
'-e GIT_CONFIG_KEY_1 ' +
|
||||
'-e GIT_CONFIG_VALUE_1 ' +
|
||||
'-e GIT_CONFIG_KEY_2 ' +
|
||||
'-e GIT_CONFIG_VALUE_2 ' +
|
||||
'-e GIT_CONFIG_COUNT ' +
|
||||
'-e GIT_CONFIG_KEY_3 ' +
|
||||
'-e GIT_CONFIG_VALUE_3 ' +
|
||||
'-e GIT_CONFIG_KEY_4 ' +
|
||||
'-e GIT_CONFIG_VALUE_4 ' +
|
||||
'-e GIT_CONFIG_KEY_5 ' +
|
||||
'-e GIT_CONFIG_VALUE_5 ' +
|
||||
'-e BUILDPACK_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'renovate/go:latest' +
|
||||
' bash -l -c "' +
|
||||
'go get -d -t ./...' +
|
||||
'"',
|
||||
options: {
|
||||
cwd: '/tmp/github/some/repo',
|
||||
env: {
|
||||
BUILDPACK_CACHE_DIR: '/tmp/renovate/cache/buildpack',
|
||||
GIT_CONFIG_COUNT: '6',
|
||||
GIT_CONFIG_KEY_0:
|
||||
'url.https://ssh:some-token@github.com/.insteadOf',
|
||||
GIT_CONFIG_KEY_1:
|
||||
'url.https://git:some-token@github.com/.insteadOf',
|
||||
GIT_CONFIG_KEY_2: 'url.https://some-token@github.com/.insteadOf',
|
||||
GIT_CONFIG_KEY_3:
|
||||
'url.https://ssh:some-other-token@gitea.com/.insteadOf',
|
||||
GIT_CONFIG_KEY_4:
|
||||
'url.https://git:some-other-token@gitea.com/.insteadOf',
|
||||
GIT_CONFIG_KEY_5:
|
||||
'url.https://some-other-token@gitea.com/.insteadOf',
|
||||
GIT_CONFIG_VALUE_0: 'ssh://git@github.com/',
|
||||
GIT_CONFIG_VALUE_1: 'git@github.com:',
|
||||
GIT_CONFIG_VALUE_2: 'https://github.com/',
|
||||
GIT_CONFIG_VALUE_3: 'ssh://git@gitea.com/',
|
||||
GIT_CONFIG_VALUE_4: 'git@gitea.com:',
|
||||
GIT_CONFIG_VALUE_5: 'https://gitea.com/',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports docker mode with 2 credentials', async () => {
|
||||
|
@ -257,13 +503,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -271,7 +517,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull renovate/go:latest' },
|
||||
{ cmd: 'docker ps --filter name=renovate_go -aq' },
|
||||
|
@ -312,13 +566,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -326,7 +580,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
@ -364,13 +626,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -378,7 +640,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
@ -425,13 +695,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -439,7 +709,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
@ -485,13 +763,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -499,7 +777,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
@ -553,12 +839,13 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
]);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
} as StatusResult);
|
||||
fs.readLocalFile.mockResolvedValueOnce('New go.sum');
|
||||
fs.readLocalFile.mockResolvedValueOnce(gomod1);
|
||||
expect(
|
||||
await gomod.updateArtifacts({
|
||||
packageFileName: 'go.mod',
|
||||
|
@ -566,7 +853,15 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newPackageFileContent: gomod1,
|
||||
config,
|
||||
})
|
||||
).not.toBeNull();
|
||||
).toEqual([
|
||||
{
|
||||
file: {
|
||||
contents: 'New go.sum',
|
||||
path: 'go.sum',
|
||||
type: 'addition',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
@ -592,8 +887,7 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
hostRules.find.mockReturnValueOnce({});
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
|
@ -612,16 +906,25 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
postUpdateOptions: ['gomodTidy'],
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{ file: { contents: 'New go.sum 1', path: 'go.sum', type: 'addition' } },
|
||||
{ file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull renovate/go:latest' },
|
||||
{ cmd: 'docker ps --filter name=renovate_go -aq' },
|
||||
{
|
||||
cmd: 'docker run --rm --name=renovate_go --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e GOPROXY -e GOPRIVATE -e GONOPROXY -e GONOSUMDB -e GOINSECURE -e GOFLAGS -e CGO_ENABLED -e BUILDPACK_CACHE_DIR -w "/tmp/github/some/repo" renovate/go:latest bash -l -c "go get -d -t ./... && go mod tidy && go mod tidy"',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports docker mode with gomodTidy1.17', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
hostRules.find.mockReturnValueOnce({});
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
|
@ -640,15 +943,24 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
postUpdateOptions: ['gomodTidy1.17'],
|
||||
},
|
||||
})
|
||||
).not.toBeNull();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{ file: { contents: 'New go.sum 1', path: 'go.sum', type: 'addition' } },
|
||||
{ file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull renovate/go:latest' },
|
||||
{ cmd: 'docker ps --filter name=renovate_go -aq' },
|
||||
{
|
||||
cmd: 'docker run --rm --name=renovate_go --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e GOPROXY -e GOPRIVATE -e GONOPROXY -e GONOSUMDB -e GOINSECURE -e GOFLAGS -e CGO_ENABLED -e BUILDPACK_CACHE_DIR -w "/tmp/github/some/repo" renovate/go:latest bash -l -c "go get -d -t ./... && go mod tidy -compat=1.17 && go mod tidy -compat=1.17"',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('catches errors', async () => {
|
||||
const execSnapshots = mockExecAll();
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
fs.writeLocalFile.mockImplementationOnce(() => {
|
||||
throw new Error('This update totally doesnt work');
|
||||
});
|
||||
|
@ -667,13 +979,12 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
},
|
||||
},
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toBeEmptyArray();
|
||||
});
|
||||
|
||||
it('updates import paths with gomodUpdateImportPaths', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -699,13 +1010,33 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ file: { type: 'addition', path: 'main.go', contents: 'New main.go' } },
|
||||
{ file: { type: 'addition', path: 'go.mod', contents: 'New go.mod' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go install github.com/marwan-at-work/mod/cmd/mod@latest',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'mod upgrade --mod-name=github.com/google/go-github/v24 -t=28',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('skips updating import paths with gomodUpdateImportPaths on v0 to v1', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -729,13 +1060,17 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ file: { type: 'addition', path: 'go.sum', contents: 'New go.sum' } },
|
||||
{ file: { type: 'addition', path: 'go.mod', contents: 'New go.mod' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('skips gomodTidy without gomodUpdateImportPaths on major update', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -756,14 +1091,21 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
postUpdateOptions: ['gomodTidy'],
|
||||
},
|
||||
})
|
||||
).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{ file: { contents: 'New go.sum', path: 'go.sum', type: 'addition' } },
|
||||
{ file: { contents: 'New main.go', path: 'go.mod', type: 'addition' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not execute go mod tidy when none of gomodTidy and gomodUpdateImportPaths are set', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -783,14 +1125,21 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
newMajor: 28,
|
||||
},
|
||||
})
|
||||
).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
).toEqual([
|
||||
{ file: { contents: 'New go.sum', path: 'go.sum', type: 'addition' } },
|
||||
{ file: { contents: 'New main.go', path: 'go.mod', type: 'addition' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('updates import paths with specific tool version from constraint', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -819,13 +1168,33 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ file: { type: 'addition', path: 'main.go', contents: 'New main.go' } },
|
||||
{ file: { type: 'addition', path: 'go.mod', contents: 'New go.mod' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go install github.com/marwan-at-work/mod/cmd/mod@v1.2.3',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'mod upgrade --mod-name=github.com/google/go-github/v24 -t=28',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('updates import paths with latest tool version on invalid version constraint', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum', 'main.go'],
|
||||
|
@ -854,13 +1223,33 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ file: { type: 'addition', path: 'main.go', contents: 'New main.go' } },
|
||||
{ file: { type: 'addition', path: 'go.mod', contents: 'New go.mod' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go install github.com/marwan-at-work/mod/cmd/mod@latest',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'mod upgrade --mod-name=github.com/google/go-github/v24 -t=28',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('skips updating import paths for gopkg.in dependencies', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current go.sum');
|
||||
// TODO: #7154 can be null
|
||||
fs.readLocalFile.mockResolvedValueOnce(null as never); // vendor modules filename
|
||||
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce({
|
||||
modified: ['go.sum'],
|
||||
|
@ -884,6 +1273,19 @@ describe('modules/manager/gomod/artifacts', () => {
|
|||
{ file: { type: 'addition', path: 'go.sum', contents: 'New go.sum' } },
|
||||
{ file: { type: 'addition', path: 'go.mod', contents: 'New go.mod' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{
|
||||
cmd: 'go get -d -t ./...',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
{
|
||||
cmd: 'go mod tidy',
|
||||
options: { cwd: '/tmp/github/some/repo' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -379,7 +379,7 @@ export async function updateArtifacts({
|
|||
}
|
||||
}
|
||||
|
||||
// TODO #7154
|
||||
// TODO: throws in tests (#7154)
|
||||
const finalGoModContent = (await readLocalFile(goModFileName, 'utf8'))!
|
||||
.replace(regEx(/\/\/ renovate-replace /g), '')
|
||||
.replace(regEx(/renovate-replace-bracket/g), ')');
|
||||
|
|
Loading…
Reference in a new issue