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

fix(datasource/gitlab-packages): prefer checking for conan_package_name if it exists #33099

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
46 changes: 45 additions & 1 deletion lib/modules/datasource/gitlab-packages/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it('returns package from custom registry', async () => {
const body = [
{
version: '1.0.0',
version: 'v1.0.0',
FFace32 marked this conversation as resolved.
Show resolved Hide resolved
created_at: '2020-03-04T12:01:37.000-06:00',
name: 'mypkg',
},
Expand Down Expand Up @@ -41,10 +41,54 @@
registryUrls: ['https://gitlab.com'],
packageName: 'user/project1:mypkg',
});
expect(res).toMatchSnapshot();

Check failure on line 44 in lib/modules/datasource/gitlab-packages/index.spec.ts

View workflow job for this annotation

GitHub Actions / test (1/16)

modules/datasource/gitlab-packages/index › getReleases › returns package from custom registry

expect(received).toMatchSnapshot() Snapshot name: `modules/datasource/gitlab-packages/index getReleases returns package from custom registry 1` - Snapshot - 1 + Received + 1 @@ -1,11 +1,11 @@ { "registryUrl": "https://gitlab.com", "releases": [ { "releaseTimestamp": "2020-03-04T18:01:37.000Z", - "version": "1.0.0", + "version": "v1.0.0", }, { "releaseTimestamp": "2020-04-04T18:01:37.000Z", "version": "v1.1.0", }, at Object.<anonymous> (lib/modules/datasource/gitlab-packages/index.spec.ts:44:19)
expect(res?.releases).toHaveLength(3);
});

it('returns conan package from custom registry', async () => {
const body = [
{
version: 'v1.0.0',
created_at: '2020-03-04T12:01:37.000-06:00',
name: 'myconanpkg/1.0.0@mycompany/stable',
conan_package_name: 'myconanpkg',
},
{
version: 'v1.1.0',
created_at: '2020-04-04T12:01:37.000-06:00',
name: 'myconanpkg/1.1.0@mycompany/stable',
conan_package_name: 'myconanpkg',
},
{
version: 'v1.1.1',
created_at: '2020-05-04T12:01:37.000-06:00',
name: 'myconanpkg/1.1.0@mycompany/stable',
conan_package_name: 'myconanpkg',
},
{
version: 'v2.0.0',
created_at: '2020-05-04T12:01:37.000-06:00',
name: 'otherpkg/2.0.0@mycompany/stable',
conan_package_name: 'otherpkg',
},
];
httpMock
.scope('https://gitlab.com')
.get('/api/v4/projects/user%2Fproject1/packages')
.query({
package_name: 'myconanpkg',
per_page: '100',
})
.reply(200, body);
const res = await getPkgReleases({
datasource,
registryUrls: ['https://gitlab.com'],
packageName: 'user/project1:myconanpkg',
});
expect(res).toMatchSnapshot();

Check failure on line 88 in lib/modules/datasource/gitlab-packages/index.spec.ts

View workflow job for this annotation

GitHub Actions / test (1/16)

modules/datasource/gitlab-packages/index › getReleases › returns conan package from custom registry

expect(received).toMatchSnapshot() Snapshot name: `modules/datasource/gitlab-packages/index getReleases returns conan package from custom registry 1` New snapshot was not written. The update flag must be explicitly passed to write a new snapshot. This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default. Received: { "registryUrl": "https://gitlab.com", "releases": [ { "releaseTimestamp": "2020-03-04T18:01:37.000Z", "version": "v1.0.0", }, { "releaseTimestamp": "2020-04-04T18:01:37.000Z", "version": "v1.1.0", }, { "releaseTimestamp": "2020-05-04T18:01:37.000Z", "version": "v1.1.1", }, ], } at Object.<anonymous> (lib/modules/datasource/gitlab-packages/index.spec.ts:88:19)
expect(res?.releases).toHaveLength(3);
});

it('returns null for 404', async () => {
httpMock
.scope('https://gitlab.com')
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/gitlab-packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class GitlabPackagesDatasource extends Datasource {
result.releases = response
// Setting the package_name option when calling the GitLab API isn't enough to filter information about other packages
// because this option is only implemented on GitLab > 12.9 and it only does a fuzzy search.
.filter((r) => r.name === packagePart)
.filter((r) => (r.conan_package_name ?? r.name) === packagePart)
.map(({ version, created_at }) => ({
version,
releaseTimestamp: created_at,
Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/gitlab-packages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface GitlabPackage {
version: string;
created_at: string;
name: string;
conan_package_name?: string;
}
Loading