mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
feat(bundler): use ruby and bundler versions to update lock files
This commit is contained in:
parent
d4cff79374
commit
1ee546b0ea
1 changed files with 57 additions and 4 deletions
|
@ -4,6 +4,14 @@ const { exec } = require('child-process-promise');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const upath = require('upath');
|
const upath = require('upath');
|
||||||
|
|
||||||
|
const { getPkgReleases } = require('../../datasource/docker');
|
||||||
|
const {
|
||||||
|
isValid,
|
||||||
|
isVersion,
|
||||||
|
matches,
|
||||||
|
sortVersions,
|
||||||
|
} = require('../../versioning/ruby');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getArtifacts,
|
getArtifacts,
|
||||||
};
|
};
|
||||||
|
@ -48,20 +56,65 @@ async function getArtifacts(
|
||||||
let cmd;
|
let cmd;
|
||||||
if (config.binarySource === 'docker') {
|
if (config.binarySource === 'docker') {
|
||||||
logger.info('Running bundler via docker');
|
logger.info('Running bundler via docker');
|
||||||
|
let tag = 'latest';
|
||||||
|
let rubyConstraint;
|
||||||
|
const rubyVersionFile = upath.join(
|
||||||
|
upath.dirname(packageFileName),
|
||||||
|
'.ruby-version'
|
||||||
|
);
|
||||||
|
logger.debug('Checking ' + rubyVersionFile);
|
||||||
|
const rubyVersionFileContent = await platform.getFile(rubyVersionFile);
|
||||||
|
if (rubyVersionFileContent) {
|
||||||
|
logger.debug('Using ruby version specified in .ruby-version');
|
||||||
|
rubyConstraint = rubyVersionFileContent.replace(/\n/g, '').trim();
|
||||||
|
} else {
|
||||||
|
rubyConstraint =
|
||||||
|
config && config.compatibility && config.compatibility.ruby
|
||||||
|
? config.compatibility.ruby
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
if (rubyConstraint && isValid(rubyConstraint)) {
|
||||||
|
logger.debug('Found ruby compatibility');
|
||||||
|
const rubyReleases = await getPkgReleases({
|
||||||
|
fullname: 'renovate/ruby',
|
||||||
|
qualifiers: {},
|
||||||
|
});
|
||||||
|
if (rubyReleases && rubyReleases.releases) {
|
||||||
|
let versions = rubyReleases.releases.map(release => release.version);
|
||||||
|
versions = versions.filter(version => isVersion(version));
|
||||||
|
versions = versions.filter(version =>
|
||||||
|
matches(version, rubyConstraint)
|
||||||
|
);
|
||||||
|
versions = versions.sort(sortVersions);
|
||||||
|
if (versions.length) {
|
||||||
|
tag = versions.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const bundlerConstraint =
|
||||||
|
config && config.compatibility && config.compatibility.bundler
|
||||||
|
? config.compatibility.bundler
|
||||||
|
: undefined;
|
||||||
|
let bundlerVersion = '';
|
||||||
|
if (bundlerConstraint && isVersion(bundlerConstraint)) {
|
||||||
|
bundlerVersion = ' -v ' + bundlerConstraint;
|
||||||
|
}
|
||||||
cmd = `docker run --rm `;
|
cmd = `docker run --rm `;
|
||||||
const volumes = [config.localDir];
|
const volumes = [config.localDir];
|
||||||
cmd += volumes.map(v => `-v ${v}:${v} `).join('');
|
cmd += volumes.map(v => `-v ${v}:${v} `).join('');
|
||||||
const envVars = [];
|
const envVars = [];
|
||||||
cmd += envVars.map(e => `-e ${e} `);
|
cmd += envVars.map(e => `-e ${e} `);
|
||||||
cmd += `-w ${cwd} `;
|
cmd += `-w ${cwd} `;
|
||||||
cmd += `renovate/bundler bundler`;
|
cmd += `renovate/ruby:${tag} bash -l -c "ruby --version && `;
|
||||||
|
cmd += 'gem install bundler' + bundlerVersion;
|
||||||
|
cmd += ' && bundle';
|
||||||
} else {
|
} else {
|
||||||
logger.info('Running bundler via global bundler');
|
logger.info('Running bundler via global bundler');
|
||||||
cmd = 'bundler';
|
cmd = 'bundler';
|
||||||
}
|
}
|
||||||
const args = 'lock';
|
cmd += ' lock"';
|
||||||
logger.debug({ cmd, args }, 'bundler command');
|
logger.debug({ cmd }, 'bundler command');
|
||||||
({ stdout, stderr } = await exec(`${cmd} ${args}`, {
|
({ stdout, stderr } = await exec(cmd, {
|
||||||
cwd,
|
cwd,
|
||||||
shell: true,
|
shell: true,
|
||||||
env,
|
env,
|
||||||
|
|
Loading…
Reference in a new issue