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

feat(platform): Add support for JetBrains Space platform #29151

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

vooft
Copy link

@vooft vooft commented May 19, 2024

Changes

Hi All,

I implemented integration with the JetBrains Space platform.
Features supported:

  • Autodiscover
  • Creating PRs
  • Finding closed ones
  • Rebasing PRs (manual only via adding rebase! to the title)
  • Adding/removing comments
  • Changing PR body
  • Adding reviewers
  • Adding authors
  • Auto-merging if checks have passed (not available in free plan, but could be tested on trial)

Not everything is covered with tests yet, but, say, 70% of the new code. I would like to get some feedback on my code, please, before proceeding with the remaining tests. My background is in JVM world and, perhaps, some things were not implemented idiomatically.

Unfortunately, Space doesn't have public repositories, but I'm happy to give access for interested to my test environment.

Minimal config for testing would look like this:

module.exports = {
  token: '<your-personal-token>',
  repositories: ['main/my-repo'], // optional, goes like <project-key>/<repo-name>, default project key is "MAIN", but it seems that server doesn't care about casing
  platform: 'space',
  endpoint: '<your-org>.jetbrains.space',
};

Context

I was using Renovate for long time and wanted to contribute in some way, as well as to play with JetBrains Space.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@vooft vooft changed the title WIP Add support for JetBrians Space platform feat(jetbrains-space): Add support for JetBrians Space platform May 19, 2024
@vooft vooft changed the title feat(jetbrains-space): Add support for JetBrians Space platform feat(platform/space): Add support for JetBrians Space platform May 19, 2024
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! The most important point would be to adopt Zod for validating all responses from the Space API. Right now you are casting any to typed values, which is risky for runtime faults. Instead we want to use Zod for all new code like this: https://github.com/renovatebot/renovate/blob/main/docs/development/zod.md

@@ -60,7 +60,7 @@ async function closedPrExists(config: RenovateConfig): Promise<Pr | null> {
}

export async function isOnboarded(config: RenovateConfig): Promise<boolean> {
logger.debug('isOnboarded()');
logger.debug(`isOnboarded(${JSON.stringify(config)})`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs reverting

Comment on lines 445 to 446
existingPrBodyHash,
newPrBodyHash,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually helpful to the user? We don't intend for these hashes to be meaningful to anyone

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I added it when was debugging, removed

case 'Opened':
return 'open';
case 'Closed':
if (canBeReopened) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a kind of "hack" to determine whether a closed PR was merged or not? Would be good to document it so that others don't need to guess in future

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment explaining why need this flag

Comment on lines 106 to 108
logger.debug(
`SPACE findPr(${JSON.stringify(findPRConfig)}, ${refreshCache})`,
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general note that logging like this will need to be lowered or removed before merge

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll clean up most of the debug logs, thanks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced most of logs with trace or simply removed, kept a couple that might be useful for general user debugging

@vooft
Copy link
Author

vooft commented May 19, 2024

@rarkins thank you for checking it out! Will read about ZOD and make required changes.

@viceice viceice self-requested a review May 21, 2024 21:01
@viceice
Copy link
Member

viceice commented May 21, 2024

I think space is to general, the platform should probably be jetbrains-space or something similar

type SpaceMergeRequestRecordPredicate,
} from './code-review-read';

const spaceEndpointUrl = 'https://myorg.jetbrains.space';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like jetbrainsSpaceEndpointUrl is easier to understand.

lib/config/presets/local/index.ts Show resolved Hide resolved
@viceice viceice changed the title feat(platform/space): Add support for JetBrians Space platform feat(platform): Add support for JetBrians Space platform May 27, 2024
@viceice viceice changed the title feat(platform): Add support for JetBrians Space platform feat(platform): Add support for JetBrains Space platform May 27, 2024
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces is deprecated1!

@rarkins @secustor Should we add a deprecated platform? Support will be fully stoped on 2025-05-31.

They currently have a new platform in preview SpaceCode.
I'm sure it's totally different.

Footnotes

  1. https://blog.jetbrains.com/space/2024/05/27/the-future-of-space/

@@ -26,6 +26,7 @@ const resolvers = {
github,
gitlab,
local: null,
space: local, // TODO: not sure what this means
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
space: local, // TODO: not sure what this means
space: local,

loading presets from local platform

@@ -0,0 +1,169 @@
export interface SpacePaginatedResult {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vooft
Copy link
Author

vooft commented May 27, 2024

@viceice that's very unfortunate lol, I chose the perfect time to start building this integration :)
I imagine they will probably reuse part of the code from Space in the new platform, so potentially the api will be similar.

@viceice
Copy link
Member

viceice commented May 27, 2024

@viceice that's very unfortunate lol, I chose the perfect time to start building this integration :)
I imagine they will probably reuse part of the code from Space in the new platform, so potentially the api will be similar.

it's already in preview, so you can check it.

@vooft
Copy link
Author

vooft commented May 27, 2024

The API feels mostly the same, looks like they removed chats, but some chat-related APIs are still there.
I will probably pause for now until they release it to public.

@HonkingGoose
Copy link
Collaborator

They currently have a new platform in preview SpaceCode.
I'm sure it's totally different.

I found some more info about the differences between the old Space and the upcoming SpaceCode. The Jetbrain docs, migrate from Space to SpaceCode, what will not stay in SpaceCode says:

What will NOT stay in SpaceCode

  • Automation. You will be able to convert and transfer your Automation jobs to JetBrains TeamCity and continue using them for your CI/CD needs.
  • Issues. You will be able to move your issues to an alternative planning tool — JetBrains YouTrack.
  • Documents. Project documents can be exported to YouTrack Knowledge Base.
  • Checklists. Can be extracted via HTTP API.
  • Blog posts. Can be extracted via HTTP API.
  • Chats. Messages can be retrieved in batch via HTTP API.
  • Packages. Package repository source data can be accessed and retrieved via HTTP API.
  • Calendars and calendar events such as Meetings, Absences, Holidays. Personal calendars can be exported to .ICS files.
  • To-do lists.
  • Locations.
  • Work schedule.
  • Availability status.

I'll let the maintainers decide if it's worth it to support a now deprecated platform.

@rarkins rarkins marked this pull request as draft May 28, 2024 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants