Skip to content

Commit

Permalink
Merge branch 'develop' into feature/adaptive-learning/learner-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesStoehr committed Dec 5, 2024
2 parents 90e061b + 96ca4ec commit 04e2a26
Show file tree
Hide file tree
Showing 103 changed files with 1,088 additions and 4,116 deletions.
117 changes: 0 additions & 117 deletions .github/workflows/analysis-of-endpoint-connections.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,3 @@ data-exports/
# Supporting scripts config
##############################
/supporting_scripts/**/*.ini
/supporting_scripts/analysis-of-endpoint-connections/build/**/*
26 changes: 8 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
id "com.github.ben-manes.versions" version "0.51.0"
id "com.github.andygoossens.modernizer" version "${modernizer_plugin_version}"
id "com.gorylenko.gradle-git-properties" version "2.4.2"
id "org.owasp.dependencycheck" version "11.1.0"
id "org.owasp.dependencycheck" version "11.1.1"
id "com.adarshr.test-logger" version "4.0.0"
}

Expand Down Expand Up @@ -96,9 +96,10 @@ spotless {
@Override
String apply(String s, File file) throws Exception {
if (s =~ /\nimport .*\*;/) {
throw new AssertionError("Do not use wildcard imports. spotlessApply cannot resolve this issue.\n" +
throw new IllegalArgumentException("Do not use wildcard imports. spotlessApply cannot resolve this issue.\n" +
"The following file violates this rule: " + file.getName())
}
return s // Ensure a value is returned after processing
}
}))
}
Expand Down Expand Up @@ -180,13 +181,13 @@ jacocoTestCoverageVerification {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
// TODO: in the future the following value should become higher than 0.92
minimum = 0.893
minimum = 0.892
}
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
// TODO: in the future the following value should become less than 10
maximum = 64
maximum = 65
}
}
}
Expand All @@ -212,18 +213,11 @@ repositories {
maven {
url "https://build.shibboleth.net/maven/releases"
}
// TODO: remove this when spring cloud is available in the official maven repository
maven {
url "https://repo.spring.io/milestone"
}
}

ext["jackson.version"] = fasterxml_version
ext["junit-jupiter.version"] = junit_version

ext { qDoxVersionReusable = "com.thoughtworks.qdox:qdox:2.2.0" }
ext { springBootStarterWeb = "org.springframework.boot:spring-boot-starter-web:${spring_boot_version}" }

dependencies {

// Note: jenkins-client is not well maintained and includes dependencies to libraries with critical security issues (e.g. CVE-2020-10683 for [email protected])
Expand Down Expand Up @@ -297,7 +291,7 @@ dependencies {
implementation "org.apache.sshd:sshd-sftp:${sshd_version}"

// https://mvnrepository.com/artifact/net.sourceforge.plantuml/plantuml
implementation "net.sourceforge.plantuml:plantuml:1.2024.7"
implementation "net.sourceforge.plantuml:plantuml:1.2024.8"
implementation "org.jasypt:jasypt:1.9.3"
implementation "me.xdrop:fuzzywuzzy:1.4.0"
implementation("org.yaml:snakeyaml") {
Expand All @@ -307,7 +301,7 @@ dependencies {
}
}

implementation qDoxVersionReusable
implementation "com.thoughtworks.qdox:qdox:2.2.0"
implementation "io.sentry:sentry-logback:${sentry_version}"
implementation "io.sentry:sentry-spring-boot-starter-jakarta:${sentry_version}"

Expand All @@ -328,10 +322,6 @@ dependencies {
implementation "org.jsoup:jsoup:1.18.3"
implementation "commons-codec:commons-codec:1.17.1" // needed for spring security saml2

// TODO: decide if we want to use OpenAPI and Swagger v3
// implementation 'io.swagger.core.v3:swagger-annotations:2.2.23'
// implementation "org.springdoc:springdoc-openapi-ui:1.8.0"

// use the latest version to avoid security vulnerabilities
implementation "org.springframework:spring-webmvc:${spring_framework_version}"

Expand Down Expand Up @@ -393,7 +383,7 @@ dependencies {
implementation "org.springframework.boot:spring-boot-starter-aop:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-security:${spring_boot_version}"
implementation(springBootStarterWeb) {
implementation("org.springframework.boot:spring-boot-starter-web:${spring_boot_version}") {
exclude module: "spring-boot-starter-undertow"
}
implementation "org.springframework.boot:spring-boot-starter-tomcat:${spring_boot_version}"
Expand Down
26 changes: 25 additions & 1 deletion docs/user/exercises/programming-exercise-setup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,38 @@ Edit Maximum Build Duration
^^^^^^^^^^^^^^^^^^^^^^^^^^^

**This option is only available when using** :ref:`integrated code lifecycle<integrated code lifecycle>`
This section is optional. In most cases, the preconfigured build script does not need to be changed.

This section is optional. In most cases, the default maximum build duration does not need to be changed.

The maximum build duration is the time limit for the build plan to execute. If the build plan exceeds this time limit, it will be terminated. The default value is 120 seconds.
You can change the maximum build duration by using the slider.

.. figure:: programming/timeout-slider.png
:align: center

Edit Container Configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**This option is only available when using** :ref:`integrated code lifecycle<integrated code lifecycle>`

This section is optional. In most cases, the default container configuration does not need to be changed.

Currently, instructors can only change whether the container has internet access and add additional environment variables.
Disabling internet access can be useful if instructors want to prevent students from downloading additional dependencies during the build process.
If internet access is disabled, the container cannot access the internet during the build process. Thus, it will not be able to download additional dependencies.
The dependencies must then be included/cached in the docker image.

Additional environment variables can be added to the container configuration. This can be useful if the build process requires additional environment variables to be set.

.. figure:: programming/docker-flags-edit.png
:align: center

We plan to add more options to the container configuration in the future.

.. warning::
- Disabling internet access is not currently supported for Swift and Haskell exercises.


.. _configure_static_code_analysis_tools:

Configure static code analysis
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ npm_version=10.8.0
jhipster_dependencies_version=8.7.2
spring_boot_version=3.4.0
spring_framework_version=6.2.0
spring_cloud_version=4.2.0-RC1
spring_cloud_version=4.2.0
spring_security_version=6.4.1
# TODO: upgrading to 6.6.0 currently leads to issues due to internal changes in Hibernate and potentially wrong use in Artemis server code
hibernate_version=6.4.10.Final
Expand All @@ -19,7 +19,7 @@ jwt_version=0.12.6
jaxb_runtime_version=4.0.5
hazelcast_version=5.5.0
fasterxml_version=2.18.2
jgit_version=7.0.0.202409031743-r
jgit_version=7.1.0.202411261347-r
sshd_version=2.14.0
checkstyle_version=10.20.2
jplag_version=5.1.0
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ module.exports = {
coverageThreshold: {
global: {
// TODO: in the future, the following values should increase to at least 90%
statements: 87.72,
branches: 73.83,
functions: 82.29,
lines: 87.78,
statements: 87.69,
branches: 73.79,
functions: 82.27,
lines: 87.74,
},
},
coverageReporters: ['clover', 'json', 'lcov', 'text-summary'],
Expand Down
5 changes: 1 addition & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ pluginManagement {

rootProject.name = 'Artemis'

// needed for rest call and endpoint analysis
include 'supporting_scripts:analysis-of-endpoint-connections'

// needed for programming exercise templates
DirectoryScanner.removeDefaultExclude "**/.gitattributes"
DirectoryScanner.removeDefaultExclude "**/.gitignore"
DirectoryScanner.removeDefaultExclude "**/.gitignore"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@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) implements Serializable {
List<String> resultPaths, int timeoutSeconds, String assignmentCheckoutPath, String testCheckoutPath, String solutionCheckoutPath, DockerRunConfig dockerRunConfig)
implements Serializable {

@Override
public String dockerImage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.tum.cit.aet.artemis.buildagent.dto;

import java.util.Map;

public record DockerFlagsDTO(String network, Map<String, String> env) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.tum.cit.aet.artemis.buildagent.dto;

import java.io.Serializable;
import java.util.List;

public record DockerRunConfig(boolean isNetworkDisabled, List<String> env) implements Serializable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,23 @@ public BuildJobContainerService(DockerClient dockerClient, HostConfig hostConfig
/**
* Configure a container with the Docker image, the container name, optional proxy config variables, and set the command that runs when the container starts.
*
* @param containerName the name of the container to be created
* @param image the Docker image to use for the container
* @param buildScript the build script to be executed in the container
* @param containerName the name of the container to be created
* @param image the Docker image to use for the container
* @param buildScript the build script to be executed in the container
* @param exerciseEnvVars the environment variables provided by the instructor
* @return {@link CreateContainerResponse} that can be used to start the container
*/
public CreateContainerResponse configureContainer(String containerName, String image, String buildScript) {
public CreateContainerResponse configureContainer(String containerName, String image, String buildScript, List<String> exerciseEnvVars) {
List<String> envVars = new ArrayList<>();
if (useSystemProxy) {
envVars.add("HTTP_PROXY=" + httpProxy);
envVars.add("HTTPS_PROXY=" + httpsProxy);
envVars.add("NO_PROXY=" + noProxy);
}
envVars.add("SCRIPT=" + buildScript);
if (exerciseEnvVars != null && !exerciseEnvVars.isEmpty()) {
envVars.addAll(exerciseEnvVars);
}
return dockerClient.createContainerCmd(image).withName(containerName).withHostConfig(hostConfig).withEnv(envVars)
// Command to run when the container starts. This is the command that will be executed in the container's main process, which runs in the foreground and blocks the
// container from exiting until it finishes.
Expand All @@ -121,11 +125,23 @@ public void startContainer(String containerId) {
/**
* Run the script in the container and wait for it to finish before returning.
*
* @param containerId the id of the container in which the script should be run
* @param buildJobId the id of the build job that is currently being executed
* @param containerId the id of the container in which the script should be run
* @param buildJobId the id of the build job that is currently being executed
* @param isNetworkDisabled whether the network should be disabled for the container
*/
public void runScriptInContainer(String containerId, String buildJobId, boolean isNetworkDisabled) {
if (isNetworkDisabled) {
log.info("disconnecting container with id {} from network", containerId);
try {
dockerClient.disconnectFromNetworkCmd().withContainerId(containerId).withNetworkId("bridge").exec();
}
catch (Exception e) {
log.error("Failed to disconnect container with id {} from network: {}", containerId, e.getMessage());
buildLogsMap.appendBuildLogEntry(buildJobId, "Failed to disconnect container from default network 'bridge': " + e.getMessage());
throw new LocalCIException("Failed to disconnect container from default network 'bridge': " + e.getMessage());
}
}

public void runScriptInContainer(String containerId, String buildJobId) {
log.info("Started running the build script for build job in container with id {}", containerId);
// The "sh script.sh" execution command specified here is run inside the container as an additional process. This command runs in the background, independent of the
// container's
Expand Down Expand Up @@ -448,9 +464,4 @@ private Container getContainerForName(String containerName) {
List<Container> containers = dockerClient.listContainersCmd().withShowAll(true).exec();
return containers.stream().filter(container -> container.getNames()[0].equals("/" + containerName)).findFirst().orElse(null);
}

private String getParentFolderPath(String path) {
Path parentPath = Paths.get(path).normalize().getParent();
return parentPath != null ? parentPath.toString() : "";
}
}
Loading

0 comments on commit 04e2a26

Please sign in to comment.