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

Development: Add mobile app version compatibility #10339

Merged
merged 6 commits into from
Feb 18, 2025

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Feb 16, 2025

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).

Motivation and Context

Android and iOS apps need to fetch the minimum-recommended versions from the Artemis server. This information can be used to notify users if their app version is outdated, with an update prompt to be added later.

Description

The /management/info endpoint now includes the minimum-required Artemis versions for Android and iOS apps.

Steps for Testing

Prerequisites:

  • 1 User
  1. After deployment, navigate to /management/info in your browser and search for "compatible-versions" to check the version numbers (e.g., https://artemis-test4.artemis.cit.tum.de/management/info).

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Summary by CodeRabbit

  • New Features
    • Introduced configuration settings to manage minimum and recommended mobile platform versions.
    • Enhanced system info endpoints to display compatibility details for Android and iOS.
  • Tests
    • Added comprehensive tests to validate the correct display and behavior of the new compatibility information.

@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. core Pull requests that affect the corresponding module labels Feb 16, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 16, 2025 14:51 Inactive
@asliayk asliayk marked this pull request as ready for review February 16, 2025 15:07
@asliayk asliayk requested a review from a team as a code owner February 16, 2025 15:07
Copy link

coderabbitai bot commented Feb 16, 2025

Walkthrough

This change introduces a new configuration class for managing compatible version information for Android and iOS platforms. It defines an inner class to encapsulate version details and binds these properties from the Spring environment. Additionally, an actuator info contributor class is added to expose these version settings via the application’s info endpoints. A corresponding test class verifies that the contributor correctly adds the configuration details to the info response.

Changes

Files Change Summary
src/main/java/.../ArtemisCompatibleVersionsConfiguration.java, src/main/java/.../CompatibleVersionsInfoContributor.java Added a configuration class (ArtemisCompatibleVersionsConfiguration) with an inner Platform class to manage Android and iOS version settings, and an actuator info contributor (CompatibleVersionsInfoContributor) to expose these settings via application endpoints.
src/test/java/.../CompatibleVersionsConfigurationTest.java Introduced a test class that verifies the proper contribution of compatible versions information to the actuator’s info details.
src/main/java/.../ArtemisApp.java Updated @EnableConfigurationProperties annotation to include ArtemisCompatibleVersionsConfiguration.class.

Suggested labels

feature, component:Notification, ready to merge, documentation

Suggested reviewers

  • SimonEntholzer
  • dmytropolityka
  • marlon-luca-bu
  • HawKhiem
  • anian03
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java (1)

34-58: Consider using Java Record and adding version validation.

The Platform class could be simplified using a Java Record. Additionally, consider adding version format validation to ensure semantic versioning compliance.

-    public static class Platform {
-        private String min;
-        private String recommended;
-
-        public Platform() {
-        }
-
-        public String getMin() {
-            return min;
-        }
-
-        public void setMin(String min) {
-            this.min = min;
-        }
-
-        public String getRecommended() {
-            return recommended;
-        }
-
-        public void setRecommended(String recommended) {
-            this.recommended = recommended;
-        }
-    }
+    public static record Platform(
+        @Pattern(regexp = "^\\d+\\.\\d+\\.\\d+$", message = "Version must follow semantic versioning")
+        String min,
+        @Pattern(regexp = "^\\d+\\.\\d+\\.\\d+$", message = "Version must follow semantic versioning")
+        String recommended
+    ) {}
src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (1)

10-42: Add test cases for edge cases and invalid inputs.

While the happy path is tested, consider adding test cases for:

  • Empty version strings
  • Invalid version formats
  • Null values
  • Different version formats between min and recommended

Example test case:

@Test
void shouldValidateVersionFormat() {
    ArtemisCompatibleVersionsConfiguration config = new ArtemisCompatibleVersionsConfiguration();
    ArtemisCompatibleVersionsConfiguration.Platform android = new ArtemisCompatibleVersionsConfiguration.Platform();
    
    // Test invalid version format
    android.setMin("invalid");
    android.setRecommended("1.0");
    config.setAndroid(android);
    
    assertThatThrownBy(() -> {
        Info.Builder builder = new Info.Builder();
        new CompatibleVersionsInfoContributor(config).contribute(builder);
    }).isInstanceOf(IllegalArgumentException.class);
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e67012a and eadbb43.

⛔ Files ignored due to path filters (1)
  • src/main/resources/config/application.yml is excluded by !**/*.yml
📒 Files selected for processing (3)
  • src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java
  • src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
`src/test/java/**/*.java`: test_naming: descriptive; test_si...

src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

  • src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java (1)

1-24: LGTM! Clean implementation following best practices.

The class follows Spring Boot best practices with:

  • Constructor injection
  • Single responsibility
  • Clean integration with Spring Boot Actuator

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 16, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test2.artemis.cit.tum.de February 16, 2025 19:54 Inactive
HanyangXu0508
HanyangXu0508 previously approved these changes Feb 16, 2025
Copy link

@HanyangXu0508 HanyangXu0508 left a comment

Choose a reason for hiding this comment

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

tested on server 2
IMG_3651

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 16, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 16, 2025 21:39 Inactive
anian03
anian03 previously approved these changes Feb 16, 2025
Copy link
Member

@anian03 anian03 left a comment

Choose a reason for hiding this comment

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

Works as expected, tested it in conjunction with ls1intum/artemis-ios#291 and ls1intum/artemis-ios-core-modules#120

(I think you also need to update the name in the test though)

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 16, 2025
anian03
anian03 previously approved these changes Feb 17, 2025
SimonEntholzer
SimonEntholzer previously approved these changes Feb 17, 2025
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Code

cremertim
cremertim previously approved these changes Feb 18, 2025
Copy link
Contributor

@cremertim cremertim left a comment

Choose a reason for hiding this comment

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

Code

@krusche krusche changed the title General: Add mobile app version compatibility Development: Add mobile app version compatibility Feb 18, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 18, 2025 08:31 Inactive
simonbohnen
simonbohnen previously approved these changes Feb 18, 2025
Copy link

@simonbohnen simonbohnen left a comment

Choose a reason for hiding this comment

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

Tested on TS3, works 👌🏼

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (3)

1-8: Test class name should be more descriptive.

The test class name should reflect that it's testing the info contributor functionality, not just the configuration.

Rename the class to better reflect its purpose:

-class CompatibleVersionsInfoConfigurationTest {
+class CompatibleVersionsInfoContributorTest {

10-28: Test method should follow BDD naming pattern.

The test method name should describe the behavior being tested, following the "given/when/then" pattern for better readability.

Rename the test method and extract the setup into descriptive variables:

-    void testContribute() {
+    void shouldContributeVersionsToInfoEndpoint() {
+        // given
+        var androidVersion = "1.2.0";
+        var iosVersion = "1.6.1";
         ArtemisCompatibleVersionsConfiguration config = new ArtemisCompatibleVersionsConfiguration();
 
         ArtemisCompatibleVersionsConfiguration.Platform android = new ArtemisCompatibleVersionsConfiguration.Platform();
-        android.setMin("1.2.0");
-        android.setRecommended("1.2.0");
+        android.setMin(androidVersion);
+        android.setRecommended(androidVersion);
         config.setAndroid(android);
 
         ArtemisCompatibleVersionsConfiguration.Platform ios = new ArtemisCompatibleVersionsConfiguration.Platform();
-        ios.setMin("1.6.1");
-        ios.setRecommended("1.6.1");
+        ios.setMin(iosVersion);
+        ios.setRecommended(iosVersion);
         config.setIos(ios);
 
         CompatibleVersionsInfoContributor contributor = new CompatibleVersionsInfoContributor(config);
 
+        // when
         Info.Builder builder = new Info.Builder();
         contributor.contribute(builder);
         Info info = builder.build();

30-41: Group assertions by platform for better readability.

The assertions should be grouped logically by platform and use descriptive error messages.

Refactor the assertions:

+        // then
         assertThat(info.getDetails()).containsKey("compatibleVersions");
 
         Object value = info.getDetails().get("compatibleVersions");
-        assertThat(value).isInstanceOf(ArtemisCompatibleVersionsConfiguration.class);
+        assertThat(value)
+            .as("Info details should contain compatible versions configuration")
+            .isInstanceOf(ArtemisCompatibleVersionsConfiguration.class);
 
         ArtemisCompatibleVersionsConfiguration resultConfig = (ArtemisCompatibleVersionsConfiguration) value;
 
-        assertThat(resultConfig.getAndroid().getMin()).isEqualTo("1.2.0");
-        assertThat(resultConfig.getAndroid().getRecommended()).isEqualTo("1.2.0");
+        // verify Android versions
+        assertThat(resultConfig.getAndroid())
+            .as("Android platform configuration")
+            .satisfies(platform -> {
+                assertThat(platform.getMin()).isEqualTo(androidVersion);
+                assertThat(platform.getRecommended()).isEqualTo(androidVersion);
+            });
 
-        assertThat(resultConfig.getIos().getMin()).isEqualTo("1.6.1");
-        assertThat(resultConfig.getIos().getRecommended()).isEqualTo("1.6.1");
+        // verify iOS versions
+        assertThat(resultConfig.getIos())
+            .as("iOS platform configuration")
+            .satisfies(platform -> {
+                assertThat(platform.getMin()).isEqualTo(iosVersion);
+                assertThat(platform.getRecommended()).isEqualTo(iosVersion);
+            });
src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java (1)

29-30: Improve readability of configuration properties list.

The list of configuration properties is becoming long and harder to read. Consider extracting them into a constant or breaking them into logical groups.

Refactor the configuration properties:

+    private static final Class<?>[] CONFIGURATION_PROPERTIES = {
+        LiquibaseProperties.class,
+        ProgrammingLanguageConfiguration.class,
+        TheiaConfiguration.class,
+        LicenseConfiguration.class,
+        ArtemisCompatibleVersionsConfiguration.class
+    };
+
 @SpringBootApplication
-@EnableConfigurationProperties({ LiquibaseProperties.class, ProgrammingLanguageConfiguration.class, TheiaConfiguration.class, LicenseConfiguration.class,
-        ArtemisCompatibleVersionsConfiguration.class })
+@EnableConfigurationProperties(CONFIGURATION_PROPERTIES)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e686b23 and eca8c71.

⛔ Files ignored due to path filters (1)
  • src/main/resources/config/application.yml is excluded by !**/*.yml
📒 Files selected for processing (3)
  • src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
🧰 Additional context used
📓 Path-based instructions (2)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java
`src/test/java/**/*.java`: test_naming: descriptive; test_si...

src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

  • src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-style
  • GitHub Check: server-style
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java (1)

21-21: LGTM!

The import statement follows the coding guidelines.

@helios-aet helios-aet bot temporarily deployed to artemis-test2.artemis.cit.tum.de February 18, 2025 14:03 Inactive
@krusche krusche added this to the 7.10.2 milestone Feb 18, 2025
@krusche krusche merged commit aef9f65 into develop Feb 18, 2025
30 of 33 checks passed
@krusche krusche deleted the chore/compatible-versions branch February 18, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config-change Pull requests that change the config in a way that they require a deployment via Ansible. core Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

8 participants