-
Notifications
You must be signed in to change notification settings - Fork 915
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
Add downgrade logic for branch in DocLinkService #3483
Add downgrade logic for branch in DocLinkService #3483
Conversation
Signed-off-by: suzhou <[email protected]>
Signed-off-by: suzhou <[email protected]>
Signed-off-by: suzhou <[email protected]>
Please help to backport to 2.x and main. |
@SuZhou-Joe Can you make an issue for this (see https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md#contributing-code)? It's a great find and definitely a bug we should fix, but I think we may want to discuss other solutions. For example:
|
cc @AMoo-Miki who is keeping 👀 on all things version related. |
Thanks @joshuarrrr , the issue has been created and linked. |
Signed-off-by: suzhou <[email protected]> Co-authored-by: Miki <[email protected]>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3483 +/- ##
=======================================
Coverage 66.45% 66.46%
=======================================
Files 3205 3208 +3
Lines 61562 61602 +40
Branches 9497 9503 +6
=======================================
+ Hits 40912 40943 +31
- Misses 18353 18383 +30
+ Partials 2297 2276 -21
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 26 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: suzhou <[email protected]>
Please add |
Hello @SuZhou-Joe, Thanks for opening! From my understanding it takes the config value and automatically sets it based on the config build version if not I believe the branch is only used within the doc links service within our repo but I'm not positive if external plugins utilize this configuration for information. If the purpose is for the doc links service, I'd recommend handling this logic https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/public/doc_links/doc_links_service.ts#L43. Also, I can kind of see how we build the doc links service to be very unique to the branching strategy and doc link URL path set by the organization. I think it's fine not to worry about for now but if I was to fork this and change the URL I think it should be valid to pass suffix. I should even be able to pass my own site. But like I said, that's not something for you something that we should think about. Let me know if you have any questions! Thanks! |
branch = pkg.branch; | ||
} else { | ||
// package version was not parsable and branch is unusable | ||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this prevent the builds if they pass a non-valid doc paths pattern in the branch in the package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if no version can be specified after so many downgrade logic, we will prevent the build because there will be a doc link error if we continue to build.
Signed-off-by: suzhou <[email protected]>
Signed-off-by: suzhou <[email protected]>
This reverts commit 8f8521d. Signed-off-by: suzhou <[email protected]>
This reverts commit b09c3eb. Signed-off-by: suzhou <[email protected]>
This reverts commit 730d694. Signed-off-by: suzhou <[email protected]>
This reverts commit 9df87a5. Signed-off-by: suzhou <[email protected]>
ccfe876
to
35fff82
Compare
branch = pkgBranch; | ||
} else { | ||
// package version was not parsable and branch is unusable | ||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: suzhou <[email protected]>
Signed-off-by: suzhou <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
} else if (parsedBuildVersion) { | ||
branch = `${parsedBuildVersion.major}.${parsedBuildVersion.minor}`; | ||
} else { | ||
branch = pkgBranch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SuZhou-Joe Can't we simplify line 54 to line 62 like this? since we already set let branch = pkgBranch;
outside the block and line 57 and line 61 are doing the duplicate thing
const validDocPathsPattern = /^\d+\.\d+$/;
const parsedBuildVersion = parse(buildVersion);
if (!validDocPathsPattern.test(pkgBranch) &&& parsedBuildVersion) {
branch = `${parsedBuildVersion.major}.${parsedBuildVersion.minor}`;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree and done.
Signed-off-by: suzhou <[email protected]>
Add downgrade logic for branch in DocLinkService Signed-off-by: suzhou <[email protected]> (cherry picked from commit e37ac4c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
Add downgrade logic for branch in DocLinkService Signed-off-by: suzhou <[email protected]> (cherry picked from commit e37ac4c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…3483) Add downgrade logic for branch in DocLinkService Signed-off-by: suzhou <[email protected]>
…3483) Add downgrade logic for branch in DocLinkService Signed-off-by: suzhou <[email protected]> Signed-off-by: David Sinclair <[email protected]>
Description
This is a TODO after PR.
The
CoreStart.docLinks.docVersion
is usingpkg.branch
. In 2.5 we changed it manually.In this PR I want to add a mechanism into CI flow to prevent human error(If build team forget to change the value, which is
2.x
now in current build flow, it will break down all the new doc links inside IM plugin because the link will become likehttps://opensearch.org/docs/2.x/api-reference/index-apis/create-index/
.).Issues Resolved
#3490 #3490
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr