mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 14:06:30 +00:00
Merge f0ef320422
into c12c57b2a8
This commit is contained in:
commit
92158522d5
2 changed files with 8 additions and 255 deletions
|
@ -438,8 +438,8 @@ describe('modules/manager/bundler/artifacts', () => {
|
|||
bundlerHostRules.findAllAuthenticatable.mockReturnValue([
|
||||
{
|
||||
hostType: 'bundler',
|
||||
matchHost: 'gems.private.com',
|
||||
resolvedHost: 'gems.private.com',
|
||||
matchHost: 'gems-private.com',
|
||||
resolvedHost: 'gems-private.com',
|
||||
username: 'some-user',
|
||||
password: 'some-password',
|
||||
},
|
||||
|
@ -470,7 +470,7 @@ describe('modules/manager/bundler/artifacts', () => {
|
|||
'docker run --rm --name=renovate_sidecar --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/cache":"/tmp/cache" ' +
|
||||
'-e BUNDLE_GEMS__PRIVATE__COM ' +
|
||||
'-e BUNDLE_GEMS___PRIVATE__COM ' +
|
||||
'-e GEM_HOME ' +
|
||||
'-e CONTAINERBASE_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
|
@ -487,218 +487,6 @@ describe('modules/manager/bundler/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('injects bundler host configuration as command with bundler < 2', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||
// ruby
|
||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||
releases: [
|
||||
{ version: '1.0.0' },
|
||||
{ version: '1.2.0' },
|
||||
{ version: '1.3.0' },
|
||||
],
|
||||
});
|
||||
bundlerHostRules.findAllAuthenticatable.mockReturnValue([
|
||||
{
|
||||
hostType: 'bundler',
|
||||
matchHost: 'gems-private.com',
|
||||
resolvedHost: 'gems-private.com',
|
||||
username: 'some-user',
|
||||
password: 'some-password',
|
||||
},
|
||||
]);
|
||||
bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue(
|
||||
'some-user:some-password',
|
||||
);
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce(
|
||||
partial<StatusResult>({
|
||||
modified: ['Gemfile.lock'],
|
||||
}),
|
||||
);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock');
|
||||
expect(
|
||||
await updateArtifacts({
|
||||
packageFileName: 'Gemfile',
|
||||
updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }],
|
||||
newPackageFileContent: 'Updated Gemfile content',
|
||||
config: {
|
||||
...config,
|
||||
constraints: {
|
||||
bundler: '1.2',
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual([updatedGemfileLock]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull ghcr.io/containerbase/sidecar' },
|
||||
{ cmd: 'docker ps --filter name=renovate_sidecar -aq' },
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_sidecar --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/cache":"/tmp/cache" ' +
|
||||
'-e GEM_HOME ' +
|
||||
'-e CONTAINERBASE_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'ghcr.io/containerbase/sidecar' +
|
||||
' bash -l -c "' +
|
||||
'install-tool ruby 1.2.0' +
|
||||
' && ' +
|
||||
'install-tool bundler 1.2' +
|
||||
' && ' +
|
||||
'ruby --version' +
|
||||
' && ' +
|
||||
'bundler config --local gems-private.com some-user:some-password' +
|
||||
' && ' +
|
||||
'bundler lock --update foo bar' +
|
||||
'"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('injects bundler host configuration as command with bundler >= 2', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||
// ruby
|
||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||
releases: [
|
||||
{ version: '1.0.0' },
|
||||
{ version: '1.2.0' },
|
||||
{ version: '1.3.0' },
|
||||
],
|
||||
});
|
||||
bundlerHostRules.findAllAuthenticatable.mockReturnValue([
|
||||
{
|
||||
hostType: 'bundler',
|
||||
matchHost: 'gems-private.com',
|
||||
resolvedHost: 'gems-private.com',
|
||||
username: 'some-user',
|
||||
password: 'some-password',
|
||||
},
|
||||
]);
|
||||
bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue(
|
||||
'some-user:some-password',
|
||||
);
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce(
|
||||
partial<StatusResult>({
|
||||
modified: ['Gemfile.lock'],
|
||||
}),
|
||||
);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock');
|
||||
expect(
|
||||
await updateArtifacts({
|
||||
packageFileName: 'Gemfile',
|
||||
updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }],
|
||||
newPackageFileContent: 'Updated Gemfile content',
|
||||
config: {
|
||||
...config,
|
||||
constraints: {
|
||||
bundler: '2.1',
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual([updatedGemfileLock]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull ghcr.io/containerbase/sidecar' },
|
||||
{ cmd: 'docker ps --filter name=renovate_sidecar -aq' },
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_sidecar --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/cache":"/tmp/cache" ' +
|
||||
'-e GEM_HOME ' +
|
||||
'-e CONTAINERBASE_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'ghcr.io/containerbase/sidecar' +
|
||||
' bash -l -c "' +
|
||||
'install-tool ruby 1.2.0' +
|
||||
' && ' +
|
||||
'install-tool bundler 2.1' +
|
||||
' && ' +
|
||||
'ruby --version' +
|
||||
' && ' +
|
||||
'bundler config set --local gems-private.com some-user:some-password' +
|
||||
' && ' +
|
||||
'bundler lock --update foo bar' +
|
||||
'"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('injects bundler host configuration as command with bundler == latest', async () => {
|
||||
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
|
||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||
// ruby
|
||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||
releases: [
|
||||
{ version: '1.0.0' },
|
||||
{ version: '1.2.0' },
|
||||
{ version: '1.3.0' },
|
||||
],
|
||||
});
|
||||
// bundler
|
||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||
releases: [{ version: '1.17.2' }, { version: '2.3.5' }],
|
||||
});
|
||||
bundlerHostRules.findAllAuthenticatable.mockReturnValue([
|
||||
{
|
||||
hostType: 'bundler',
|
||||
matchHost: 'gems-private.com',
|
||||
resolvedHost: 'gems-private.com',
|
||||
username: 'some-user',
|
||||
password: 'some-password',
|
||||
},
|
||||
]);
|
||||
bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue(
|
||||
'some-user:some-password',
|
||||
);
|
||||
const execSnapshots = mockExecAll();
|
||||
git.getRepoStatus.mockResolvedValueOnce(
|
||||
partial<StatusResult>({
|
||||
modified: ['Gemfile.lock'],
|
||||
}),
|
||||
);
|
||||
fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock');
|
||||
expect(
|
||||
await updateArtifacts({
|
||||
packageFileName: 'Gemfile',
|
||||
updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }],
|
||||
newPackageFileContent: 'Updated Gemfile content',
|
||||
config,
|
||||
}),
|
||||
).toEqual([updatedGemfileLock]);
|
||||
expect(execSnapshots).toMatchObject([
|
||||
{ cmd: 'docker pull ghcr.io/containerbase/sidecar' },
|
||||
{ cmd: 'docker ps --filter name=renovate_sidecar -aq' },
|
||||
{
|
||||
cmd:
|
||||
'docker run --rm --name=renovate_sidecar --label=renovate_child ' +
|
||||
'-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' +
|
||||
'-v "/tmp/cache":"/tmp/cache" ' +
|
||||
'-e GEM_HOME ' +
|
||||
'-e CONTAINERBASE_CACHE_DIR ' +
|
||||
'-w "/tmp/github/some/repo" ' +
|
||||
'ghcr.io/containerbase/sidecar' +
|
||||
' bash -l -c "' +
|
||||
'install-tool ruby 1.2.0' +
|
||||
' && ' +
|
||||
'install-tool bundler 1.3.0' +
|
||||
' && ' +
|
||||
'ruby --version' +
|
||||
' && ' +
|
||||
'bundler config set --local gems-private.com some-user:some-password' +
|
||||
' && ' +
|
||||
'bundler lock --update foo bar' +
|
||||
'"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns error when failing in lockFileMaintenance true', async () => {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { lt } from '@renovatebot/ruby-semver';
|
||||
import is from '@sindresorhus/is';
|
||||
import { quote } from 'shlex';
|
||||
import {
|
||||
|
@ -17,7 +16,6 @@ import {
|
|||
} from '../../../util/fs';
|
||||
import { getRepoStatus } from '../../../util/git';
|
||||
import { newlineRegex, regEx } from '../../../util/regex';
|
||||
import { isValid } from '../../versioning/ruby';
|
||||
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
|
||||
import {
|
||||
getBundlerConstraint,
|
||||
|
@ -32,14 +30,16 @@ import {
|
|||
const hostConfigVariablePrefix = 'BUNDLE_';
|
||||
|
||||
function buildBundleHostVariable(hostRule: HostRule): Record<string, string> {
|
||||
if (!hostRule.resolvedHost || hostRule.resolvedHost.includes('-')) {
|
||||
if (!hostRule.resolvedHost) {
|
||||
return {};
|
||||
}
|
||||
const varName = hostConfigVariablePrefix.concat(
|
||||
hostRule.resolvedHost
|
||||
.toUpperCase()
|
||||
.split('.')
|
||||
.map((term) => term.toUpperCase())
|
||||
.join('__'),
|
||||
.join('__')
|
||||
.split('-')
|
||||
.join('___'),
|
||||
);
|
||||
return {
|
||||
[varName]: `${getAuthenticationHeaderValue(hostRule)}`,
|
||||
|
@ -149,47 +149,12 @@ export async function updateArtifacts(
|
|||
{} as Record<string, string>,
|
||||
);
|
||||
|
||||
// Detect hosts with a hyphen '-' in the url.
|
||||
// Those cannot be added with environment variables but need to be added
|
||||
// with the bundler config
|
||||
const bundlerHostRulesAuthCommands: string[] = bundlerHostRules.reduce(
|
||||
(authCommands: string[], hostRule) => {
|
||||
if (hostRule.resolvedHost?.includes('-')) {
|
||||
// TODO: fix me, hostrules can missing all auth
|
||||
const creds = getAuthenticationHeaderValue(hostRule);
|
||||
authCommands.push(`${quote(hostRule.resolvedHost)} ${quote(creds)}`);
|
||||
}
|
||||
return authCommands;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const bundler = getBundlerConstraint(
|
||||
updateArtifact,
|
||||
existingLockFileContent,
|
||||
);
|
||||
const preCommands = ['ruby --version'];
|
||||
|
||||
// Bundler < 2 has a different config option syntax than >= 2
|
||||
if (
|
||||
bundlerHostRulesAuthCommands &&
|
||||
bundler &&
|
||||
isValid(bundler) &&
|
||||
lt(bundler, '2')
|
||||
) {
|
||||
preCommands.push(
|
||||
...bundlerHostRulesAuthCommands.map(
|
||||
(authCommand) => `bundler config --local ${authCommand}`,
|
||||
),
|
||||
);
|
||||
} else if (bundlerHostRulesAuthCommands) {
|
||||
preCommands.push(
|
||||
...bundlerHostRulesAuthCommands.map(
|
||||
(authCommand) => `bundler config set --local ${authCommand}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const execOptions: ExecOptions = {
|
||||
cwdFile: lockFileName,
|
||||
userConfiguredEnv: config.env,
|
||||
|
|
Loading…
Reference in a new issue