mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
b696abb3c2
* feat: add Hermit package manager * fix: pass bin directory into getRepoStatus as string rather than an array * fix: fix up hermit manager implementations * add docker support in exec * move fs related operations back into util/fs * remove ENVVar passed on by process.env * set concurrency in pMap * use for instead of pMap for concurrency = 1 * use regex to pick up package reference parts * fix: fix manager updateArtifacts test after change * Update lib/modules/manager/hermit/extract.ts Co-authored-by: Philip <42116482+PhilipAbed@users.noreply.github.com> * fix: fix up test and docker reference for hermit manager * test refer to internal fs * docker image change to sidecar * only symlink are read for the changed file content after hermit install * no more global mock in artifacts test * fix: use warn instead of error so error better flows up in hermit manager * fix: partial for test type, use throw instead of reject * fix: update snapshot * fix: combine install packages, also make extractPackageFile async * fix: remove weird generated readLocalSynmlink in test * fix: removes old test * fix: use ensureLocalPath and fix test coverage * fix: more test coverage * fix: use ensureLocalPath in readLocalSymlink * Apply suggestions from code review Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * fix: remove unused functions and types * Apply suggestions from code review Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * Apply suggestions from code review Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com> * fix: use execSnapshots and for of loop when returning the result * Update lib/modules/manager/hermit/artifacts.spec.ts Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * fix: move exports below imports Co-authored-by: Philip <42116482+PhilipAbed@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
293 lines
7 KiB
TypeScript
293 lines
7 KiB
TypeScript
import { mockExecAll } from '../../../../test/exec-util';
|
|
import { mockedFunction, partial } from '../../../../test/util';
|
|
import { GlobalConfig } from '../../../config/global';
|
|
import { ExecError } from '../../../util/exec/exec-error';
|
|
import { localPathIsSymbolicLink, readLocalSymlink } from '../../../util/fs';
|
|
import { getRepoStatus } from '../../../util/git';
|
|
import type { StatusResult } from '../../../util/git/types';
|
|
import type { UpdateArtifact } from '../types';
|
|
import { updateArtifacts } from '.';
|
|
|
|
jest.mock('../../../util/git');
|
|
jest.mock('../../../util/fs');
|
|
|
|
const getRepoStatusMock = mockedFunction(getRepoStatus);
|
|
|
|
const lstatsMock = mockedFunction(localPathIsSymbolicLink);
|
|
const readlinkMock = mockedFunction(readLocalSymlink);
|
|
|
|
describe('modules/manager/hermit/artifacts', () => {
|
|
describe('updateArtifacts', () => {
|
|
it('should run hermit install for packages and return updated files', async () => {
|
|
lstatsMock.mockResolvedValue(true);
|
|
|
|
readlinkMock.mockResolvedValue('hermit');
|
|
GlobalConfig.set({ localDir: '' });
|
|
|
|
const execSnapshots = mockExecAll();
|
|
getRepoStatusMock.mockResolvedValue(
|
|
partial<StatusResult>({
|
|
not_added: ['bin/go-1.17.1'],
|
|
deleted: ['bin/go-1.17'],
|
|
modified: ['bin/go', 'bin/jq'],
|
|
created: ['bin/jq-extra'],
|
|
renamed: [
|
|
{
|
|
from: 'bin/jq-1.5',
|
|
to: 'bin/jq-1.6',
|
|
},
|
|
],
|
|
})
|
|
);
|
|
|
|
const res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
depName: 'go',
|
|
currentVersion: '1.17',
|
|
newValue: '1.17.1',
|
|
},
|
|
{
|
|
depName: 'jq',
|
|
currentVersion: '1.5',
|
|
newValue: '1.6',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(execSnapshots).toMatchObject([
|
|
{ cmd: './hermit install go-1.17.1 jq-1.6' },
|
|
]);
|
|
|
|
expect(res).toStrictEqual([
|
|
{
|
|
file: {
|
|
path: 'bin/jq-1.5',
|
|
type: 'deletion',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
contents: 'hermit',
|
|
isSymlink: true,
|
|
isExecutable: undefined,
|
|
path: 'bin/jq-1.6',
|
|
type: 'addition',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
path: 'bin/go',
|
|
type: 'deletion',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
contents: 'hermit',
|
|
isSymlink: true,
|
|
isExecutable: undefined,
|
|
path: 'bin/go',
|
|
type: 'addition',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
path: 'bin/jq',
|
|
type: 'deletion',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
contents: 'hermit',
|
|
isSymlink: true,
|
|
isExecutable: undefined,
|
|
path: 'bin/jq',
|
|
type: 'addition',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
contents: 'hermit',
|
|
isSymlink: true,
|
|
isExecutable: undefined,
|
|
path: 'bin/jq-extra',
|
|
type: 'addition',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
contents: 'hermit',
|
|
isSymlink: true,
|
|
isExecutable: undefined,
|
|
path: 'bin/go-1.17.1',
|
|
type: 'addition',
|
|
},
|
|
},
|
|
{
|
|
file: {
|
|
path: 'bin/go-1.17',
|
|
type: 'deletion',
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should fail on error getting link content', async () => {
|
|
lstatsMock.mockResolvedValue(true);
|
|
|
|
readlinkMock.mockResolvedValue(null);
|
|
GlobalConfig.set({ localDir: '' });
|
|
|
|
mockExecAll();
|
|
|
|
getRepoStatusMock.mockResolvedValue(
|
|
partial<StatusResult>({
|
|
not_added: [],
|
|
deleted: [],
|
|
modified: [],
|
|
created: [],
|
|
renamed: [
|
|
{
|
|
from: 'bin/jq-1.5',
|
|
to: 'bin/jq-1.6',
|
|
},
|
|
],
|
|
})
|
|
);
|
|
|
|
const res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
depName: 'go',
|
|
currentVersion: '1.17',
|
|
newValue: '1.17.1',
|
|
},
|
|
{
|
|
depName: 'jq',
|
|
currentVersion: '1.5',
|
|
newValue: '1.6',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(res).toEqual([
|
|
{
|
|
artifactError: {
|
|
stderr: 'error getting content for bin/jq-1.6',
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should return error on installation error', async () => {
|
|
mockExecAll(
|
|
new ExecError('', {
|
|
stdout: '',
|
|
stderr: 'error executing hermit install',
|
|
cmd: '',
|
|
options: {
|
|
encoding: 'utf-8',
|
|
},
|
|
})
|
|
);
|
|
|
|
const res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
depName: 'go',
|
|
currentVersion: '1.17',
|
|
newValue: '1.17.1',
|
|
},
|
|
{
|
|
depName: 'jq',
|
|
currentVersion: '1.5',
|
|
newValue: '1.6',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(res).toStrictEqual([
|
|
{
|
|
artifactError: {
|
|
lockFile: 'from: go-1.17 jq-1.5, to: go-1.17.1 jq-1.6',
|
|
stderr: 'error executing hermit install',
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should return error on invalid update information', async () => {
|
|
let res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
currentVersion: '1.17',
|
|
newValue: '1.17.1',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(res).toStrictEqual([
|
|
{
|
|
artifactError: {
|
|
lockFile: 'from: -1.17, to: -1.17.1',
|
|
stderr: `invalid package to update`,
|
|
},
|
|
},
|
|
]);
|
|
|
|
res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
depName: 'go',
|
|
newValue: '1.17.1',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(res).toStrictEqual([
|
|
{
|
|
artifactError: {
|
|
lockFile: 'from: go-, to: go-1.17.1',
|
|
stderr: `invalid package to update`,
|
|
},
|
|
},
|
|
]);
|
|
|
|
res = await updateArtifacts(
|
|
partial<UpdateArtifact>({
|
|
updatedDeps: [
|
|
{
|
|
depName: 'go',
|
|
currentVersion: '1.17',
|
|
},
|
|
],
|
|
packageFileName: 'go/bin/hermit',
|
|
})
|
|
);
|
|
|
|
expect(res).toStrictEqual([
|
|
{
|
|
artifactError: {
|
|
lockFile: 'from: go-1.17, to: go-',
|
|
stderr: `invalid package to update`,
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
});
|