-
Notifications
You must be signed in to change notification settings - Fork 6
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
chore: add script for generating new API version #WPB-11975 #3097
Conversation
Bencher Report
Click to view all benchmark results
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3097 +/- ##
========================================
Coverage 54.07% 54.07%
========================================
Files 1232 1232
Lines 36006 36012 +6
Branches 3653 3653
========================================
+ Hits 19469 19475 +6
+ Misses 15128 15127 -1
- Partials 1409 1410 +1
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportBranch report: ✅ 0 Failed, 3182 Passed, 107 Skipped, 31.87s Total Time |
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.
I did run the script and it keeps constructor parameter modifiers like private val
it is better to remove them if they are not used inside the class
so maybe adding to the end of the copy api classes step will help
note: this Regex is from ChatGPT so take it with a grain of salt
# Remove 'private val' from constructor parameters
new_content=$(echo "$new_content" | perl -0777 -pe '
s{
(constructor\s*\() # Match "constructor(" with optional whitespace
( # Start capture group for parameters
(?: # Non-capturing group
[^()] # Any character except parentheses
| # OR
\([^()]*\) # Parentheses containing anything but parentheses
)*? # Zero or more times, non-greedy
)
(\)) # Match closing ")"
}{
my ($cons, $params, $close) = ($1, $2, $3);
# Remove visibility modifiers and 'val' or 'var' from parameters
$params =~ s/\b(private|public|protected|internal)\s+(val|var)\s+//g;
"$cons$params$close"
}egsx;
')
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.
I believe the logic within generate_new_api_version.sh
would be easier to maintain and expand if written in Kotlin, as it's what most of the team is used to. It would also run on Windows :c
We could even leverage tools like KotlinPoet to generate some pieces of code for us.
On the other hand... it's definitely an improvement over not having it at all. So yeah, if the other comments can be addressed, it's fine from my point of view :)
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 with existed comments, other then that: I like the idea, definitely improvement of life 👍 💪
I have added removing vals. I did not found a way to remove unused params without installing detekt CLI to run the autofix on a directory. 🤔 Added a task to rewrite it in Kotlin. I didn't used the KotlinPoet yet, looks fun https://wearezeta.atlassian.net/browse/WPB-14423 |
…/script-generate-new-api # Conflicts: # network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt # network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt # network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt # network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt
Quality Gate passedIssues Measures |
What's new in this PR?
Issues
While implementing API v7 I noticed that we need to add many new classes in a repetitive way. Doing it manual is prone to errors.
Solutions
Added script that automates the process. Added comments about the script in a likely places that develop can start looking in.
Testing
How to Test
You can either run:
./scripts/generate_new_api_version.sh 5 6 7
./gradlew :network:generateNewApiVersion -PpreviousApiVersion=5 -PcurrentApiVersion=6 -PnewApiVersion=7
It should generate NetworkContainers and API classes.
It should add the new api as BackendMetaDataUtil.DevelopmentApiVersions
There could be some unused params copied from previous API version that developer will need to remove, but static analysis will catch it.
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.