mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
4b4d14ec00
* feat(manager): pass extracted constraints to updateArtifacts `extractedConstraints` were collected during extraction but only ever read by `fetch.ts` for the lookup. At artifact time every manager had to derive the same tool constraints a second time, and when the updated package file no longer carried the constraint there was nothing to fall back to. `generateBranchConfig()` now merges the `extractedConstraints` of all upgrades of a branch onto the branch config, which reaches `updateArtifacts()` through `patchConfigForArtifactsUpdate()`. `UpdateArtifactsConfig` declares the field and documents what it contains. The new `resolveToolConstraint()` helper implements the ladder once: user `constraints` > an optional artifact-time derivation > the extracted value. The derivation is ranked above the extracted value on purpose: it reads the package files as the branch changed them, so poetry (python is an updatable dependency there), composer, pipenv (`pipenv` can be a dev package) and pep621 (`requires-python` is an updatable dependency) would otherwise regress to a stale constraint. pipenv, pep621 uv/pdm, poetry and composer are migrated to the helper and keep their derivation. Behaviour change: these managers now use the extract-time constraint as a last resort instead of running unconstrained, for example on lock file maintenance where pipenv deletes `Pipfile.lock` before deriving. `execute-post-upgrade-commands.ts` is unaffected: it reads `upgrade.constraints` per upgrade, and the extracted values are kept in a separate field rather than folded into `constraints`, so post-upgrade task tool constraints still come from user config only. Not migrated, because their constraints are never extracted, so the fallback would be dead code: bundler (`ruby`/`bundler`), pixi (`pixi`), pep621 uv (`required-version`) and npm's node ladder, whose last step already reads `package.json` engines. * refactor(manager): resolve tool constraints through resolveToolConstraint() Every manager now obtains the constraint of a tool it runs through `resolveToolConstraint()` instead of reading `config.constraints` itself, so the precedence "user config, then a value derived from the updated files, then the constraints collected during extraction" applies everywhere. The helper treats an empty string as not set at every step and accepts the `PostUpdateConfig` shape, whose `constraints` may be `null`. Behaviour changes that go beyond the new fallback to extracted constraints: - `mix` applies its hardcoded erlang default only after the extracted constraint, so an erlang version collected at extraction can win over it. - `kustomize` decides `HELM_EXPERIMENTAL_OCI` from the fully resolved helm constraint; `generateHelmEnvs()` takes that value instead of the config. - `npm` (yarn): an upgrade of yarn without a new value now consults the user constraint before deriving one from package.json or the lock file. - The "Using <tool> constraint from config" debug lines in bundler, composer, copier and pip-compile are gone, as the helper is the only reader of the config now. Helpers that read the config synchronously became async: bundler `getBundlerConstraint()`, copier `getPythonVersionConstraint()` and `getCopierVersionConstraint()`, pip-compile `get*VersionConstraint()` and `getToolVersionConstraint()`, gomod `deriveGoToolchainConstraints()` and `getUpdateImportPathCmds()`, mise `getMiseLockToolConstraints()`. composer `getPhpConstraint()` is removed. Each converted manager has a test showing the extracted constraint reaching the executed tool, and, where a derive callback exists, that the derived value still wins over it. * refactor(linters): add prefer-resolve-tool-constraint rule Reports member reads and destructuring of `constraints` and `extractedConstraints` from a manager config in `lib/modules/manager/**`, so that tool constraints are resolved through `resolveToolConstraint()` in `lib/modules/manager/util.ts` only. Writes and the same properties on package files, which extraction has to populate, are not reported. The helper itself and spec files are exempt in `.oxlintrc.json`. * refactor(manager): inline thin resolveToolConstraint wrappers Drop copier/utils.ts and the pip-compile getPipToolsVersionConstraint / getUvVersionConstraint helpers, which only forwarded to resolveToolConstraint(). Callers now call it directly. * docs(development): note lock file maintenance in tool constraints section * refactor(manager): address review on tool constraint resolution composer only runs extractConstraints() when a user constraint is missing, via Lazy. UpdateArtifactsConfig no longer re-declares constraints and extractedConstraints, which ToolConstraintsConfig already provides.
634 lines
19 KiB
TypeScript
634 lines
19 KiB
TypeScript
import upath from 'upath';
|
|
import { mockDeep } from 'vitest-mock-extended';
|
|
import { envMock, mockExecAll } from '~test/exec-util.ts';
|
|
import { Fixtures } from '~test/fixtures.ts';
|
|
import { env, fs, git, partial } from '~test/util.ts';
|
|
import { GlobalConfig } from '../../../config/global.ts';
|
|
import type {
|
|
InternalGlobalConfigOptions,
|
|
RepoGlobalConfig,
|
|
} from '../../../config/types.ts';
|
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';
|
|
import { ExecError } from '../../../util/exec/exec-error.ts';
|
|
import type { StatusResult } from '../../../util/git/types.ts';
|
|
import * as hostRules from '../../../util/host-rules.ts';
|
|
import type { UpdateArtifactsConfig } from '../types.ts';
|
|
import * as vendir from './index.ts';
|
|
|
|
process.env.CONTAINERBASE = 'true';
|
|
|
|
vi.mock('../../datasource/index.ts', () => mockDeep());
|
|
vi.mock('../../../util/exec/env.ts');
|
|
vi.mock('../../../util/http/index.ts', () => mockDeep());
|
|
vi.mock('../../../util/fs/index.ts', () => mockDeep());
|
|
vi.mock('../../../util/git/index.ts', () => mockDeep());
|
|
|
|
const adminConfig: RepoGlobalConfig & InternalGlobalConfigOptions = {
|
|
localDir: upath.join('/tmp/github/some/repo'), // `join` fixes Windows CI
|
|
cacheDir: upath.join('/tmp/renovate/cache'),
|
|
containerbaseDir: upath.join('/tmp/cache/containerbase'),
|
|
dockerSidecarImage: 'ghcr.io/renovatebot/base-image',
|
|
binarySource: 'global',
|
|
};
|
|
|
|
const config: UpdateArtifactsConfig = {};
|
|
const vendirLockFile1 = Fixtures.get('vendir_1.lock');
|
|
const vendirLockFile2 = Fixtures.get('vendir_2.lock');
|
|
const vendirFile = Fixtures.get('vendir.yml');
|
|
|
|
describe('modules/manager/vendir/artifacts', () => {
|
|
beforeEach(() => {
|
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
|
GlobalConfig.set(adminConfig);
|
|
});
|
|
|
|
afterEach(() => {
|
|
hostRules.clear();
|
|
});
|
|
|
|
it('returns null if no vendir.lock.yml found', async () => {
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: '',
|
|
config,
|
|
}),
|
|
).resolves.toBeNull();
|
|
});
|
|
|
|
it('returns null if empty vendir.lock.yml found', async () => {
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
fs.readLocalFile.mockResolvedValueOnce('');
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: '',
|
|
config,
|
|
}),
|
|
).resolves.toBeNull();
|
|
});
|
|
|
|
it('returns null if updatedDeps is empty', async () => {
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.lock.yml',
|
|
updatedDeps: [],
|
|
newPackageFileContent: '',
|
|
config,
|
|
}),
|
|
).resolves.toBeNull();
|
|
});
|
|
|
|
it('returns null if unchanged', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce(vendirFile);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
const execSnapshots = mockExecAll();
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config,
|
|
}),
|
|
).resolves.toBeNull();
|
|
expect(execSnapshots).toMatchObject([{ cmd: 'vendir sync' }]);
|
|
});
|
|
|
|
it('returns updated vendir.lock', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
const execSnapshots = mockExecAll();
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config,
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([{ cmd: 'vendir sync' }]);
|
|
});
|
|
|
|
it('returns updated vendir.yml for lockfile maintenance', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.yml');
|
|
const execSnapshots = mockExecAll();
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps: [],
|
|
newPackageFileContent: vendirFile,
|
|
config: { ...config, isLockFileMaintenance: true },
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([{ cmd: 'vendir sync' }]);
|
|
});
|
|
|
|
it('catches errors', async () => {
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.writeLocalFile.mockImplementationOnce(() => {
|
|
throw new Error('not found');
|
|
});
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config,
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
artifactError: {
|
|
fileName: 'vendir.yml',
|
|
stderr: 'not found',
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('rethrows for temporary error', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const execError = new ExecError(TEMPORARY_ERROR, {
|
|
cmd: '',
|
|
stdout: '',
|
|
stderr: '',
|
|
options: {},
|
|
});
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
mockExecAll(execError);
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config,
|
|
}),
|
|
).rejects.toThrow(TEMPORARY_ERROR);
|
|
});
|
|
|
|
it('add artifacts to file list if vendir.yml exists', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
const execSnapshots = mockExecAll();
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
|
|
// artifacts
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendor');
|
|
git.getRepoStatus.mockResolvedValueOnce(
|
|
partial<StatusResult>({
|
|
not_added: ['vendor/Chart.yaml', 'vendor/my-chart/Chart.yaml'],
|
|
deleted: ['vendor/removed.yaml'],
|
|
}),
|
|
);
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
const test = await vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
},
|
|
});
|
|
expect(test).toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendor/Chart.yaml',
|
|
contents: undefined,
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendor/my-chart/Chart.yaml',
|
|
contents: undefined,
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
type: 'deletion',
|
|
path: 'vendor/removed.yaml',
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([
|
|
{
|
|
cmd: 'vendir sync',
|
|
options: {
|
|
env: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('add artifacts', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
const execSnapshots = mockExecAll();
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
|
|
// artifacts
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendor');
|
|
git.getRepoStatus.mockResolvedValueOnce(
|
|
partial<StatusResult>({
|
|
not_added: ['vendor/Chart.yaml'],
|
|
}),
|
|
);
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
},
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendor/Chart.yaml',
|
|
contents: undefined,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([
|
|
{
|
|
cmd: 'vendir sync',
|
|
options: {
|
|
env: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('sets GIT_CONFIG variables when Host Rules are configured', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
const execSnapshots = mockExecAll();
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
|
|
hostRules.add({
|
|
hostType: 'github',
|
|
matchHost: 'api.github.com',
|
|
token: 'some-token',
|
|
});
|
|
hostRules.add({
|
|
hostType: 'github',
|
|
matchHost: 'github.enterprise.com',
|
|
token: 'some-enterprise-token',
|
|
});
|
|
hostRules.add({
|
|
hostType: 'gitlab',
|
|
matchHost: 'gitlab.enterprise.com',
|
|
token: 'some-gitlab-token',
|
|
});
|
|
|
|
// artifacts
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendor');
|
|
git.getRepoStatus.mockResolvedValueOnce(
|
|
partial<StatusResult>({
|
|
not_added: ['vendor/Chart.yaml'],
|
|
}),
|
|
);
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
|
|
await vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
},
|
|
});
|
|
|
|
expect(execSnapshots).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
options: expect.objectContaining({
|
|
env: expect.objectContaining({
|
|
GIT_CONFIG_COUNT: '9',
|
|
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-enterprise-token@github.enterprise.com/.insteadOf',
|
|
GIT_CONFIG_KEY_4:
|
|
'url.https://git:some-enterprise-token@github.enterprise.com/.insteadOf',
|
|
GIT_CONFIG_KEY_5:
|
|
'url.https://some-enterprise-token@github.enterprise.com/.insteadOf',
|
|
GIT_CONFIG_KEY_6:
|
|
'url.https://gitlab-ci-token:some-gitlab-token@gitlab.enterprise.com/.insteadOf',
|
|
GIT_CONFIG_KEY_7:
|
|
'url.https://gitlab-ci-token:some-gitlab-token@gitlab.enterprise.com/.insteadOf',
|
|
GIT_CONFIG_KEY_8:
|
|
'url.https://gitlab-ci-token:some-gitlab-token@gitlab.enterprise.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@github.enterprise.com/',
|
|
GIT_CONFIG_VALUE_4: 'git@github.enterprise.com:',
|
|
GIT_CONFIG_VALUE_5: 'https://github.enterprise.com/',
|
|
GIT_CONFIG_VALUE_6: 'ssh://git@gitlab.enterprise.com/',
|
|
GIT_CONFIG_VALUE_7: 'git@gitlab.enterprise.com:',
|
|
}),
|
|
}),
|
|
}),
|
|
]),
|
|
);
|
|
});
|
|
|
|
it('works explicit global binarySource', async () => {
|
|
GlobalConfig.set({ ...adminConfig, binarySource: 'global' });
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
const execSnapshots = mockExecAll();
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config,
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([{ cmd: 'vendir sync' }]);
|
|
});
|
|
|
|
it('supports install mode', async () => {
|
|
GlobalConfig.set({
|
|
...adminConfig,
|
|
binarySource: 'install',
|
|
});
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
const execSnapshots = mockExecAll();
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
constraints: { vendir: '0.35.0', helm: '3.17.0' },
|
|
},
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([
|
|
{
|
|
cmd: 'install-tool vendir 0.35.0',
|
|
options: {
|
|
env: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
cmd: 'install-tool helm 3.17.0',
|
|
options: {
|
|
env: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
cmd: 'vendir sync',
|
|
options: {
|
|
env: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('falls back to the extracted constraints', async () => {
|
|
GlobalConfig.set({ ...adminConfig, binarySource: 'install' });
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
const execSnapshots = mockExecAll();
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps: [{ depName: 'dep1' }],
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
extractedConstraints: { vendir: '0.35.0', helm: '3.17.0' },
|
|
},
|
|
}),
|
|
).resolves.not.toBeNull();
|
|
expect(execSnapshots).toMatchObject([
|
|
{ cmd: 'install-tool vendir 0.35.0' },
|
|
{ cmd: 'install-tool helm 3.17.0' },
|
|
{ cmd: 'vendir sync' },
|
|
]);
|
|
});
|
|
|
|
describe('Docker', () => {
|
|
beforeEach(() => {
|
|
GlobalConfig.set({
|
|
...adminConfig,
|
|
binarySource: 'docker',
|
|
});
|
|
});
|
|
|
|
it('returns updated vendir.yml for lockfile maintenance', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile1);
|
|
fs.getSiblingFileName.mockReturnValueOnce('vendir.lock.yml');
|
|
fs.readLocalFile.mockResolvedValueOnce(vendirLockFile2);
|
|
const execSnapshots = mockExecAll();
|
|
fs.privateCacheDir.mockReturnValue(
|
|
'/tmp/renovate/cache/__renovate-private-cache',
|
|
);
|
|
fs.getParentDir.mockReturnValue('');
|
|
const updatedDeps = [{ depName: 'dep1' }];
|
|
await expect(
|
|
vendir.updateArtifacts({
|
|
packageFileName: 'vendir.yml',
|
|
updatedDeps,
|
|
newPackageFileContent: vendirFile,
|
|
config: {
|
|
...config,
|
|
constraints: { vendir: '0.35.0', helm: '3.17.0' },
|
|
},
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: 'vendir.lock.yml',
|
|
contents: vendirLockFile2,
|
|
},
|
|
},
|
|
]);
|
|
expect(execSnapshots).toMatchObject([
|
|
{ cmd: 'docker pull ghcr.io/renovatebot/base-image' },
|
|
{ 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/renovate/cache":"/tmp/renovate/cache" ' +
|
|
'-v "/tmp/cache/containerbase":"/tmp/cache/containerbase" ' +
|
|
'-e CI ' +
|
|
'-e CONTAINERBASE_CACHE_DIR ' +
|
|
'-w "/tmp/github/some/repo" ' +
|
|
'ghcr.io/renovatebot/base-image' +
|
|
" bash -l -c '" +
|
|
'install-tool vendir 0.35.0' +
|
|
' && ' +
|
|
'install-tool helm 3.17.0' +
|
|
' && ' +
|
|
'vendir sync' +
|
|
"'",
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
});
|