Skip to content

Commit

Permalink
Merge branch 'main' into feat-config-export-async-function-issue-13035
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Dec 13, 2021
2 parents 3acbda5 + b762656 commit 6591821
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 733 deletions.
2 changes: 1 addition & 1 deletion docs/usage/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ To get access to the token a custom Renovate Docker image is needed that include
The Dockerfile to create such an image can look like this:

```Dockerfile
FROM renovate/renovate:29.32.4
FROM renovate/renovate:30.3.1
# Include the "Docker tip" which you can find here https://cloud.google.com/sdk/docs/install
# under "Installation" for "Debian/Ubuntu"
RUN ...
Expand Down
1 change: 1 addition & 0 deletions lib/config/presets/internal/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const repoGroups = {
],
'graphql-mesh': 'https://github.com/Urigo/graphql-mesh',
'graphql-tools': 'https://github.com/ardatan/graphql-tools',
guava: 'https://github.com/google/guava',
javahamcrest: 'https://github.com/hamcrest/JavaHamcrest',
Hangfire: 'https://github.com/HangfireIO/Hangfire',
hapijs: 'https://github.com/hapijs',
Expand Down
44 changes: 25 additions & 19 deletions lib/manager/cargo/artifacts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import { exec as _exec } from 'child_process';
import _fs from 'fs-extra';
import { join } from 'upath';
import { envMock, mockExecAll } from '../../../test/exec-util';
import { git, mocked } from '../../../test/util';
import { envMock, exec, mockExecAll } from '../../../test/exec-util';
import { env, fs, git } from '../../../test/util';
import { GlobalConfig } from '../../config/global';
import type { RepoGlobalConfig } from '../../config/types';
import * as docker from '../../util/exec/docker';
import * as _env from '../../util/exec/env';
import type { UpdateArtifactsConfig } from '../types';
import * as cargo from './artifacts';

jest.mock('fs-extra');
jest.mock('child_process');
jest.mock('../../util/exec/env');
jest.mock('../../util/git');
jest.mock('../../util/http');

const fs: jest.Mocked<typeof _fs> = _fs as any;
const exec: jest.Mock<typeof _exec> = _exec as any;
const env = mocked(_env);
jest.mock('../../util/fs');

const config: UpdateArtifactsConfig = {};

Expand All @@ -39,6 +32,7 @@ describe('manager/cargo/artifacts', () => {
afterEach(() => {
GlobalConfig.reset();
});

it('returns null if no Cargo.lock found', async () => {
fs.stat.mockRejectedValue(new Error('not found!'));
const updatedDeps = [
Expand All @@ -55,6 +49,7 @@ describe('manager/cargo/artifacts', () => {
})
).toBeNull();
});

it('returns null if updatedDeps is empty', async () => {
expect(
await cargo.updateArtifacts({
Expand All @@ -65,11 +60,14 @@ describe('manager/cargo/artifacts', () => {
})
).toBeNull();
});

it('returns null if unchanged', async () => {
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
fs.readFile.mockResolvedValueOnce('Current Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('Current Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('Current Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('Current Cargo.lock');

const updatedDeps = [
{
Expand All @@ -86,11 +84,14 @@ describe('manager/cargo/artifacts', () => {
).toBeNull();
expect(execSnapshots).toMatchSnapshot();
});

it('returns updated Cargo.lock', async () => {
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('New Cargo.lock');
const updatedDeps = [
{
depName: 'dep1',
Expand All @@ -111,7 +112,8 @@ describe('manager/cargo/artifacts', () => {
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('New Cargo.lock');
const updatedDeps = [
{
depName: 'renamedDep1',
Expand All @@ -136,7 +138,8 @@ describe('manager/cargo/artifacts', () => {

git.getFile.mockResolvedValueOnce('Old Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('New Cargo.lock');
const updatedDeps = [
{
depName: 'dep1',
Expand All @@ -157,7 +160,8 @@ describe('manager/cargo/artifacts', () => {
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('New Cargo.lock');
expect(
await cargo.updateArtifacts({
packageFileName: 'Cargo.toml',
Expand All @@ -174,7 +178,8 @@ describe('manager/cargo/artifacts', () => {
GlobalConfig.set({ ...adminConfig, binarySource: 'docker' });
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('New Cargo.lock');
const updatedDeps = [
{
depName: 'dep1',
Expand All @@ -192,8 +197,9 @@ describe('manager/cargo/artifacts', () => {
});
it('catches errors', async () => {
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
fs.readFile.mockResolvedValueOnce('Current Cargo.lock' as any);
fs.outputFile.mockImplementationOnce(() => {
fs.findLocalSiblingOrParent.mockResolvedValueOnce('Cargo.lock');
fs.readLocalFile.mockResolvedValueOnce('Current Cargo.lock');
fs.writeLocalFile.mockImplementationOnce(() => {
throw new Error('not found');
});
const updatedDeps = [
Expand Down
34 changes: 8 additions & 26 deletions lib/workers/branch/__snapshots__/get-updated.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "version: 0.0.2",
"name": "undefined",
"name": "Chart.yaml",
},
],
}
Expand All @@ -22,7 +22,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "new version",
"name": "undefined",
"name": "package.json",
},
],
}
Expand All @@ -36,7 +36,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "updated-file",
"name": "undefined",
"name": "index.html",
},
],
}
Expand All @@ -50,21 +50,12 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "updated-file",
"name": "undefined",
"name": "index.html",
},
],
}
`;

exports[`workers/branch/get-updated getUpdatedPackageFiles() handles autoreplace branch no update 1`] = `
Object {
"artifactErrors": Array [],
"reuseExistingBranch": undefined,
"updatedArtifacts": Array [],
"updatedPackageFiles": Array [],
}
`;

exports[`workers/branch/get-updated getUpdatedPackageFiles() handles content change 1`] = `
Object {
"artifactErrors": Array [],
Expand All @@ -73,21 +64,12 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "some new content",
"name": "undefined",
"name": "package.json",
},
],
}
`;

exports[`workers/branch/get-updated getUpdatedPackageFiles() handles empty 1`] = `
Object {
"artifactErrors": Array [],
"reuseExistingBranch": undefined,
"updatedArtifacts": Array [],
"updatedPackageFiles": Array [],
}
`;

exports[`workers/branch/get-updated getUpdatedPackageFiles() handles git submodules 1`] = `
Object {
"artifactErrors": Array [],
Expand All @@ -96,7 +78,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "existing content",
"name": "undefined",
"name": ".gitmodules",
},
],
}
Expand Down Expand Up @@ -162,7 +144,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "some new content",
"name": "undefined",
"name": "composer.json",
},
],
}
Expand Down Expand Up @@ -209,7 +191,7 @@ Object {
"updatedPackageFiles": Array [
Object {
"contents": "existing content",
"name": "undefined",
"name": "composer.json",
},
],
}
Expand Down
Loading

0 comments on commit 6591821

Please sign in to comment.