Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sync fork #6

Merged
merged 50 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fc896e0
Spike scmm
Aug 1, 2023
6d36707
work in progress
zT-1337 Aug 1, 2023
3c9e7f0
work in progress
zT-1337 Aug 1, 2023
45e3cc8
work in progress
zT-1337 Aug 1, 2023
712f927
work in progress
zT-1337 Aug 1, 2023
9240fcf
work in progress
zT-1337 Aug 2, 2023
38b2b39
work in progress
zT-1337 Aug 2, 2023
76bf8fc
work in progress
zT-1337 Aug 2, 2023
b39d349
work in progress
zT-1337 Aug 2, 2023
debd963
work in progress
zT-1337 Aug 2, 2023
532ea32
work in progress
zT-1337 Aug 2, 2023
8f63651
work in progress
zT-1337 Aug 2, 2023
e5a3f35
-removed: not needed property
zT-1337 Aug 2, 2023
22e8d86
-added: feature for autodiscovery of repos
zT-1337 Aug 3, 2023
4891088
-removed: not needed comments
zT-1337 Aug 3, 2023
7dba947
-renamed: scmm client to scm client
zT-1337 Aug 3, 2023
a3b3647
-deleted: not needed files
zT-1337 Aug 3, 2023
1bb7b82
-added: test cases
zT-1337 Aug 3, 2023
698018c
-added: test cases
zT-1337 Aug 3, 2023
cce9633
-added: test cases
zT-1337 Aug 4, 2023
56f6ad7
-removed: not needed imports
zT-1337 Aug 4, 2023
cf1ddce
-added: test cases
zT-1337 Aug 4, 2023
d9db25a
-added: test cases
zT-1337 Aug 4, 2023
08534c4
-fixed: linting
zT-1337 Aug 4, 2023
bc20059
-added: test cases
zT-1337 Aug 4, 2023
169de08
-added: token as password
zT-1337 Aug 7, 2023
ec90fe4
-fixed: documentation in index.md
zT-1337 Aug 7, 2023
5326bf9
-fixed: missing ensureComment function
zT-1337 Aug 17, 2023
47aebf1
-fixed: eslint command
zT-1337 Aug 17, 2023
59e2e29
-added: scm-manager to supported platform inside of readme and some o…
zT-1337 Aug 17, 2023
473b7dd
-changed: ignoring hg and svn repos in get All Repos function
zT-1337 Aug 23, 2023
e62ad39
Fixed wrong state mapping with not open and rejected (#4)
zT-1337 Sep 13, 2023
0c54b6b
Added axios as dependency. Added missing functions required by the Pl…
zT-1337 Jan 23, 2024
00f9167
Changes by lint-fix
zT-1337 Jan 23, 2024
3c73906
Added another test case
zT-1337 Jan 23, 2024
3bfda0b
The state and target branch change, now also gets passed to the scmm …
zT-1337 Jan 23, 2024
d64b071
Renamed index.md to readme.md. Like the other platform implementations
zT-1337 Jan 23, 2024
e556bdd
Added SCMM specific docs to the list of other platforms
zT-1337 Jan 23, 2024
1a1a2c1
Fixed numbering of items
zT-1337 Jan 23, 2024
1ad15f9
Added SCMM to the list of supported platforms
zT-1337 Jan 23, 2024
be5da27
Addes SCM-Manager as supported platform in docs
zT-1337 Jan 23, 2024
10c5642
Merge branch 'develop' into feature/sync-fork
zT-1337 Jan 24, 2024
0cde06e
Fixed linting
zT-1337 Jan 24, 2024
cfb0bcd
Added scmm preset resolver as null
zT-1337 Jan 24, 2024
da22e46
Fixed supported platforms list (scm-manager to scmm)
zT-1337 Jan 24, 2024
119fbdd
Fixed with prettier
zT-1337 Jan 24, 2024
33f6b38
Fixed supported platforms list (scm-manager to scmm)
zT-1337 Jan 24, 2024
7481fff
Improved test coverage by additional tests or ignoring certain paths,…
zT-1337 Jan 25, 2024
640d520
Update lib/modules/platform/scmm/readme.md
zT-1337 Jan 25, 2024
652e38a
Fixed linting
zT-1337 Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/usage/bot-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you see anything wrong on this page, please let us know by creating a [Discus
| Dependency Dashboard | Yes | No |
| Grouped updates | Yes, use community-provided groups, or create your own | Yes, create [`groups`](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#groups) manually |
| Upgrades common monorepo packages at once | Yes | No |
| Officially supported platforms | GitHub, GitLab, Bitbucket, Azure, Gitea, see [full list](./index.md#supported-platforms) | GitHub only |
| Officially supported platforms | GitHub, GitLab, Bitbucket, Azure, Gitea, SCM-Manager, see [full list](./index.md#supported-platforms) | GitHub only |
| Supported languages | [List for Renovate](./modules/manager/index.md) | [List for Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates#supported-repositories-and-ecosystems) |
| Show changelogs | Yes | Yes |
| Compatibility score badges | Four badges showing: Age, Adoption, Passing, Confidence | One badge with overall compatibility score |
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Major releases of Renovate are held back until the maintainers are reasonably ce

## Renovate core features not supported on all platforms

| Feature | Platforms which lack feature | See Renovate issue(s) |
| --------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| Dependency Dashboard | Azure, Bitbucket, Bitbucket Server | [#9592](https://github.com/renovatebot/renovate/issues/9592) |
| The Mend Renovate App | Azure, Bitbucket, Bitbucket Server, Forgejo, Gitea, GitLab | |
| Feature | Platforms which lack feature | See Renovate issue(s) |
| --------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------ |
| Dependency Dashboard | Azure, Bitbucket, Bitbucket Server, SCM-Manager | [#9592](https://github.com/renovatebot/renovate/issues/9592) |
| The Mend Renovate App | Azure, Bitbucket, Bitbucket Server, Forgejo, Gitea, GitLab, SCM-Manager | |

## Major platform features not supported by Renovate

Expand Down
1 change: 1 addition & 0 deletions docs/usage/getting-started/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ Read the platform-specific docs to learn how to setup authentication on your pla
- [Gitea and Forgejo](../modules/platform/gitea/index.md)
- [github.com and GitHub Enterprise Server](../modules/platform/github/index.md)
- [GitLab](../modules/platform/gitlab/index.md)
- [SCM-Manager](../modules/platform/scmm/index.md)

### GitHub.com token for changelogs

Expand Down
4 changes: 2 additions & 2 deletions docs/usage/getting-started/use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Example package files include:
Renovate:

1. Scans your repositories to find package files and their dependencies
1. Checks if any newer versions exist
1. Raises Pull Requests for available updates
2. Checks if any newer versions exist
3. Raises Pull Requests for available updates

The Pull Requests patch the package files directly, and include changelogs for the newer versions (if they are available).

Expand Down
6 changes: 3 additions & 3 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const options: RenovateOptions[] = [
'If set to `true` then Renovate creates draft PRs, instead of normal status PRs.',
type: 'boolean',
default: false,
supportedPlatforms: ['azure', 'gitea', 'github', 'gitlab', 'scm-manager'],
supportedPlatforms: ['azure', 'gitea', 'github', 'gitlab', 'scmm'],
},
{
name: 'dryRun',
Expand Down Expand Up @@ -780,7 +780,7 @@ const options: RenovateOptions[] = [
description: 'Username for authentication.',
stage: 'repository',
type: 'string',
supportedPlatforms: ['azure', 'bitbucket', 'bitbucket-server', 'scm-manager'],
supportedPlatforms: ['azure', 'bitbucket', 'bitbucket-server', 'scmm'],
globalOnly: true,
},
{
Expand Down Expand Up @@ -2729,7 +2729,7 @@ const options: RenovateOptions[] = [
description:
'Overrides the default resolution for Git remote, e.g. to switch GitLab from HTTPS to SSH-based.',
type: 'string',
supportedPlatforms: ['gitlab', 'bitbucket-server', 'scm-manager'],
supportedPlatforms: ['gitlab', 'bitbucket-server', 'scmm'],
allowedValues: ['default', 'ssh', 'endpoint'],
default: 'default',
stage: 'repository',
Expand Down
1 change: 1 addition & 0 deletions lib/config/presets/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const resolvers = {
github,
gitlab,
local: null,
scmm: null,
} satisfies Record<PlatformId, Resolver | null>;

export function getPreset({
Expand Down
108 changes: 92 additions & 16 deletions lib/modules/platform/scmm/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
initPlatform,
initRepo,
invalidatePrCache,
updatePr,
} from './index';

jest.mock('../../../util/host-rules');
Expand Down Expand Up @@ -91,13 +92,13 @@ describe('modules/platform/scmm/index', () => {
describe(initPlatform, () => {
it('should throw error, because endpoint is not configured', async () => {
await expect(initPlatform({ token })).rejects.toThrow(
'SCM-Manager endpoint not configured'
'SCM-Manager endpoint not configured',
);
});

it('should throw error, because token is not configured', async () => {
await expect(initPlatform({ endpoint })).rejects.toThrow(
'SCM-Manager api token not configured'
'SCM-Manager api token not configured',
);
});

Expand Down Expand Up @@ -131,7 +132,7 @@ describe('modules/platform/scmm/index', () => {
util.repoFingerprint.mockReturnValueOnce(expectedFingerprint);

expect(
await initRepo({ repository: `${repo.namespace}/${repo.name}` })
await initRepo({ repository: `${repo.namespace}/${repo.name}` }),
).toEqual({
defaultBranch: expectedDefaultBranch,
isFork: false,
Expand All @@ -153,15 +154,23 @@ describe('modules/platform/scmm/index', () => {
.mockResolvedValueOnce([
repo,
{ ...repo, namespace: 'other', name: 'repository' },
{ ...repo, namespace: 'other', name: 'mercurial', type: 'hg'},
{ ...repo, namespace: 'other', name: 'subversion', type: 'svn'}
{ ...repo, namespace: 'other', name: 'mercurial', type: 'hg' },
{ ...repo, namespace: 'other', name: 'subversion', type: 'svn' },
]);

expect(await getRepos()).toEqual(['default/repo', 'other/repository']);
});
});

describe(getPrList, () => {
it('should return empty array, because no pr could be found', async () => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
.mockRejectedValue(new Error());

expect(await getPrList()).toIncludeAllMembers([]);
});

it('should return all prs of a repo', async () => {
const expectedResult: Pr[] = [
{
Expand Down Expand Up @@ -190,6 +199,19 @@ describe('modules/platform/scmm/index', () => {
});

describe(findPr, () => {
it('search in pull request without explicitly setting the state as argument', async () => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
.mockResolvedValueOnce([pullRequest]);

expect(
await findPr({
branchName: pullRequest.source,
prTitle: pullRequest.title,
}),
).toEqual(renovatePr);
});

it.each([
[[], pullRequest.source, pullRequest.title, 'all', null],
[[pullRequest], 'invalid branchName', pullRequest.title, 'all', null],
Expand All @@ -213,16 +235,20 @@ describe('modules/platform/scmm/index', () => {
branchName: string,
prTitle: string | null | undefined,
state: string,
result: Pr | null
result: Pr | null,
) => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
.mockResolvedValueOnce(availablePullRequest);

expect(
await findPr({ branchName, prTitle, state: state as PrFilterByState })
await findPr({
branchName,
prTitle,
state: state as PrFilterByState,
}),
).toEqual(result);
}
},
);
});

Expand All @@ -236,18 +262,30 @@ describe('modules/platform/scmm/index', () => {
async (
availablePullRequest: PullRequest[],
branchName: string,
result: Pr | null
result: Pr | null,
) => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
.mockResolvedValueOnce(availablePullRequest);

expect(await getBranchPr(branchName)).toEqual(result);
}
},
);
});

describe(getPr, () => {
it('should return null, because pr was not found', async () => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
.mockResolvedValueOnce([]);

jest
.spyOn(ScmClient.prototype, 'getRepoPr')
.mockRejectedValue(new Error('Not found'));

expect(await getPr(1)).toBeNull();
});

it.each([
[[], pullRequest, 1, renovatePr],
[[pullRequest], pullRequest, 1, renovatePr],
Expand All @@ -257,7 +295,7 @@ describe('modules/platform/scmm/index', () => {
availablePullRequest: PullRequest[],
pullRequestById: PullRequest,
prId: number,
result: Pr | null
result: Pr | null,
) => {
jest
.spyOn(ScmClient.prototype, 'getAllRepoPrs')
Expand All @@ -268,7 +306,7 @@ describe('modules/platform/scmm/index', () => {
.mockResolvedValueOnce(pullRequestById);

expect(await getPr(prId)).toEqual(result);
}
},
);
});

Expand All @@ -282,7 +320,7 @@ describe('modules/platform/scmm/index', () => {
async (
draftPR: boolean | undefined,
expectedState: string,
expectedIsDraft: boolean
expectedIsDraft: boolean,
) => {
jest
.spyOn(ScmClient.prototype, 'createPr')
Expand All @@ -306,7 +344,7 @@ describe('modules/platform/scmm/index', () => {
},
},
});
}
},
);

expect(
Expand All @@ -316,7 +354,7 @@ describe('modules/platform/scmm/index', () => {
prTitle: 'PR Title',
prBody: 'PR Body',
draftPR,
})
}),
).toEqual({
sourceBranch: 'feature/test',
targetBranch: 'develop',
Expand All @@ -329,7 +367,45 @@ describe('modules/platform/scmm/index', () => {
reviewers: [],
state: expectedState,
});
}
},
);
});

describe(updatePr, () => {
it.each([
['open', 'OPEN', 'prBody', 'prBody'],
['closed', 'REJECTED', 'prBody', 'prBody'],
[undefined, undefined, 'prBody', 'prBody'],
['open', 'OPEN', undefined, undefined],
])(
'it should update the pr with state %p and prBody %p',
async (
actualState: string | undefined,
expectedState: string | undefined,
actualPrBody: string | undefined,
expectedPrBody: string | undefined,
) => {
jest
.spyOn(ScmClient.prototype, 'updatePr')
.mockImplementationOnce(() => Promise.resolve());

await updatePr({
number: 1,
prTitle: 'PR Title',
prBody: actualPrBody,
state: actualState as 'open' | 'closed' | undefined,
targetBranch: 'Target/Branch',
});

expect(
jest.spyOn(ScmClient.prototype, 'updatePr'),
).toHaveBeenCalledWith('default/repo', 1, {
description: expectedPrBody,
status: expectedState,
target: 'Target/Branch',
title: 'PR Title',
});
},
);
});
});
Loading
Loading