Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into test/reduce-random…
Browse files Browse the repository at this point in the history
…-test-data
  • Loading branch information
DominikRemo committed May 26, 2023
1 parent 5342ca2 commit 6d9cdf9
Show file tree
Hide file tree
Showing 261 changed files with 9,322 additions and 1,494 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Desktop.ini
.dbus/
repos/
repos-download/
local-vcs-repos
/templates/
.bash_history
.v8flags.*.json
Expand Down Expand Up @@ -201,5 +202,7 @@ repos-download/
# Artemis configs
######################
/src/main/resources/config/application-local*.yml
!/src/main/resources/config/application-localvc.yml
!/src/main/resources/config/application-localci.yml
/src/main/resources/id_*
/src/main/resources/known_hosts
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server__Athene_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/runConfigurations/Artemis__Server__LocalVC___LocalCI_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server___Client_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/runConfigurations/_template__of_Gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ dependencies {
// https://search.maven.org/artifact/org.eclipse.jgit/org.eclipse.jgit
implementation "org.eclipse.jgit:org.eclipse.jgit:${jgit_version}"
implementation "org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}"
implementation "org.eclipse.jgit:org.eclipse.jgit.http.server:${jgit_version}"
// https://search.maven.org/artifact/net.sourceforge.plantuml/plantuml
implementation "net.sourceforge.plantuml:plantuml:1.2023.6"
implementation "org.imsglobal:basiclti-util:1.2.0"
Expand All @@ -253,6 +254,9 @@ dependencies {
implementation "org.springdoc:springdoc-openapi-ui:1.7.0"
implementation "com.vdurmont:semver4j:3.1.0"

implementation 'com.github.docker-java:docker-java-core:3.3.0'
implementation 'com.github.docker-java:docker-java-transport-httpclient5:3.3.0'

// import JHipster dependencies BOM
implementation platform("tech.jhipster:jhipster-dependencies:${jhipster_dependencies_version}")

Expand Down
6 changes: 3 additions & 3 deletions prebuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const args = process.argv.slice(2);
const developFlag = args.includes('--develop');
const environmentConfig = `// Don't change this file manually, it will be overwritten by the build process!
export const __DEBUG_INFO_ENABLED__ = ${developFlag};
export const __VERSION__ = ${JSON.stringify(process.env.APP_VERSION || inferVersion())};
export const __VERSION__ = '${process.env.APP_VERSION || inferVersion()}';
// The root URL for API calls, ending with a '/' - for example: \`"https://www.jhipster.tech:8081/myservice/"\`.
// If you use an API server, in \`prod\` mode, you will need to enable CORS
// (see the \`jhipster.cors\` common JHipster property in the \`application-*.yml\` configurations)
export const I18N_HASH = ${JSON.stringify(languagesHash.hash)};
export const I18N_HASH = '${languagesHash.hash}';
`;
fs.writeFileSync(path.resolve(__dirname, 'src', 'main', 'webapp', 'app', 'environments', 'environment.override.ts'), environmentConfig);

Expand Down Expand Up @@ -103,7 +103,7 @@ for (const group of groups) {
const mergedContent = files.reduce((acc, file) => {
const content = JSON.parse(fs.readFileSync(path.resolve(group.folder, file)).toString());
return deepMerge(acc, content);
});
}, {});

await fs.promises.writeFile(group.output, JSON.stringify(mergedContent));
} catch (error) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ public final class Constants {

public static final String EXAM_EXERCISE_START_STATUS = "exam-exercise-start-status";

/**
* The name of the Spring profile used to choose the local VC system instead of Bitbucket or GitLab.
*/
public static final String PROFILE_LOCALVC = "localvc";

/**
* The name of the Spring profile used to choose the local CI system instead of Bamboo, Jenkins, or GitLabCI.
*/
public static final String PROFILE_LOCALCI = "localci";

/**
* Size of an unsigned tinyInt in SQL, that is used in the database
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.tum.in.www1.artemis.config.localvcci;

import java.util.Optional;

import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.transport.ReceivePack;

import de.tum.in.www1.artemis.service.connectors.localci.LocalCIConnectorService;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCFetchFilter;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCPostPushHook;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCPrePushHook;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCPushFilter;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCServletService;

/**
* This class configures the JGit Servlet, which is used to receive Git push and fetch requests for local VC.
*/
public class ArtemisGitServlet extends GitServlet {

/**
* Constructor for ArtemisGitServlet.
*
* @param localVCServletService the service for authenticating and authorizing users and retrieving the repository from disk
* @param localCIConnectorService the service for triggering a new build after a successful push
*/
public ArtemisGitServlet(LocalVCServletService localVCServletService, Optional<LocalCIConnectorService> localCIConnectorService) {
this.setRepositoryResolver((req, name) -> {
// req – the current request, may be used to inspect session state including cookies or user authentication.
// name – name of the repository, as parsed out of the URL (everything after /git/).

// Return the opened repository instance.
return localVCServletService.resolveRepository(name);
});

// Add filters that every request to the JGit Servlet goes through, one for each fetch request, and one for each push request.
this.addUploadPackFilter(new LocalVCFetchFilter(localVCServletService));
this.addReceivePackFilter(new LocalVCPushFilter(localVCServletService));

this.setReceivePackFactory((req, db) -> {
ReceivePack receivePack = new ReceivePack(db);
// Add a hook that prevents illegal actions on push (delete branch, rename branch, force push).
receivePack.setPreReceiveHook(new LocalVCPrePushHook());
// Add a hook that triggers the creation of a new submission after the push went through successfully.
receivePack.setPostReceiveHook(new LocalVCPostPushHook(localCIConnectorService));
return receivePack;
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.tum.in.www1.artemis.config.localvcci;

import java.util.Optional;

import org.eclipse.jgit.http.server.GitServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import de.tum.in.www1.artemis.service.connectors.localci.LocalCIConnectorService;
import de.tum.in.www1.artemis.service.connectors.localvc.LocalVCServletService;

/**
* Configuration of the JGit Servlet that handles fetch and push requests for local Version Control.
*/
@Configuration
@Profile("localvc")
public class JGitServletConfiguration {

private final Logger log = LoggerFactory.getLogger(JGitServletConfiguration.class);

private final LocalVCServletService localVCServletService;

private final Optional<LocalCIConnectorService> localCIConnectorService;

public JGitServletConfiguration(LocalVCServletService localVCServletService, Optional<LocalCIConnectorService> localCIConnectorService) {
this.localVCServletService = localVCServletService;
this.localCIConnectorService = localCIConnectorService;
}

/**
* @return GitServlet (Git server implementation by JGit) configured with a repository resolver and filters for fetch and push requests.
*/
@Bean
public ServletRegistrationBean<GitServlet> jgitServlet() {
ArtemisGitServlet gitServlet = new ArtemisGitServlet(localVCServletService, localCIConnectorService);
log.info("Registering ArtemisGitServlet for handling fetch and push requests to [Artemis URL]/git/[Project Key]/[Repository Slug].git");
return new ServletRegistrationBean<>(gitServlet, "/git/*");
}
}
Loading

0 comments on commit 6d9cdf9

Please sign in to comment.