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

Integrated code lifecycle: Provide Instructors more options to control container configuration #9487

Open
wants to merge 66 commits into
base: develop
Choose a base branch
from

Conversation

BBesrour
Copy link
Member

@BBesrour BBesrour commented Oct 15, 2024

Contains migration (Doesn't break TS)

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 principle of data economy for all 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).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

We want instructors to be able to configure some docker flags. For now, this is restricted to disabling internet access when running the student code and to add env vars to the container.

Description

  • Disabling network access: To disable network access, we run this command docker network disconnect bridge <container-name> using the java docker API. However, some programming languages need to download dependencies to correctly run the submissions. Thus, after a container is started, we run a script to download dependencies. The script depends on the programming language. After that script is run, we execute the mentioned docker command and proceed with the build job as usual. The instructor will have to cache the dependencies in the docker image.
  • Environment variables: We parse the environment variables and pass them to the start container command.

Steps for Testing

Prerequisites:

  • 1 Instructor

Testing disabling network access

  1. Go to programming exercise creation (Choose java with project type maven)
  2. Check the Edit Build Script checkbox
  3. Check the Disable network access checkbox
  4. Make sure that the tooltip is helpful and explains the feature correctly
  5. change docker image to bbesrour/artemis-maven-docker-with-depedencies:1.0. This image has the necessary dependencies cached.
  6. Create exercise
  7. Make sure that the solution build is successful.
  8. Edit image back to it's default value (ls1tum/artemis-maven-template:java17-21) and retrigger the template and solution build. Both should fail

Testing env vars

  1. Go to programming exercise edit (or create a new one)
  2. Check the Edit Build Script checkbox
  3. In the environment variables option, enter environment variables (you have to click on add env var, then enter the key/value pair)
  4. In the build script, add this line echo $<env_var_key>
  5. Save and run a buildjob for that exercise
  6. Check that the value of the env var you added is present in the build logs

Unchanged Behavior

  1. Make sure that creating programming exercises work correctly if you don't change the build configuration

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2
Class/File Line Coverage Confirmation (assert/expect)
programming-exercise-build-configuration.component.ts 83.33% ✅ ❌

Server

Class/File Line Coverage Confirmation (assert/expect)
BuildConfig.java 100%
DockerFlagsDTO.java 100%
DockerRunConfig.java 100%
BuildJobContainerService.java 80% ✅ ❌
BuildJobExecutionService.java 71% ✅ ❌
Constants.java 100%
ProgrammingExerciseBuildConfig.java 62% ✅ ❌
ProgrammingExerciseBuildConfigService.java 85% ✅ ❌
ProgrammingExerciseService.java 86% ✅ ❌
LocalCITriggerService.java 89% ✅ ❌
ProgrammingExerciseExportImportResource.java 93% ✅ ❌
ProgrammingExerciseResource.java 82% ✅ ❌

Screenshots

docker-flags-edit

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Docker configuration settings for programming exercises, allowing customization of network access and environment variables.
    • Added validation for Docker flags during exercise setup and import processes.
  • Enhancements

    • Improved error handling and validation mechanisms across various services related to Docker configurations.
    • Updated user interface to include options for disabling network access and managing environment variables.
    • Enhanced the programming exercise setup documentation to clarify Docker configuration options and their implications.
  • Documentation

    • Expanded user guides to clarify new Docker configuration options and their implications for programming exercises.

@coderabbitai ignore

@BBesrour BBesrour self-assigned this Oct 15, 2024
@BBesrour BBesrour requested a review from a team as a code owner October 15, 2024 07:53
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) buildagent Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module labels Oct 15, 2024
Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

This pull request introduces significant enhancements to Docker configuration management within the application. A new record class, DockerRunConfig, is added to encapsulate Docker run settings, including network access and environment variables. Several services, such as BuildJobContainerService and BuildJobExecutionService, are updated to incorporate new parameters for handling Docker configurations. The frontend JSON files are modified to include new options for Docker settings, and various validation methods are introduced to ensure proper configuration during exercise setup. Additionally, multiple tests are adjusted or added to cover the new functionality.

Changes

File Path Change Summary
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java Added DockerRunConfig record with fields isNetworkDisabled and env, and an enum AllowedDockerFlags for flag validation.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java Updated methods to include new parameters for environment variables and network settings, enhancing container configuration capabilities.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java Modified methods to retrieve and utilize environment variables and network settings from dockerRunConfig.
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java Added method getDockerRunConfig() for parsing Docker flags from JSON, and a helper method for environment variable extraction.
src/main/webapp/i18n/de/programmingExercise.json Introduced dockerFlags object with keys for disableNetworkAccess and envVars for German localization.
src/main/webapp/i18n/en/programmingExercise.json Introduced dockerFlags object with keys for disableNetworkAccess and envVars for English localization.
docs/user/exercises/programming-exercise-setup.inc Added sections for editing container configurations and detailed instructions for Docker settings, including environment variables and network access.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java Added validateDockerFlags() method to enhance validation for Docker configurations during exercise setup.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java Updated updateProgrammingExercise method to include Docker flags validation and improved error handling.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java Renamed test class and added testDockerFlagsParsing method to verify Docker flags parsing functionality.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java Added tests for custom checkout paths and disabling network access with environment variables.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java Enhanced import functionality with Docker flags validation and improved error handling for imports.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java Updated getBuildConfig method to include dockerRunConfig in BuildConfig constructor.
src/main/webapp/app/exercises/programming/manage/update/update-components/... Updated HTML template to include conditional rendering for network access and environment variables input fields.
src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java Modified BuildConfig constructor call in tests to accommodate new parameters.

Possibly related PRs

Suggested labels

feature, config-change

Suggested reviewers

  • SimonEntholzer
  • JohannesStoehr
  • krusche
  • Hialus
  • az108

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 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: 42

🧹 Outside diff range comments (6)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

Line range hint 1-26: Consider the following improvements for better adherence to coding guidelines

  1. Serializable Implementation:
    The BuildConfig record implements Serializable. While this might be necessary for your use case, it's generally not recommended for DTOs. Consider if this is absolutely necessary, and if so, add a comment explaining why.

  2. Comment Formatting:
    The comment about shared data structures and breaking changes is important. Consider formatting it as a proper Javadoc comment for better visibility and documentation.

  3. dockerImage() Method:
    The dockerImage() method could be simplified using the String.strip() method, which removes leading and trailing whitespace.

Here are the suggested changes:

+ /**
+  * This data structure is used in shared code between core and build agent nodes.
+  * Changing it requires that the shared data structures in Hazelcast (or potentially Redis)
+  * in the future are migrated or cleared. Changes should be communicated in release notes
+  * as potentially breaking changes.
+  */
 @JsonIgnoreProperties(ignoreUnknown = true)
 @JsonInclude(JsonInclude.Include.NON_EMPTY)
 public record BuildConfig(String buildScript, String dockerImage, String commitHashToBuild, String assignmentCommitHash, String testCommitHash, String branch,
         ProgrammingLanguage programmingLanguage, ProjectType projectType, boolean scaEnabled, boolean sequentialTestRunsEnabled, boolean testwiseCoverageEnabled,
         List<String> resultPaths, int timeoutSeconds, String assignmentCheckoutPath, String testCheckoutPath, String solutionCheckoutPath, DockerRunConfig dockerRunConfig)
         implements Serializable {

     @Override
     public String dockerImage() {
-        // make sure to avoid whitespace issues
-        return dockerImage.trim();
+        return dockerImage.strip();
     }
 }

These changes improve code documentation and simplify the dockerImage() method. Please ensure that the Serializable implementation is necessary before making any changes related to it.

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (1)

Line range hint 1-386: Consider adding new test cases for the updated BuildConfig.

While the existing tests have been updated to accommodate the new BuildConfig parameters, consider adding specific test cases to verify the functionality associated with these new parameters. This will ensure comprehensive coverage of the new features introduced in the BuildConfig class.

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (2)

Line range hint 196-207: Consider enhancing error handling for validation steps.

While the added validation for build plan network access is good, consider wrapping each validation step in a try-catch block to provide more specific error messages. This would help in identifying which validation step failed and provide better feedback to the user.

Here's a suggested refactoring:

 newExercise.validateGeneralSettings();
 newExercise.validateProgrammingSettings();
 newExercise.validateSettingsForFeedbackRequest();
-newExercise.validateBuildPlanNetworkAccessForProgrammingLanguage();
+try {
+    newExercise.validateBuildPlanNetworkAccessForProgrammingLanguage();
+} catch (Exception e) {
+    throw new BadRequestAlertException("Invalid build plan network access configuration: " + e.getMessage(), ENTITY_NAME, "invalidBuildPlanNetworkAccess");
+}
 validateStaticCodeAnalysisSettings(newExercise);

This change would provide a more specific error message if the build plan network access validation fails.


Line range hint 1-1: Enhance API documentation with OpenAPI annotations.

While the existing Javadoc comments provide good documentation for the endpoints, consider adding OpenAPI (formerly Swagger) annotations to improve API documentation. This would make it easier for clients to understand and interact with the API.

Here's an example of how you could enhance the documentation for the importProgrammingExercise endpoint:

@Operation(summary = "Import an existing programming exercise into a course", description = "Imports the whole exercise, including all base build plans and repositories.")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200", description = "Successfully imported the exercise"),
    @ApiResponse(responseCode = "403", description = "Forbidden - user doesn't have required role"),
    @ApiResponse(responseCode = "404", description = "Not Found - template doesn't exist")
})
@PostMapping("programming-exercises/import/{sourceExerciseId}")
@EnforceAtLeastEditor
public ResponseEntity<ProgrammingExercise> importProgrammingExercise(
    @Parameter(description = "ID of the original exercise to import") @PathVariable long sourceExerciseId,
    @Parameter(description = "New exercise details") @RequestBody ProgrammingExercise newExercise,
    @Parameter(description = "Whether to recreate build plans") @RequestParam(defaultValue = "false") boolean recreateBuildPlans,
    @Parameter(description = "Whether to update the template") @RequestParam(defaultValue = "false") boolean updateTemplate,
    @Parameter(description = "Whether to set test case visibility to after due date") @RequestParam(defaultValue = "false") boolean setTestCaseVisibilityToAfterDueDate) throws JsonProcessingException {
    // ... existing method body ...
}

Add the necessary imports for OpenAPI annotations:

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;

Apply similar annotations to other endpoints in this controller to improve overall API documentation.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1)

Line range hint 442-451: Approve the implementation of checkout directory validation.

The validateCheckoutDirectoriesUnchanged method effectively ensures that custom checkout paths remain unchanged during updates, which is crucial for maintaining consistency in the exercise configuration.

To improve readability, consider extracting the comparison logic into a separate private method. For example:

+private boolean checkoutPathsUnchanged(ProgrammingExerciseBuildConfig original, ProgrammingExerciseBuildConfig updated) {
+    return Objects.equals(original.getAssignmentCheckoutPath(), updated.getAssignmentCheckoutPath())
+        && Objects.equals(original.getSolutionCheckoutPath(), updated.getSolutionCheckoutPath())
+        && Objects.equals(original.getTestCheckoutPath(), updated.getTestCheckoutPath());
+}

public void validateCheckoutDirectoriesUnchanged(ProgrammingExercise originalProgrammingExercise, ProgrammingExercise updatedProgrammingExercise) {
    var originalBuildConfig = originalProgrammingExercise.getBuildConfig();
    var updatedBuildConfig = updatedProgrammingExercise.getBuildConfig();
-   if (!Objects.equals(originalBuildConfig.getAssignmentCheckoutPath(), updatedBuildConfig.getAssignmentCheckoutPath())
-           || !Objects.equals(originalBuildConfig.getSolutionCheckoutPath(), updatedBuildConfig.getSolutionCheckoutPath())
-           || !Objects.equals(originalBuildConfig.getTestCheckoutPath(), updatedBuildConfig.getTestCheckoutPath())) {
+   if (!checkoutPathsUnchanged(originalBuildConfig, updatedBuildConfig)) {
        throw new BadRequestAlertException("The custom checkout paths cannot be changed!", "programmingExercise", "checkoutDirectoriesChanged");
    }
}

This refactoring improves readability and makes the main method more concise.

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (1)

Line range hint 241-257: Refactor runScriptAndParseResults to reduce the number of parameters

The method runScriptAndParseResults has a large number of parameters, which can make the code difficult to read and maintain. According to the Single Responsibility Principle and the guideline for small methods, consider encapsulating related parameters into an object to improve readability and maintainability.

Consider creating a BuildJobContext class to group related parameters:

public class BuildJobContext {
    private VcsRepositoryUri assignmentRepositoryUri;
    private VcsRepositoryUri testRepositoryUri;
    private VcsRepositoryUri solutionRepositoryUri;
    private VcsRepositoryUri[] auxiliaryRepositoriesUris;
    private Path assignmentRepositoryPath;
    private Path testsRepositoryPath;
    private Path solutionRepositoryPath;
    private Path[] auxiliaryRepositoriesPaths;
    private String assignmentRepoCommitHash;
    private String testRepoCommitHash;
    private boolean isNetworkDisabled;
    // getters and setters
}

Then, update the method signature:

-private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String containerName, String containerId, VcsRepositoryUri assignmentRepositoryUri,
-        VcsRepositoryUri testRepositoryUri, VcsRepositoryUri solutionRepositoryUri, VcsRepositoryUri[] auxiliaryRepositoriesUris, Path assignmentRepositoryPath,
-        Path testsRepositoryPath, Path solutionRepositoryPath, Path[] auxiliaryRepositoriesPaths, @Nullable String assignmentRepoCommitHash,
-        @Nullable String testRepoCommitHash, boolean isNetworkDisabled) {
+private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String containerName, String containerId, BuildJobContext context) {

And update the method calls accordingly. This refactoring aligns with best practices and enhances code maintainability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a5167be and 8ec3f57.

📒 Files selected for processing (23)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (7 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1 hunks)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (3 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/TestBuildAgentConfiguration.java (2 hunks)
  • src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (22)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

Pattern 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/buildagent/dto/DockerRunConfig.java (1)

Pattern 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/buildagent/service/BuildJobContainerService.java (1)

Pattern 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/buildagent/service/BuildJobExecutionService.java (1)

Pattern 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/programming/domain/ProgrammingExercise.java (1)

Pattern 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/programming/domain/ProgrammingExerciseBuildConfig.java (1)

Pattern 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/programming/service/ProgrammingExerciseService.java (1)

Pattern 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/programming/service/ci/ContinuousIntegrationService.java (1)

Pattern 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/programming/service/localci/LocalCITriggerService.java (1)

Pattern 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/programming/web/ProgrammingExerciseExportImportResource.java (1)

Pattern 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/programming/web/ProgrammingExerciseResource.java (1)

Pattern 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/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/i18n/de/programmingExercise.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1)

Pattern 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/programming/icl/LocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIResourceIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIServiceTest.java (1)

Pattern 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/programming/icl/LocalVCLocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/TestBuildAgentConfiguration.java (1)

Pattern 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/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (2)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-06-15T20:04:18.637Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:42.972Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
🪛 Biome
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts

[error] 22-22: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 30-30: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 74-74: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 74-74: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts

[error] 81-81: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)

🔇 Additional comments (27)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

18-19: New parameter added to BuildConfig record

The DockerRunConfig dockerRunConfig parameter has been added to the BuildConfig record. This change extends the configuration options for Docker runs, which aligns with the PR objectives of providing instructors more control over container configuration.

A few points to consider:

  1. The addition maintains the single responsibility principle as it's related to build configuration.
  2. The change adheres to the camelCase naming convention.
  3. The use of a separate DockerRunConfig class follows good practices for code organization and reusability.

To ensure this change doesn't break existing code, let's verify its usage:

✅ Verification successful

BuildConfig constructor usages are correctly updated

All instances of BuildConfig constructors have been updated to include the dockerRunConfig parameter. No issues detected with existing usages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for BuildConfig usages that might need updating

# Search for BuildConfig constructor calls
echo "Searching for BuildConfig constructor calls:"
rg --type java "new BuildConfig\(" -A 3

# Search for BuildConfig method references
echo "Searching for BuildConfig method references:"
rg --type java "BuildConfig::" -A 1

Length of output: 4373

src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (4)

1-8: LGTM: Class structure and imports are well-defined.

The DockerRunConfig class is properly structured:

  • Class name follows CamelCase convention.
  • Implements Serializable, which is appropriate for a DTO.
  • Package name follows the reverse domain name convention.
  • Imports are specific and avoid wildcard imports.

10-20: LGTM: isNetworkDisabled field and methods are well-implemented.

The isNetworkDisabled boolean field and its accessor methods are correctly implemented:

  • Field name follows the Java convention for boolean fields.
  • Getter method uses the isXxx() convention.
  • Setter method follows the setXxx(Type value) convention.
  • Methods provide appropriate public access for a DTO.

30-55: LGTM: AllowedDockerFlags enum is well-implemented.

The AllowedDockerFlags enum is correctly implemented with good practices:

  • Enum name follows CamelCase convention.
  • Constants follow uppercase naming convention.
  • Private constructor and final field for the flag value.
  • Efficient static initialization of ALLOWED_FLAGS.
  • Useful isAllowed method for flag validation.

The implementation provides a clean and type-safe way to manage allowed Docker flags.


1-56: Overall implementation is well-structured and follows best practices.

The DockerRunConfig class is a well-implemented DTO for Docker run configurations:

  • Adheres to the single responsibility principle.
  • Follows Java naming conventions and best practices.
  • Maintains proper encapsulation with getter/setter methods.
  • Includes a useful inner enum for managing allowed Docker flags.

The code is clean, simple, and easy to understand, following the KISS principle. It provides a solid foundation for managing Docker run configurations in the Artemis platform.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

Line range hint 8-17: LGTM! Correct usage of new Angular syntax and property binding.

The changes look good:

  1. The new property binding [programmingExercise]="programmingExercise" is correctly implemented, passing the programmingExercise object to the child component.
  2. The @if syntax is used correctly for conditional rendering, adhering to the coding guidelines.
  3. The overall structure and logic of the template remain intact.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1)

52-52: LGTM! Improved layout structure.

The addition of the flexbox container improves the layout and alignment of the timeout input section.

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (5)

6-8: LGTM: New imports are appropriate for the added test cases.

The new imports for ProgrammingExercise, ProgrammingLanguage, Course, and ProgrammingExerciseBuildConfig are necessary and correctly added for the new test cases.


30-30: LGTM: Appropriate setup for new test cases.

The addition of programmingExercise as an input to the component is correct and necessary for the new test cases. This setup ensures that the component has the required data to test the new functionality.


47-55: LGTM: Comprehensive test case for network access toggle.

This test case effectively verifies the behavior of enabling and disabling network access. It checks both the isNetworkDisabled flag and the dockerFlags property, ensuring that the component correctly updates its state and configuration.

The use of toBeTrue() and toBeFalse() for boolean assertions is in line with the provided coding guidelines.


57-65: LGTM: Well-structured test case for environment variables.

This test case effectively verifies the behavior of updating environment variables. It checks both the envVars property and the dockerFlags property, ensuring that the component correctly updates its state and configuration when environment variables are set and cleared.

The assertions use the recommended toBe() method, which is appropriate for these equality checks.


67-78: LGTM: Comprehensive test case for combined network and environment variable changes.

This test case effectively verifies the behavior of the component when both network access and environment variables are modified. It covers multiple scenarios:

  1. Enabling network restrictions and setting environment variables
  2. Disabling network restrictions while keeping environment variables
  3. Re-enabling network restrictions and clearing environment variables

The assertions use the recommended toBe() method, which is appropriate for these equality checks. The test ensures that the dockerFlags property is correctly updated in each scenario, demonstrating the component's ability to handle multiple configuration changes simultaneously.

src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1)

94-95: LGTM! Consider verifying BuildConfig usage consistency.

The addition of the new null parameter to the BuildConfig constructor is correct and aligns with the reported changes in the BuildConfig class. This change maintains the test's adherence to the coding guidelines, particularly in terms of test naming, size, and use of fixed data.

To ensure consistency, please run the following script to check if all BuildConfig constructor calls in this test class have been updated:

If any occurrences are found with fewer parameters, they should be updated to match this change.

✅ Verification successful

Consistency Confirmed! All BuildConfig constructor calls in BuildAgentDockerServiceTest.java have been updated with the new parameter.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all BuildConfig constructor calls in the test class have been updated with the new parameter.

# Test: Search for BuildConfig constructor calls
rg --type java 'new BuildConfig\(' src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java

Length of output: 301

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java (1)

Line range hint 1-238: Well-structured test class adhering to coding guidelines.

The LocalCIServiceTest class demonstrates good adherence to the provided coding guidelines:

  1. Test naming is descriptive and clear.
  2. Test methods are small and specific to individual functionalities.
  3. JUnit 5 features are utilized appropriately.
  4. AssertJ's assertThat is used for assertions, enhancing readability.
  5. The class structure is well-organized, including a nested class for related tests.

Keep up the good work in maintaining high-quality test code!

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (2)

27-27: New import added for DockerRunConfig

The addition of this import suggests that Docker run configurations are now being incorporated into the build process. This aligns with the PR objectives of providing instructors more options to control container configuration.


Line range hint 311-322: Consider additional documentation and error handling for Docker run configuration

The integration of Docker run configurations is a significant feature addition. To ensure maintainability and robustness:

  1. Consider adding a comment or documentation explaining the purpose and structure of the Docker run configuration.
  2. Implement error handling for the getDockerRunConfigFromString() method call to gracefully handle potential parsing errors.
  3. Ensure that unit tests are updated or added to cover this new functionality.

Example documentation:

// Parse Docker run configuration from the build config
// This configuration includes settings such as network access and environment variables
DockerRunConfig dockerRunConfig = buildConfig.getDockerRunConfigFromString();

// TODO: Add error handling for getDockerRunConfigFromString()

To check for existing tests related to this functionality:

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (2)

Line range hint 1-828: Summary and Recommendations

The addition of the validateBuildPlanNetworkAccessForProgrammingLanguage() method is a positive improvement to the ProgrammingExercise class. It adds necessary validation for network access features based on programming languages.

Recommendations:

  1. Implement the suggested refactoring to improve readability and maintainability.
  2. Ensure the method is being called appropriately in other parts of the codebase (use the provided verification script).
  3. Consider adding unit tests for this new validation method to ensure its correctness and prevent regressions.
  4. Update any relevant documentation to reflect this new validation step in the exercise creation or configuration process.

Overall, these changes enhance the robustness of the system by preventing unsupported configurations. With the suggested improvements, they will also contribute to better code quality and maintainability.


818-828: Verify usage of the new validation method across the codebase.

The new validateBuildPlanNetworkAccessForProgrammingLanguage() method is public, suggesting it should be called from other parts of the codebase. Let's verify its usage to ensure it's being utilized correctly.

Run the following script to check for usage of the new method:

This script will help us identify where the new method is being used or referenced in the codebase, allowing us to ensure it's properly integrated and utilized.

✅ Verification successful

Usage of validateBuildPlanNetworkAccessForProgrammingLanguage() is correctly implemented.

The new method validateBuildPlanNetworkAccessForProgrammingLanguage() is appropriately called in the following locations:

  • ProgrammingExerciseExportImportResource.java
  • ProgrammingExerciseResource.java
  • ProgrammingExerciseService.java

No unauthorized or unintended usages were detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of validateBuildPlanNetworkAccessForProgrammingLanguage method

# Search for method calls
echo "Searching for method calls:"
rg --type java "validateBuildPlanNetworkAccessForProgrammingLanguage\(\)" -g '!ProgrammingExercise.java'

# Search for references to the method (e.g., in comments or string literals)
echo "Searching for method references:"
rg --type java "validateBuildPlanNetworkAccessForProgrammingLanguage" -g '!ProgrammingExercise.java'

Length of output: 1395

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (2)

202-202: LGTM: Added validation for build plan network access.

The new line newExercise.validateBuildPlanNetworkAccessForProgrammingLanguage(); adds an important validation step for the build plan network access based on the programming language. This is a good addition to ensure the exercise configuration is valid before proceeding with the import.


Line range hint 1-1: Overall, well-structured and secure implementation.

The ProgrammingExerciseExportImportResource class is well-implemented, following good practices for Spring REST controllers. It demonstrates proper use of authorization checks, dependency injection, and adherence to the single responsibility principle. The added validation for build plan network access enhances the robustness of the import process.

Minor suggestions for improvement include:

  1. Enhancing error handling for validation steps to provide more specific error messages.
  2. Adding OpenAPI annotations to improve API documentation.

These changes would further improve the already solid implementation.

src/main/webapp/i18n/en/programmingExercise.json (1)

Line range hint 1-700: Overall changes look good and align with PR objectives.

The additions to the programmingExercise.json file successfully introduce new Docker configuration options for instructors. These changes are consistent with the existing file structure and translation style. The new options (disabling network access and adding environment variables) enhance the flexibility of container configuration as intended.

Key improvements:

  1. Added "dockerFlags" section with "disableNetworkAccess" and "envVars" options.
  2. Provided clear titles and descriptions for the new options.

No other parts of the file were modified, maintaining the integrity of existing translations.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1)

Line range hint 1-1180: Overall assessment: Changes enhance exercise configuration options as intended.

The modifications to ProgrammingExerciseService.java successfully implement the PR objectives by adding network access validation and ensuring the immutability of checkout directories. These changes provide instructors with more control over container configuration while maintaining consistency in exercise settings. The code quality is good, with only minor suggestions for improvement in readability and error handling.

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (1)

3-4: Approved: Necessary imports added

The added import statements are appropriate for the new functionalities and comply with the coding guidelines.

Also applies to: 7-8, 17-17, 25-26, 28-28

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (2)

91-97: Method signature updated correctly.

The method configureContainer has been updated to include List<String> exerciseEnvVars, and the parameter is properly documented and handled within the method.


Line range hint 36-51: Imports added appropriately.

The new import statements for CreateContainerCmd, ProjectType, and DependencyDownloadScript are necessary for the updated functionality and are correctly included.

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)

333-334: Validation method added for network access compatibility

The addition of validateBuildPlanNetworkAccessForProgrammingLanguage() ensures that the selected network access option is compatible with the programming language of the programming exercise. This enhances the validation process and prevents potential misconfigurations.

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (1)

61-61: [Approved] Addition of required import

The import statement for ProgrammingExerciseBuildConfig is necessary for the new test method and is appropriately added.

Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

The pull request introduces several changes primarily focused on enhancing Docker configuration management within the build process. A new DockerRunConfig class is added, and the existing BuildConfig record is modified to include this new configuration. Various service classes are updated to handle additional parameters for environment variables and network settings. Additionally, validation methods are introduced for programming exercises to ensure compatibility with the new Docker configurations, along with modifications to the frontend components and corresponding tests.

Changes

File Path Change Summary
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java Updated BuildConfig to include dockerRunConfig field.
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java Added new class DockerRunConfig with fields for network settings and environment variables.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java Modified methods to include parameters for environment variables and network configurations.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java Updated methods to handle environment variables and network configuration for Docker execution.
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java Added method validateBuildPlanNetworkAccessForProgrammingLanguage() for network access validation.
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java Added method to convert JSON string to DockerRunConfig.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java Updated validation logic to include network access checks.
src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java Introduced DependencyDownloadScript enum for managing language-specific dependency scripts.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java Updated getBuildConfig method to include dockerRunConfig.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java Added validation step in importProgrammingExercise method.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java Enhanced updateProgrammingExercise method with new validation logic.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html Modified HTML template to include new input fields for Docker configuration.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts Updated component to manage Docker flags and language support.
src/main/webapp/i18n/de/programmingExercise.json Added new entries for Docker flags in the German i18n file.
src/main/webapp/i18n/en/programmingExercise.json Added new entries for Docker flags in the English i18n file.
src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java Updated BuildConfig constructor in tests to include new parameter.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java Added new test methods for Docker flags and custom checkout paths.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java Updated createJobs method to include new parameter in BuildConfig.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java Updated BuildConfig instantiation in tests to include new parameters.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java Restructured tests and added method for verifying Docker flags parsing.
src/test/java/de/tum/cit/aet/artemis/programming/icl/TestBuildAgentConfiguration.java Introduced mock setup for network disconnection commands in tests.
src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts Enhanced test suite with new cases for Docker flags and environment variables.

Possibly related PRs

Suggested labels

ready for review, config-change, component:Programming, priority:high

Suggested reviewers

  • JohannesStoehr
  • SimonEntholzer
  • edkaya
  • BBesrour
  • krusche

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 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: 39

🧹 Outside diff range comments (4)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

Line range hint 3-7: Replace star imports with specific imports

To improve code readability and adhere to the coding guideline of avoiding star imports, consider replacing the star imports with specific imports for the classes you're using.

Replace:

import java.util.*;
import com.fasterxml.jackson.annotation.*;

With specific imports for the classes you're using, such as:

import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (1)

Line range hint 1-386: Review overall test coverage for BuildConfig changes

The BuildConfig constructor has been consistently updated throughout this test file to include an additional parameter. To ensure the robustness of the test suite:

  1. Review all test methods that use BuildConfig to ensure they're still valid and comprehensive.
  2. Consider adding new test cases that specifically target the functionality related to the new BuildConfig parameter.
  3. Update the class-level documentation to reflect the changes in the BuildConfig usage, if necessary.
  4. Verify that these changes align with any modifications made to the main BuildConfig class and its usage in the production code.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1)

Line range hint 1-1000: Consider refactoring for improved maintainability

While the class adheres to the single responsibility principle at a high level, there are several areas where improvements could be made:

  1. Method length: Some methods, like importProgrammingExercise, are quite long and complex. Consider breaking them down into smaller, more focused methods.

  2. Class size: The file is very long. Consider splitting it into smaller, more focused classes, each handling a specific aspect of the export/import process.

  3. Error handling: The class uses a mix of custom exceptions and ResponseEntity returns. Consider standardizing the error handling approach across all methods.

  4. Logging: While there is some logging, consider adding more detailed logging, especially for complex operations, to aid in debugging and monitoring.

  5. Dependency injection: The constructor has many dependencies. Consider grouping related dependencies into service classes to reduce the number of direct dependencies.

These refactoring suggestions aim to improve the overall maintainability and readability of the code. Implementing these changes could make the codebase easier to understand, test, and maintain in the long run.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1)

Line range hint 1-1293: Approve the overall structure with a suggestion for future improvement.

The ProgrammingExerciseService class is well-structured and follows good practices such as dependency injection and the single responsibility principle. The integration of the new validation step is seamless and doesn't disrupt the existing flow.

For future improvements, consider breaking down this large service class into smaller, more focused services. For example, you could create separate services for:

  1. Exercise creation and setup
  2. Exercise validation
  3. Build plan management
  4. Repository management

This refactoring would improve maintainability and make the codebase easier to navigate and test. However, this is not an urgent change and can be considered for future refactoring efforts.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a5167be and 8ec3f57.

📒 Files selected for processing (23)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (7 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1 hunks)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (3 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/TestBuildAgentConfiguration.java (2 hunks)
  • src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (22)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

Pattern 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/buildagent/dto/DockerRunConfig.java (1)

Pattern 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/buildagent/service/BuildJobContainerService.java (1)

Pattern 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/buildagent/service/BuildJobExecutionService.java (1)

Pattern 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/programming/domain/ProgrammingExercise.java (1)

Pattern 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/programming/domain/ProgrammingExerciseBuildConfig.java (1)

Pattern 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/programming/service/ProgrammingExerciseService.java (1)

Pattern 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/programming/service/ci/ContinuousIntegrationService.java (1)

Pattern 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/programming/service/localci/LocalCITriggerService.java (1)

Pattern 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/programming/web/ProgrammingExerciseExportImportResource.java (1)

Pattern 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/programming/web/ProgrammingExerciseResource.java (1)

Pattern 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/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/i18n/de/programmingExercise.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1)

Pattern 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/programming/icl/LocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIResourceIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIServiceTest.java (1)

Pattern 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/programming/icl/LocalVCLocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/TestBuildAgentConfiguration.java (1)

Pattern 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/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (3)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-06-15T20:04:18.637Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:42.972Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:48.767Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
🪛 Biome
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts

[error] 22-22: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 30-30: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 74-74: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 74-74: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts

[error] 81-81: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)

🔇 Additional comments (31)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (5)

8-8: LGTM: Class structure and naming convention.

The DockerRunConfig class is well-structured and follows the CamelCase naming convention. Implementing Serializable is appropriate for DTOs, allowing for easy serialization if needed.


10-20: LGTM: Field isNetworkDisabled and its accessor methods.

The boolean field isNetworkDisabled and its getter/setter methods are correctly implemented following Java conventions for boolean fields.


12-28: LGTM: Field env and its accessor methods.

The env field of type List<String> and its getter/setter methods are correctly implemented following Java conventions. The type is appropriate for storing environment variables.


30-55: LGTM: Well-implemented AllowedDockerFlags enum.

The AllowedDockerFlags enum is well-designed and implemented:

  • It provides type-safe constants for allowed Docker flags.
  • The static ALLOWED_FLAGS set and isAllowed method offer an efficient way to check flag validity.
  • The implementation follows good practices and is easy to maintain and extend if needed.

1-56: Overall: Well-structured and implemented DockerRunConfig class.

The DockerRunConfig class is well-designed and implemented, adhering to Java conventions and best practices:

  • It follows the single responsibility principle, focusing solely on Docker run configuration.
  • The code is clean, simple, and easy to understand (KISS principle).
  • Proper encapsulation is maintained with private fields and public getter/setter methods.
  • The inner AllowedDockerFlags enum provides a type-safe and efficient way to manage allowed Docker flags.

The implementation aligns well with the PR objectives, providing a structure to manage Docker container configurations, particularly for network settings and environment variables.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (4)

8-8: Correct usage of new Angular syntax.

The template correctly uses the new @if directive instead of the older *ngIf. This aligns with the provided coding guidelines, which recommend using @if and @for over the old style.

Also applies to: 9-9


Line range hint 1-30: Well-structured template with clear user interface.

The template is well-organized and provides a clear interface for customizing build plans:

  1. The checkbox for enabling/disabling custom build plans is implemented correctly using two-way binding.
  2. Additional configuration options are conditionally rendered when the custom build plan is enabled.
  3. Appropriate use of Artemis-specific components (jhi-help-icon, jhi-monaco-editor) enhances functionality.
  4. The code editor for script input is well-integrated.

The overall structure follows Angular best practices and provides a good user experience for managing build configurations.


Line range hint 1-30: Summary: Changes align with PR objectives and guidelines.

The modifications to this template file successfully implement the PR's objective of enhancing Docker configuration management. The addition of the programmingExercise input to the build configuration component allows for more flexible container configuration, aligning with the goal of providing instructors more options.

The template adheres to the provided coding guidelines, particularly in its use of new Angular syntax (@if). The overall structure is well-organized and provides a clear interface for customizing build plans.

While the changes are approved, consider the suggestions regarding data encapsulation and potential performance implications of passing the entire programmingExercise object to the child component.


11-11: LGTM! Consider performance and data encapsulation.

The addition of [programmingExercise]="programmingExercise" to the jhi-programming-exercise-build-configuration component is a valid change. It allows the child component to access all properties of the programming exercise, which can be beneficial for build configuration.

However, consider the following points:

  1. Data encapsulation: Passing the entire programmingExercise object might expose more data than necessary to the child component. Consider passing only the required properties if possible.
  2. Performance: If programmingExercise is a large object, passing it entirely might impact change detection performance. Monitor for any performance issues in complex scenarios.

To ensure that only necessary properties are used, let's check the implementation of the jhi-programming-exercise-build-configuration component:

✅ Verification successful

Verified the addition of [programmingExercise]="programmingExercise". The programmingExercise object is extensively utilized within the jhi-programming-exercise-build-configuration component, justifying the need to pass the entire object. No unnecessary data exposure or significant performance implications detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the usage of programmingExercise in the build configuration component

# Test: Search for properties of programmingExercise used in the component
rg --type typescript -g "programming-exercise-build-configuration.component.ts" "programmingExercise\."

# Test: Check the inputs of the component
rg --type typescript -g "programming-exercise-build-configuration.component.ts" "@Input\\(\\)"

Length of output: 266


Script:

#!/bin/bash
# Description: Check the usage of programmingExercise in the build configuration component without specifying file type

# Test: Search for properties of programmingExercise used in the component
rg "programmingExercise\." src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-configuration.component.ts

# Test: Check the inputs of the component
rg "@Input\(" src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-configuration.component.ts

Length of output: 740


Script:

#!/bin/bash
# Description: Check the usage of programmingExercise in the build configuration component with corrected file path

# Test: Search for properties of programmingExercise used in the component
rg "programmingExercise\." src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts

# Test: Check the inputs of the component
rg "@Input\(" src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts

Length of output: 3712

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (2)

19-52: Overall, great implementation of new Docker configuration features!

The changes successfully implement the new features for disabling network access and adding environment variables, aligning well with the PR objectives. The use of the new Angular syntax (@if) is consistent with the coding guidelines. The UI elements are well-structured with appropriate labels and help icons.

A few minor suggestions were made to enhance accessibility and clarify the environment variable input validation. Once these are addressed, the changes look ready to be merged.


36-51: LGTM! Please clarify the ENV_VAR_REGEX pattern.

The implementation of the environment variables input aligns well with the PR objectives. Good job on including input validation using a regex pattern.

Could you please clarify the specific format that ENV_VAR_REGEX enforces? This information would be helpful for understanding the expected input format and ensuring it meets the requirements for Docker environment variables.

Additionally, let's verify the implementation of ENV_VAR_REGEX:

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (8)

6-8: LGTM: New imports added correctly.

The new imports for ProgrammingExercise, ProgrammingLanguage, Course, and ProgrammingExerciseBuildConfig are correctly added and necessary for the new test cases.


12-14: LGTM: Test objects correctly initialized.

The Course, ProgrammingExercise, and ProgrammingExerciseBuildConfig objects are properly initialized for testing purposes. The use of type assertion for the Course object is acceptable in this test context.


30-30: LGTM: ProgrammingExercise input correctly set.

The programmingExercise is properly set as an input to the component under test, which is necessary for the new test cases.


47-55: LGTM: Network flag update test case is well-implemented.

This test case thoroughly checks the behavior of the onDisableNetworkAccessChange method. It verifies both enabling and disabling network access, and correctly asserts the changes in isNetworkDisabled and dockerFlags properties. The use of toBeTrue(), toBeFalse(), and toBe() for assertions is in line with the coding guidelines.


57-65: LGTM: Environment variable update test case is well-implemented.

This test case effectively verifies the onEnvVarsChange method's behavior. It checks both setting and clearing environment variables, and correctly asserts the changes in envVars and dockerFlags properties. The use of toBe() for assertions is consistent with the coding guidelines.


67-78: LGTM: Combined network and environment variable handling test case is comprehensive.

This test case effectively verifies the interaction between network access and environment variable changes. It covers multiple scenarios, including enabling/disabling network access and setting/clearing environment variables. The assertions using toBe() are correct and in line with the coding guidelines. The test is well-structured and provides good coverage of the combined functionality.


87-95: LGTM: Supported languages test case is well-implemented.

This test case effectively verifies the setIsLanguageSupported method's behavior for different programming languages. It checks both unsupported (SWIFT) and supported (JAVA) languages, correctly asserting the isLanguageSupported property. The use of toBeTrue() and toBeFalse() for assertions is in line with the coding guidelines. The test is concise and provides good coverage of the language support functionality.


Line range hint 1-95: Overall assessment: Well-implemented test cases with good coverage.

The changes to this test file significantly improve the coverage of the ProgrammingExerciseBuildConfigurationComponent. The new test cases are well-structured, follow the coding guidelines, and effectively verify the new functionality related to Docker configuration management.

Key points:

  1. New imports and test setup are correctly implemented.
  2. Test cases cover network access, environment variables, and their interactions.
  3. Parsing of existing Docker flags and language support are well-tested.
  4. Assertions use recommended methods (toBeTrue, toBeFalse, toBe) consistently.

There was one minor suggestion regarding a non-null assertion, but overall, the changes are of high quality and ready for merging after addressing that small issue.

🧰 Tools
🪛 Biome

[error] 81-81: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (3)

27-27: Import statement for DockerRunConfig added correctly.

The new import statement for DockerRunConfig is appropriately placed and follows the coding guidelines. This addition aligns with the PR objectives of enhancing Docker configuration management.


27-27: Overall, the changes successfully integrate Docker run configurations.

The modifications effectively incorporate Docker run configurations into the build process, aligning with the PR objectives. The changes are well-integrated into the existing structure of the LocalCITriggerService class and follow the coding guidelines. Consider the suggestions for error handling and refactoring to further improve the code quality.

Also applies to: 311-312, 322-322


311-312: DockerRunConfig initialization added, but consider error handling.

The addition of DockerRunConfig dockerRunConfig aligns with the PR objectives. However, consider adding error handling for the getDockerRunConfigFromString() method to manage potential parsing errors.

To verify the error handling, you can run the following script:

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java (2)

504-517: Summary of LocalCIIntegrationTest changes

The two new test methods, testCustomCheckoutPaths and testDisableNetworkAccessAndEnvVars, are valuable additions to the test suite. They cover important functionality related to custom checkout paths and Docker flags in the build configuration. However, both methods could benefit from the following improvements:

  1. More explicit assertions to clarify what is being tested.
  2. Proper cleanup steps using try-finally blocks to ensure test isolation.
  3. Additional verification steps to confirm that the tested features (custom checkout paths and Docker flags) are working as expected.

Implementing these suggestions will enhance the robustness and clarity of the tests, making them more maintainable and reliable. Consider applying similar improvements to other test methods in this class for consistency.


508-517: 🛠️ Refactor suggestion

Enhance test coverage and add verification for Docker flags.

The test method is a good start, but it could be improved in the following ways:

  1. Make the assertion more explicit by adding a comment or splitting the testLatestSubmission call into separate act and assert steps.
  2. Add a cleanup step to reset the Docker flags after the test.
  3. Verify that the network access was actually disabled and the environment variable was set correctly.

Here's a suggested refactor:

 @Test
 @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
 void testDisableNetworkAccessAndEnvVars() {
     var buildConfig = programmingExercise.getBuildConfig();
     buildConfig.setDockerFlags("[[\"network\",\"none\"],[\"env\",\"key=value\"]]");
     ProgrammingExerciseStudentParticipation participation = localVCLocalCITestService.createParticipation(programmingExercise, student1Login);
     programmingExerciseBuildConfigRepository.save(programmingExercise.getBuildConfig());
+    try {
         localVCServletService.processNewPush(commitHash, studentAssignmentRepository.originGit.getRepository());
-        localVCLocalCITestService.testLatestSubmission(participation.getId(), commitHash, 1, false);
+        // Assert: Verify that the submission was processed correctly with the Docker flags
+        localVCLocalCITestService.testLatestSubmission(participation.getId(), commitHash, 1, false);
+    } finally {
+        buildConfig.setDockerFlags("");
+        programmingExerciseBuildConfigRepository.save(programmingExercise.getBuildConfig());
+    }
 }

Additionally, to verify that the Docker flags are working as expected:

Run the following script to verify the Docker flag effects:

Replace <container_name> with the actual name or ID of the Docker container used in the test. This script will help ensure that the Docker flags are correctly applied and functioning as intended.

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (2)

818-828: Summary: New validation method added for network access feature.

The addition of the validateBuildPlanNetworkAccessForProgrammingLanguage() method enhances the ProgrammingExercise class by providing a specific validation for the network access feature. This change:

  1. Improves the robustness of the system by preventing unsupported configurations.
  2. Clearly communicates which programming languages do not support disabling the network access feature.
  3. Follows good coding practices and integrates well with the existing class structure.

To fully benefit from this addition, ensure that:

  1. The method is called at appropriate points in the exercise creation/update workflow.
  2. The error message is properly handled and displayed to users when needed.
  3. Documentation is updated to reflect this new constraint for SWIFT and HASKELL exercises.

818-828: Verify the usage of the new validation method.

The new validateBuildPlanNetworkAccessForProgrammingLanguage() method has been added successfully. To ensure it's being used correctly:

  1. Verify that this method is called at the appropriate point in the exercise creation or update process.
  2. Check if there are any other places in the codebase where this validation should be performed.

To help with this verification, you can run the following script to find potential usage points:

This will help ensure that the new validation is properly integrated into the existing workflow.

✅ Verification successful

The new validateBuildPlanNetworkAccessForProgrammingLanguage() method is correctly utilized within the service and resource layers. No issues were found regarding its integration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find potential usage points for the new validation method

# Search for method calls
echo "Searching for direct method calls:"
rg "validateBuildPlanNetworkAccessForProgrammingLanguage\(\)" --type java

# Search for potential places where it should be called (e.g., exercise creation/update methods)
echo "Searching for potential places to call the method:"
rg "createProgrammingExercise|updateProgrammingExercise" --type java

Length of output: 47326

src/main/webapp/i18n/en/programmingExercise.json (2)

693-696: LGTM: Clear and informative entry for disabling network access

The "disableNetworkAccess" entry is well-structured and provides clear information about the feature. The description accurately explains the behavior and implications of enabling this option, which is crucial for users to understand its impact on student submissions.


692-700: LGTM: Well-integrated new Docker flags configuration

The new "dockerFlags" entries are correctly placed and well-integrated into the existing JSON structure. They complement the existing content without introducing any conflicts or structural issues.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1)

Line range hint 1-1293: Conclusion: Changes are well-implemented and align with PR objectives.

The addition of the new validation step for build plan network access is a valuable improvement that aligns well with the PR's goal of providing instructors more options to control container configuration. The implementation is clean and well-integrated into the existing validation process.

The overall structure of the ProgrammingExerciseService class remains solid, with good practices in place. While there's potential for future refactoring to improve maintainability, the current implementation is appropriate and doesn't require immediate changes.

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (1)

475-486: Ensure compatibility of switch expressions with project Java version

The getDependencyDownloadScript method uses switch expressions with the -> syntax:

private String getDependencyDownloadScript(ProgrammingLanguage programmingLanguage, ProjectType projectType) {
    return switch (programmingLanguage) {
        case JAVA -> switch (projectType) {
            case PLAIN_MAVEN, MAVEN_BLACKBOX, MAVEN_MAVEN -> DependencyDownloadScript.MAVEN.getScript();
            case PLAIN_GRADLE, GRADLE_GRADLE -> DependencyDownloadScript.GRADLE.getScript();
            default -> DependencyDownloadScript.OTHER.getScript();
        };
        case RUST -> DependencyDownloadScript.RUST.getScript();
        case JAVASCRIPT -> DependencyDownloadScript.JAVASCRIPT.getScript();
        default -> DependencyDownloadScript.OTHER.getScript();
    };
}

Switch expressions with this syntax are available from Java 14 onwards. Ensure that the project is using Java 14 or a newer version to prevent compilation issues.

Run the following script to check the Java version specified in the project's build configuration:

✅ Verification successful

Java version is compatible with switch expressions

The project is using Java version 21, which supports switch expressions with the -> syntax as required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the Java version specified in Maven and Gradle build files.

# Search for Java version in pom.xml (Maven)
rg --type xml --no-ignore-case '<maven.compiler.source>|<java.version>' pom.xml

# Search for Java version in build.gradle (Gradle)
rg --type gradle --no-ignore-case 'sourceCompatibility|targetCompatibility' build.gradle

Length of output: 1108


Script:

#!/bin/bash
# Description: Check the Java version specified in Maven and Gradle build files.

# Search for Java version in pom.xml (Maven)
rg --type xml --ignore-case '<maven.compiler.source>|<java.version>' pom.xml

# Search for Java version in build.gradle (Gradle)
rg --type gradle --ignore-case 'sourceCompatibility|targetCompatibility' build.gradle

Length of output: 312

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)

333-334: Validation of network access option is correctly implemented

The code appropriately adds a validation step to ensure that the programming language supports the selected network access option.

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: 5

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 8ec3f57 and 7c98073.

📒 Files selected for processing (3)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (1)

Pattern 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/programming/domain/ProgrammingExerciseBuildConfig.java (1)

Pattern 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/programming/service/localci/LocalCITriggerService.java (1)

Pattern 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

🔇 Additional comments (3)
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (1)

27-27: LGTM: New import statement added correctly

The import for DockerRunConfig is properly placed and follows the coding guidelines.

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (2)

819-832: Overall assessment: Approved with suggestions for improvement

The new validateBuildPlanNetworkAccessForProgrammingLanguage() method is a valuable addition to the ProgrammingExercise class, preventing incompatible configurations for specific programming languages. However, there are several areas for potential improvement:

  1. Code structure: Consider refactoring for better readability and maintainability, as suggested in previous comments.

  2. User experience: Implement frontend checks and provide more informative error messages to guide users effectively.

  3. Security: Ensure proper sandboxing and monitoring for languages that require network access.

  4. Documentation: Update relevant guides and documentation to reflect these new restrictions and their implications.

These changes will enhance the robustness of the system, improve user experience, and maintain security standards. Please consider implementing these suggestions in a follow-up commit.


819-832: Ensure security measures for languages requiring network access.

While the method correctly prevents disabling network access for SWIFT and HASKELL, it's important to consider the security implications:

  1. For languages that require network access, ensure that proper sandboxing and security measures are in place to prevent potential abuse of the network connection.

  2. Consider implementing additional security measures for SWIFT and HASKELL exercises, such as:

    • Restricting network access to only necessary domains/IPs.
    • Monitoring and logging network activity for these containers.
    • Implementing stricter timeouts for network operations.
  3. Document the security implications and any additional measures taken for exercises using these languages.

To ensure proper security measures are in place, consider running the following checks:

This will help identify any existing security measures and areas where additional precautions might be needed.

Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request introduce a new DockerRunConfig class and modify the existing BuildConfig to include it as a field. Several service classes are updated to handle new parameters related to Docker configurations, including environment variables and network settings. Additionally, validation methods are added to ensure compliance with programming language constraints regarding network access. The HTML and TypeScript components are updated to support new UI elements for configuring Docker settings. The changes aim to enhance the configurability and functionality of build processes in the Artemis platform.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java Updated BuildConfig record to include DockerRunConfig dockerRunConfig.
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java Added new class DockerRunConfig with fields for network settings and environment variables, along with validation methods for Docker flags.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java Updated methods to include new parameters for environment variables and network settings, enhancing container configuration logic.
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java Modified runBuildJob and runScriptAndParseResults methods to handle new environment variable and network settings parameters.
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java Added validateBuildPlanNetworkAccessForProgrammingLanguage() method to enforce network access rules based on programming language.
src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java Introduced getDockerRunConfigFromString() method for parsing Docker flags from JSON strings into DockerRunConfig instances.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java Integrated new validation for network access in validateNewProgrammingExerciseSettings method.
src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java Added DependencyDownloadScript enum for managing dependency download scripts by programming language.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java Updated getBuildConfig method to include DockerRunConfig in the build configuration.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java Added validation for network access during the import of programming exercises.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java Enhanced updateProgrammingExercise method with new validation for network access and updated reset method to include additional parameters.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html Added UI elements for configuring network access and environment variables in the HTML template.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts Updated component to manage state for new properties related to environment variables and network access.
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html Added property binding for programmingExercise in the custom build plan component.
src/main/webapp/i18n/de/programmingExercise.json Introduced new entries for Docker flags configuration in the German localization file.
src/main/webapp/i18n/en/programmingExercise.json Introduced new entries for Docker flags configuration in the English localization file.
src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java Updated test to reflect changes in BuildConfig constructor by adding a new parameter.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java Added new tests for custom checkout paths and Docker flag handling.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java Updated tests to reflect changes in BuildConfig constructor.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java Updated test to reflect changes in BuildConfig constructor.
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java Introduced new class DisabledBuildAgentTest and added tests for Docker flags parsing.
src/test/java/de/tum/cit/aet/artemis/programming/icl/TestBuildAgentConfiguration.java Added mock setup for DisconnectFromNetworkCmd to enhance testing capabilities.

Possibly related issues

Possibly related PRs

Suggested labels

feature, config-change, ready for review

Suggested reviewers

  • BBesrour
  • krusche
  • JohannesStoehr
  • SimonEntholzer
  • Hialus
  • az108

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 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: 40

🧹 Outside diff range comments (5)
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

Line range hint 1-31: LGTM: Template structure and syntax usage

The overall structure of the template is well-organized and follows good practices. The use of the new Angular control flow syntax (@if) for conditional rendering is correctly implemented and complies with the provided coding guidelines.

However, for consistency, consider reviewing the entire file to ensure all instances of *ngIf and *ngFor (if any) are replaced with @if and @for respectively, as per the coding guidelines.

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java (1)

Line range hint 498-507: LGTM! Consider adding assertions for custom path usage.

The test method testCustomCheckoutPaths effectively covers the functionality of custom checkout paths. It follows good practices by setting up the test environment, performing the necessary actions, and cleaning up afterwards.

To further improve the test, consider adding assertions to verify that the custom assignment path was actually used during the build process. This could involve checking build logs or examining the file structure in the test environment.

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1)

Line range hint 1-724: Consider refactoring for improved maintainability

While the current implementation is well-structured and follows best practices, the file's length suggests it might benefit from refactoring in the future. Consider splitting this large controller into smaller, more focused classes. For example:

  1. ProgrammingExerciseImportResource
  2. ProgrammingExerciseExportResource
  3. ProgrammingExerciseStudentExportResource

This separation of concerns could improve maintainability and make the codebase easier to navigate and understand. It's not an urgent change, but something to keep in mind for future refactoring efforts.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1)

Line range hint 1-24: Approve the enhanced validation for checkout directories.

The updated validateCheckoutDirectoriesUnchanged method now comprehensively checks all relevant checkout paths (assignment, solution, and test) to ensure they remain unchanged during an update operation. This is a crucial improvement for maintaining the integrity of the exercise configuration.

To improve readability, consider extracting the comparison logic into a separate private method. This would make the main method more concise and easier to understand at a glance. For example:

private boolean checkoutPathsUnchanged(ProgrammingExerciseBuildConfig original, ProgrammingExerciseBuildConfig updated) {
    return Objects.equals(original.getAssignmentCheckoutPath(), updated.getAssignmentCheckoutPath())
        && Objects.equals(original.getSolutionCheckoutPath(), updated.getSolutionCheckoutPath())
        && Objects.equals(original.getTestCheckoutPath(), updated.getTestCheckoutPath());
}

Then, you could use this method in the main validation:

if (!checkoutPathsUnchanged(originalBuildConfig, updatedBuildConfig)) {
    throw new BadRequestAlertException("The custom checkout paths cannot be changed!", "programmingExercise", "checkoutDirectoriesChanged");
}
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (1)

Line range hint 241-257: Refactor runScriptAndParseResults to reduce parameter complexity

The method runScriptAndParseResults has a lengthy parameter list, which can impact readability and maintainability. This violates the principle of keeping methods small and adhering to the single responsibility principle as per the coding guidelines.

Consider encapsulating the parameters into a single object or record to simplify the method signature.

Example:

Create a parameter object BuildJobContext:

public class BuildJobContext {
    private final BuildJobQueueItem buildJob;
    private final String containerName;
    private final String containerId;
    private final VcsRepositoryUri assignmentRepositoryUri;
    private final VcsRepositoryUri testRepositoryUri;
    private final VcsRepositoryUri solutionRepositoryUri;
    private final VcsRepositoryUri[] auxiliaryRepositoriesUris;
    private final Path assignmentRepositoryPath;
    private final Path testsRepositoryPath;
    private final Path solutionRepositoryPath;
    private final Path[] auxiliaryRepositoriesPaths;
    private final String assignmentRepoCommitHash;
    private final String testRepoCommitHash;
    private final boolean isNetworkDisabled;

    // Constructor, getters (optional), and other necessary methods
}

Then update the method signature:

-private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String containerName, String containerId, VcsRepositoryUri assignmentRepositoryUri,
-        VcsRepositoryUri testRepositoryUri, VcsRepositoryUri solutionRepositoryUri, VcsRepositoryUri[] auxiliaryRepositoriesUris, Path assignmentRepositoryPath,
-        Path testsRepositoryPath, Path solutionRepositoryPath, Path[] auxiliaryRepositoriesPaths, @Nullable String assignmentRepoCommitHash,
-        @Nullable String testRepoCommitHash, boolean isNetworkDisabled) {
+private BuildResult runScriptAndParseResults(BuildJobContext context) {

Update method calls and internal references to use the context object. This refactoring aligns with the single responsibility principle and enhances code maintainability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a5167be and 8ec3f57.

📒 Files selected for processing (23)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (7 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1 hunks)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (3 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/TestBuildAgentConfiguration.java (2 hunks)
  • src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (22)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/BuildConfig.java (1)

Pattern 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/buildagent/dto/DockerRunConfig.java (1)

Pattern 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/buildagent/service/BuildJobContainerService.java (1)

Pattern 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/buildagent/service/BuildJobExecutionService.java (1)

Pattern 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/programming/domain/ProgrammingExercise.java (1)

Pattern 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/programming/domain/ProgrammingExerciseBuildConfig.java (1)

Pattern 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/programming/service/ProgrammingExerciseService.java (1)

Pattern 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/programming/service/ci/ContinuousIntegrationService.java (1)

Pattern 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/programming/service/localci/LocalCITriggerService.java (1)

Pattern 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/programming/web/ProgrammingExerciseExportImportResource.java (1)

Pattern 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/programming/web/ProgrammingExerciseResource.java (1)

Pattern 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/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/i18n/de/programmingExercise.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1)

Pattern 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/programming/icl/LocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIResourceIntegrationTest.java (1)

Pattern 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/programming/icl/LocalCIServiceTest.java (1)

Pattern 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/programming/icl/LocalVCLocalCIIntegrationTest.java (1)

Pattern 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/programming/icl/TestBuildAgentConfiguration.java (1)

Pattern 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/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (3)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-06-15T20:04:18.637Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:42.972Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:48.767Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
🪛 Biome
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts

[error] 22-22: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 30-30: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 74-74: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 74-74: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts

[error] 81-81: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)

🔇 Additional comments (27)
src/main/java/de/tum/cit/aet/artemis/buildagent/dto/DockerRunConfig.java (4)

8-8: LGTM: Class structure and naming convention.

The DockerRunConfig class is well-structured and follows the CamelCase naming convention. Implementing Serializable is appropriate for DTOs, allowing for easy serialization if needed.


10-20: LGTM: Boolean field and methods follow Java conventions.

The isNetworkDisabled field and its getter/setter methods are correctly implemented following Java conventions for boolean fields.


30-55: LGTM: Well-implemented enum for allowed Docker flags.

The AllowedDockerFlags enum is well-structured and provides a type-safe way to manage allowed Docker flags. The static ALLOWED_FLAGS set and isAllowed method offer an efficient mechanism for flag validation. This implementation adheres to the Single Responsibility Principle and provides good encapsulation of the allowed flags logic.


1-56: Overall, well-implemented DTO for Docker run configuration.

The DockerRunConfig class is well-structured and adheres to good Java practices and principles:

  1. It follows the Single Responsibility Principle by focusing solely on Docker run configuration.
  2. The implementation is simple and follows the KISS principle.
  3. The use of an inner enum for allowed flags provides type safety and encapsulation.
  4. The code follows Java naming conventions and DTO patterns.

Minor suggestion: Consider using a more descriptive name for the env field, as mentioned in a previous comment.

Great job on creating a clean and maintainable DTO!

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.html (1)

11-11: LGTM: Property binding addition enhances component communication

The addition of [programmingExercise]="programmingExercise" to the <jhi-programming-exercise-build-configuration> component is a good improvement. This property binding allows the child component to access the programmingExercise data, enabling better communication between parent and child components.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (3)

19-20: Excellent use of new Angular syntax and improved condition.

The change from *ngIf to @if aligns with the provided coding guidelines. Additionally, the more specific condition isLanguageSupported enhances the granularity of control, which is in line with the PR objectives.


19-52: Overall excellent implementation of new Docker configuration options.

The changes in this file successfully implement the new features for Docker configuration as outlined in the PR objectives. The use of new Angular syntax (@if) is consistent with the coding guidelines. The additions for disabling network access and configuring environment variables are well-implemented and provide the intended flexibility for instructors.

A few minor suggestions:

  1. Consider adding an aria-label to the network access checkbox for improved accessibility.
  2. Clarify the reasoning behind the 128-character limit for environment variables.

Great work on enhancing the instructor's control over container configurations!


36-51: Excellent addition of environment variable configuration.

This new input field fulfills the PR objective of allowing instructors to add environment variables to the container. The implementation is well-structured with proper data binding, event handling, and validation using a regex pattern.

Could you please clarify the reason for setting the maxlength attribute to 128 characters? Is this a technical limitation or a design decision? If it's a technical limitation, we should verify that it doesn't restrict any common use cases.

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIServiceTest.java (1)

Line range hint 1-265: Overall, the test file adheres well to the coding guidelines.

The LocalCIServiceTest class demonstrates good practices in test design:

  • Descriptive test names that clearly indicate the functionality being tested.
  • Small, focused tests that verify specific behaviors.
  • Appropriate use of fixed data for reproducibility.
  • Utilization of JUnit 5 features, including @Nested for organizing related tests.
  • Consistent use of assertThat for assertions.

These practices contribute to maintainable and readable tests, which is crucial for the long-term health of the codebase.

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalCIResourceIntegrationTest.java (1)

Line range hint 1-368: LGTM with minor suggestions for improvement

The integration tests in this file are well-structured and comprehensive. They adhere to the coding guidelines by using descriptive naming, assertThat statements, and testing with different user roles. The tests cover various scenarios and API endpoints, which is commendable.

To further improve the tests:

  1. Consider adding tests specifically for the new Docker configuration options introduced in this PR, using non-null values for the new BuildConfig parameter.
  2. Ensure that all new functionality related to disabling network access and adding environment variables is covered in these integration tests.

Overall, great job on maintaining high-quality tests while implementing new features!

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExercise.java (1)

818-828: 🛠️ Refactor suggestion

Consider integrating with existing validations and add unit tests.

The new validateBuildPlanNetworkAccessForProgrammingLanguage() method is well-implemented and consistent with the existing code style. To further improve its integration and test coverage:

  1. Consider calling this method from validateProgrammingSettings() to ensure all programming language-specific validations are performed together. This would centralize the validation logic and make it less likely for this check to be missed.

  2. Add unit tests to cover this new validation method. Ensure to test both the happy path (supported languages) and the exception case (unsupported languages).

Example integration with validateProgrammingSettings():

 public void validateProgrammingSettings() {
     // ... existing validations ...

+    // Validate network access support for the programming language
+    validateBuildPlanNetworkAccessForProgrammingLanguage();
 }

To ensure proper test coverage, please run the following script:

#!/bin/bash
# Description: Check for existing test cases related to the new method

# Search for test cases mentioning the new method
echo "Searching for test cases:"
rg "validateBuildPlanNetworkAccessForProgrammingLanguage" --type java --glob "*Test.java"

# If no results are found, remind to add test cases
if [ $? -ne 0 ]; then
    echo "No test cases found for validateBuildPlanNetworkAccessForProgrammingLanguage. Please add appropriate unit tests."
fi
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1)

Line range hint 1-724: Well-structured controller with good adherence to best practices

The ProgrammingExerciseExportImportResource class is well-organized and follows several best practices:

  1. It adheres to the single responsibility principle by focusing on export and import operations for programming exercises.
  2. Dependency injection is correctly implemented using constructor injection.
  3. Proper authorization checks are in place throughout the methods.
  4. Extensive use of Optional for null-safety.
  5. Appropriate error handling and logging.
  6. Clear method names and good overall code structure.

The code demonstrates a good understanding of RESTful API design and Spring Boot best practices. Keep up the good work!

src/main/webapp/i18n/en/programmingExercise.json (1)

Line range hint 1-700: Overall, the changes enhance the configuration options for programming exercises.

The addition of the "dockerFlags" section provides instructors with more control over the execution environment for student submissions. This improvement aligns well with the PR objectives of enhancing container configuration options for instructors.

The new options are:

  1. Ability to disable network access for student code execution.
  2. Option to add environment variables to the container.

These changes are consistent with the existing structure and style of the JSON file. They provide clear and concise descriptions for users, which is crucial for a translation file.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1)

38-39: Ensure setIsLanguageSupported() is correctly called

After refactoring the use of effect, make sure that setIsLanguageSupported() is called appropriately, ideally in the ngOnInit() method, to initialize the isLanguageSupported property based on the current programming language.

src/test/javascript/spec/component/programming-exercise/programming-exercise-build-configuration.component.spec.ts (7)

6-8: Imports are appropriate and necessary.

The necessary entities are correctly imported, supporting the new test cases.


12-14: Initialization of test data is correctly implemented.

The course and programmingExercise objects are properly initialized with the required properties.


30-30: Component inputs are set correctly.

Setting the programmingExercise input ensures the component has the necessary context for testing.


47-55: Network flag update tests are thorough and accurate.

The test cases effectively verify the enabling and disabling of network access and the corresponding updates to dockerFlags.


57-65: Environment variables update tests are comprehensive.

The component's handling of environment variables is thoroughly tested, ensuring dockerFlags are updated correctly.


67-78: Combined functionality tests are well-implemented.

The interaction between network access and environment variables is accurately tested, confirming that both settings can be managed simultaneously.


87-95: Supported languages tests are accurate and effective.

The tests correctly verify the component's behavior with both unsupported (SWIFT) and supported (JAVA) programming languages.

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCITriggerService.java (1)

27-27: Import statement added correctly

The import of DockerRunConfig is necessary and correctly added.

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (3)

335-342: Ensure Pre-Script Execution Order

In createScriptFile, when network access is disabled, the pre-script is created to download dependencies before the main script runs. Verify that the pre-script successfully completes before the network is disconnected to prevent any dependency issues.


475-486: ⚠️ Potential issue

Ensure Compatibility with Project Java Version

The use of switch expressions with the -> syntax is a feature introduced in Java 14. If the project's Java version is earlier than 14, this syntax will cause a compilation error. Please verify that the project's Java version is compatible or refactor the code to use traditional switch statements.

Refactored code for Java versions below 14:

 private String getDependencyDownloadScript(ProgrammingLanguage programmingLanguage, ProjectType projectType) {
-    return switch (programmingLanguage) {
-        case JAVA -> switch (projectType) {
-            case PLAIN_MAVEN, MAVEN_BLACKBOX, MAVEN_MAVEN -> DependencyDownloadScript.MAVEN.getScript();
-            case PLAIN_GRADLE, GRADLE_GRADLE -> DependencyDownloadScript.GRADLE.getScript();
-            default -> DependencyDownloadScript.OTHER.getScript();
-        };
-        case RUST -> DependencyDownloadScript.RUST.getScript();
-        case JAVASCRIPT -> DependencyDownloadScript.JAVASCRIPT.getScript();
-        default -> DependencyDownloadScript.OTHER.getScript();
-    };
+    switch (programmingLanguage) {
+        case JAVA:
+            switch (projectType) {
+                case PLAIN_MAVEN:
+                case MAVEN_BLACKBOX:
+                case MAVEN_MAVEN:
+                    return DependencyDownloadScript.MAVEN.getScript();
+                case PLAIN_GRADLE:
+                case GRADLE_GRADLE:
+                    return DependencyDownloadScript.GRADLE.getScript();
+                default:
+                    return DependencyDownloadScript.OTHER.getScript();
+            }
+        case RUST:
+            return DependencyDownloadScript.RUST.getScript();
+        case JAVASCRIPT:
+            return DependencyDownloadScript.JAVASCRIPT.getScript();
+        default:
+            return DependencyDownloadScript.OTHER.getScript();
+    }
 }

Line range hint 305-332: Verify Method Calls with Updated Parameters

The method populateBuildJobContainer now includes projectType and isNetworkDisabled as parameters. Ensure that all calls to this method across the codebase have been updated accordingly to prevent compilation errors or unintended behavior.

Run the following script to identify method calls that need updating:

✅ Verification successful

**All calls to populateBuildJobContainer have been updated with the new parameters. **

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all calls to 'populateBuildJobContainer' to verify parameter updates.

# Test: Search for the method usage. Expect: All calls include the new parameters.
rg --type java 'populateBuildJobContainer\(' --context 2

Length of output: 2044

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (1)

263-263: Verify that isNetworkDisabled is properly handled in runScriptInContainer

When calling buildJobContainerService.runScriptInContainer(containerId, buildJob.id(), isNetworkDisabled);, ensure that the runScriptInContainer method in BuildJobContainerService is updated to accept and utilize the isNetworkDisabled parameter.

Run the following script to confirm that the method signature includes isNetworkDisabled:

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)

333-335: Ensure consistent error handling in validation method

Verify that updatedProgrammingExercise.validateBuildPlanNetworkAccessForProgrammingLanguage(); follows the project's error handling conventions. If the validation fails, it should throw a BadRequestAlertException with an appropriate error message, consistent with other validation checks in this method.

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: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 7c98073 and 08b22d3.

📒 Files selected for processing (6)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (6 hunks)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (3 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (1)

Pattern 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/buildagent/service/BuildJobExecutionService.java (1)

Pattern 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/programming/domain/ProgrammingExerciseBuildConfig.java (1)

Pattern 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/programming/service/ci/ContinuousIntegrationService.java (1)

Pattern 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/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (1)

Pattern 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

🪛 Biome
src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts

[error] 22-22: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 30-30: This type annotation is trivially inferred from its initialization.

Safe fix: Remove the type annotation.

(lint/style/noInferrableTypes)


[error] 71-71: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 71-71: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

🔇 Additional comments (13)
src/test/java/de/tum/cit/aet/artemis/programming/icl/LocalVCLocalCIIntegrationTest.java (2)

975-975: LGTM: Class renamed to better reflect its purpose

The class has been renamed from BuildJobPriorityTest to BuildJobConfigurationTest, which better represents its expanded scope to include testing of Docker flag parsing in addition to build job priorities.


Line range hint 1-1084: Overall, good additions with minor improvements needed

The changes to this test file are focused and valuable. The renaming of the BuildJobConfigurationTest class better reflects its expanded scope, and the new testDockerFlagsParsing method adds coverage for an important feature.

Key points:

  1. The new test effectively covers Docker flag parsing.
  2. Existing tests remain unchanged, maintaining current coverage.
  3. The file structure and organization remain consistent with the rest of the codebase.

Areas for improvement:

  1. Remove direct database access in the new test method.
  2. Expand test coverage for edge cases in Docker flag parsing.

These changes enhance the test suite without introducing regressions. After addressing the minor issues mentioned, the code will be in excellent shape.

src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.ts (3)

42-53: Initialization in ngOnInit is handled correctly

The ngOnInit() method properly initializes component state by parsing dockerFlags and setting isNetworkDisabled and envVars accordingly. This ensures that the component reflects the current configuration when loaded.


65-72: The updateDockerFlags method effectively updates Docker flags

The logic within updateDockerFlags efficiently manages the Docker flags by filtering existing flags and updating them based on allowed options. This maintains valid configurations and ensures consistency.

🧰 Tools
🪛 Biome

[error] 71-71: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 71-71: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


74-76: Language support check is correctly implemented

The setIsLanguageSupported() method accurately determines if the programming language supports network disabling by checking against NOT_SUPPORTED_NETWORK_DISABLED_LANGUAGES. This enhances the component's adaptability to different languages.

src/main/java/de/tum/cit/aet/artemis/programming/domain/ProgrammingExerciseBuildConfig.java (2)

3-4: Appropriate imports included for new functionality

The added import statements correctly bring in the necessary classes and utilities required for the new methods and functionalities, such as ArrayList, List, Matcher, Pattern, StringUtils, TypeReference, ObjectMapper, and DockerRunConfig. This adheres to the coding guidelines, specifically avoiding wildcard imports and ensuring that only necessary dependencies are included.

Also applies to: 7-8, 17-17, 25-26, 28-28


303-376: Well-structured methods with clear documentation

The newly added methods getDockerRunConfig() and parseEnvVariableString() are well-implemented and adhere to the project's coding guidelines. Key points include:

  • Single Responsibility Principle: Each method performs a distinct function, enhancing maintainability.
  • Clear Documentation: Comprehensive Javadoc comments provide clarity on the purpose and usage of the methods.
  • Proper Access Modifiers: Access levels are appropriately set (public and private), following the principle of least privilege.
  • Code Readability: The code is readable with meaningful variable names and logical structuring, aligning with KISS principles.
src/main/java/de/tum/cit/aet/artemis/programming/service/ci/ContinuousIntegrationService.java (1)

266-335: Well-structured addition of DependencyDownloadScript Enum

The DependencyDownloadScript enum is a clean and effective way to manage dependency download scripts for various programming languages. The use of an abstract getScript() method with language-specific overrides promotes extensibility and adheres to the Single Responsibility Principle. The code is readable and maintains consistency across different language implementations.

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (1)

140-144: Avoid Hardcoding the Network ID 'bridge'

Hardcoding the network ID 'bridge' when disconnecting the container may cause issues if the network configuration changes or if the container is connected to a different network. Consider retrieving the network IDs dynamically or making the network ID configurable to enhance flexibility and maintainability.

src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java (4)

195-200: Enhancement: Properly retrieve Docker run configurations

The introduction of envVars and isNetworkDisabled correctly retrieves environment variables and network settings from the DockerRunConfig. This enhances the configurability of the Docker container as intended.


202-203: Update: Pass environment variables to configureContainer method

Passing envVars to the configureContainer method allows for dynamic environment variable configuration within the Docker container, aligning with the new feature requirements.


206-206: Modification: Include network settings in runScriptAndParseResults

Adding isNetworkDisabled as a parameter to runScriptAndParseResults ensures that network configuration settings are consistently propagated throughout the build process.


263-263: Adjustment: Apply network settings when running scripts in the container

By passing isNetworkDisabled to runScriptInContainer, the network access settings are correctly applied during the execution of the build script within the Docker container.

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: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 08b22d3 and b1cd291.

📒 Files selected for processing (4)
  • src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (6 hunks)
  • src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1 hunks)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (1)

Pattern 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/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-build-configuration/programming-exercise-build-configuration.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/i18n/de/programmingExercise.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

🔇 Additional comments (8)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java (8)

48-50: Necessary imports are correctly added

The import statements for ProjectType and DependencyDownloadScript are appropriately included to support the new functionalities.


90-96: configureContainer method updated with exerciseEnvVars

The method signature and documentation are updated to include exerciseEnvVars. The environment variables are safely added to the envVars list after null and emptiness checks.


104-106: Proper handling of exerciseEnvVars

The null and emptiness check before adding exerciseEnvVars to envVars ensures robustness and prevents potential issues with null references or empty lists.


130-145: Enhancements in runScriptInContainer method

The addition of the isNetworkDisabled parameter allows conditional execution of the pre-script and disconnection from the network. Exception handling around the network disconnection ensures that any issues are logged without causing the application to crash.


303-308: Updated populateBuildJobContainer method signature

The method now accepts ProjectType and isNetworkDisabled parameters, enhancing configurability based on project specifics and network requirements.


335-335: Invocation of createScriptFile with new parameters

The call to createScriptFile includes isNetworkDisabled, programmingLanguage, and projectType, ensuring that the script creation is tailored according to the network settings and project type.


338-345: Script files are conditionally created

The createScriptFile method correctly generates the preScript.sh when isNetworkDisabled is true, and handles the main script.sh. The implementation is consistent with the intended functionality.


478-489: Implementation of getDependencyDownloadScript

The method effectively uses a switch expression to return the appropriate dependency download script based on the programming language and project type. This enhances code clarity and maintainability.

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between b1cd291 and 9d6ba04.

📒 Files selected for processing (1)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/i18n/de/programmingExercise.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

src/main/webapp/i18n/de/programmingExercise.json Outdated Show resolved Hide resolved
src/main/webapp/i18n/de/programmingExercise.json Outdated Show resolved Hide resolved
@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Nov 19, 2024
@Cathy0123456789 Cathy0123456789 added deploy:artemis-test1 and removed deployment-error Added by deployment workflows if an error occured labels Nov 19, 2024
@Cathy0123456789 Cathy0123456789 temporarily deployed to artemis-test1.artemis.cit.tum.de November 19, 2024 23:51 — with GitHub Actions Inactive
Copy link

@Cathy0123456789 Cathy0123456789 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 TS1. Works as expected :)

@krusche krusche modified the milestones: 7.7.3, 7.7.4 Nov 28, 2024
krusche and others added 4 commits November 29, 2024 17:12
…docker-flags

# Conflicts:
#	src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java
#	src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buildagent Pull requests that affect the corresponding module client Pull requests that update TypeScript code. (Added Automatically!) core Pull requests that affect the corresponding module database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. documentation programming Pull requests that affect the corresponding module ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Developer Approved
Development

Successfully merging this pull request may close these issues.