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

Programming exercises: Enable empty template for LocalCI #9280

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_LOCALCI;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.ASSEMBLER;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.C;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.EMPTY;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.HASKELL;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.JAVA;
import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.KOTLIN;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class LocalCIProgrammingLanguageFeatureService extends ProgrammingLanguag

public LocalCIProgrammingLanguageFeatureService() {
// Must be extended once a new programming language is added
// TODO LOCALVC_CI: Local CI is not supporting EMPTY at the moment.
programmingLanguageFeatures.put(EMPTY, new ProgrammingLanguageFeature(EMPTY, false, false, false, false, false, List.of(), false, true));
programmingLanguageFeatures.put(JAVA,
new ProgrammingLanguageFeature(JAVA, true, true, true, true, false, List.of(PLAIN_GRADLE, GRADLE_GRADLE, PLAIN_MAVEN, MAVEN_MAVEN), false, true));
programmingLanguageFeatures.put(PYTHON, new ProgrammingLanguageFeature(PYTHON, false, false, true, false, false, List.of(), false, true));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ artemis:
# possible overrides: maven, gradle
default: "ls1tum/artemis-maven-template:java17-21"
empty:
default: "ls1tum/artemis-maven-template:java17-21"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the PR change the default docker image here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to imply that the tests have to be Java based, so I went with something more basic. You would want to use a custom image anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Nevertheless, I would avoid not needed config changes as it might change workflows for instructors and also it increases the amount of used images.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. But a workflow using the default image of Empty and requiring Maven without using the Java template would be highly unusual.
Most of the other images are based on ubuntu down the line, so I wouldn't expect much of an increase in disk usage.

default: "ubuntu:24.04"
python:
default: "ls1tum/artemis-python-docker:latest"
c:
Expand Down
37 changes: 37 additions & 0 deletions src/main/resources/templates/aeolus/empty/default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e
export AEOLUS_INITIAL_DIRECTORY=${PWD}
install_dependencies () {
echo '⚙️ executing install_dependencies'
# TODO: Install dependencies not provided by the Docker image
echo 'Install dependencies'
}

run_tests () {
echo '⚙️ executing run_tests'
# TODO: Run the tests and generate JUnit XMLs
echo 'Hello World'
}

process_results () {
echo '⚙️ executing process_results'
rm -rf results
mkdir results
# TODO: Move JUnit XMLs into the results directory
}

main () {
if [[ "${1}" == "aeolus_sourcing" ]]; then
return 0 # just source to use the methods in the subshell, no execution
fi
local _script_name
_script_name=${BASH_SOURCE[0]:-$0}
cd "${AEOLUS_INITIAL_DIRECTORY}"
bash -c "source ${_script_name} aeolus_sourcing; install_dependencies"
cd "${AEOLUS_INITIAL_DIRECTORY}"
bash -c "source ${_script_name} aeolus_sourcing; run_tests"
cd "${AEOLUS_INITIAL_DIRECTORY}"
bash -c "source ${_script_name} aeolus_sourcing; process_results"
}

main "${@}"
23 changes: 23 additions & 0 deletions src/main/resources/templates/aeolus/empty/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
api: v0.0.1
metadata:
name: Empty
id: empty
description: Provides a starting point
actions:
- name: install_dependencies
script: |-
# TODO: Install dependencies not provided by the Docker image
echo 'Install dependencies'
- name: run_tests
script: |-
# TODO: Run the tests and generate JUnit XMLs
echo 'Hello World'
- name: process_results
script: |-
rm -rf results
mkdir results
# TODO: Move JUnit XMLs into the results directory
results:
- name: junit
path: results/*.xml
type: junit
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ test-job:
- git clone --branch ${ARTEMIS_SUBMISSION_GIT_BRANCH} ${CI_SERVER_PROTOCOL}://${ARTEMIS_TEST_GIT_USER}:${ARTEMIS_TEST_GIT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME} assignment
- export ARTEMIS_NOTIFICATION_SECRET=[hidden] # Workaround for overwriting the secret
- export ARTEMIS_TEST_GIT_TOKEN=[hidden]
- mvn --version && echo "ARTEMIS_BUILD_STATUS=success" > .env || echo "ARTEMIS_BUILD_STATUS=failed" > .env
# TODO: Install dependencies not provided by the Docker image
magaupp marked this conversation as resolved.
Show resolved Hide resolved
# TODO: Run the tests and generate JUnit XMLs
magaupp marked this conversation as resolved.
Show resolved Hide resolved
- echo "Hello World" && echo "ARTEMIS_BUILD_STATUS=success" > .env || echo "ARTEMIS_BUILD_STATUS=failed" > .env
magaupp marked this conversation as resolved.
Show resolved Hide resolved
# TODO: Move JUnit XMLs into the ${ARTEMIS_TEST_RESULTS_DIR} directory
magaupp marked this conversation as resolved.
Show resolved Hide resolved
after_script:
- echo "ARTEMIS_TEST_GIT_HASH=$(git rev-parse HEAD)" >> .env
- echo "ARTEMIS_SUBMISSION_GIT_HASH=${CI_COMMIT_SHA}" >> .env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ private void runTestSteps() {
* Run unit tests
*/
private void test() {
stage('Build') {
sh '''
mvn --version
'''
stage('Install dependencies') {
// TODO: Install dependencies not provided by the Docker image
sh 'echo "Install dependencies"'
}
stage('Run tests') {
// TODO: Run the tests and generate JUnit XMLs
sh 'echo "Hello World"'
magaupp marked this conversation as resolved.
Show resolved Hide resolved
}
magaupp marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -45,6 +48,7 @@ void postBuildTasks() {
rm -rf results
mkdir results
'''
// TODO: Move JUnit XMLs into the results directory
}

// very important, do not remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export class ProgrammingExerciseUpdateComponent implements AfterViewInit, OnDest
} else {
this.programmingExercise.buildConfig = new ProgrammingExerciseBuildConfig();
}
this.programmingExercise.customizeBuildPlanWithAeolus = language === ProgrammingLanguage.EMPTY;
}

// If we switch to another language which does not support static code analysis we need to reset options related to static code analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@
}
</div>
}
@if (programmingExercise.programmingLanguage === ProgrammingLanguage.EMPTY) {
<div>
<p>
<fa-icon [icon]="faExclamationTriangle" size="xl" class="text-warning"></fa-icon>
<span jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.title" [translateValues]="{ documentationLink: DOCUMENTATION_LINK }"></span>
</p>
<ol>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.setImage" [translateValues]="DOCKER_REGISTRY_LINKS"></li>
<li>
<p jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.buildScript.title" class="mb-0"></p>
<ol>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.buildScript.dependencies"></li>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.buildScript.runTests"></li>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.buildScript.moveResults" [translateValues]="{ resultsDirectory: './results/' }"></li>
</ol>
</li>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.pushExercise" [translateValues]="{ checkoutDirectory: './assignment/' }"></li>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.pushSolution"></li>
<li jhiTranslate="artemisApp.programmingExercise.otherLanguageHints.pushTest" [translateValues]="{ checkoutDirectory: './' }"></li>
</ol>
</div>
}
@if (programmingExercise.programmingLanguage && programmingExerciseCreationConfig.packageNameRequired && programmingExercise.projectType !== ProjectType.XCODE) {
<div class="form-group">
<label class="label-narrow" jhiTranslate="artemisApp.programmingExercise.packageName" for="field_packageName"></label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewChecked, AfterViewInit, Component, EventEmitter, Input, OnDestroy, ViewChild } from '@angular/core';
import { ProgrammingExercise, ProgrammingLanguage, ProjectType } from 'app/entities/programming/programming-exercise.model';
import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import { ProgrammingExerciseCreationConfig } from 'app/exercises/programming/manage/update/programming-exercise-creation-config';
import { PROFILE_AEOLUS, PROFILE_LOCALCI } from 'app/app.constants';
import { NgModel } from '@angular/forms';
Expand Down Expand Up @@ -32,10 +32,16 @@ export class ProgrammingExerciseLanguageComponent implements AfterViewChecked, A

fieldSubscriptions: (Subscription | undefined)[] = [];

faQuestionCircle = faQuestionCircle;
faExclamationTriangle = faExclamationTriangle;
protected readonly PROFILE_LOCALCI = PROFILE_LOCALCI;
protected readonly PROFILE_AEOLUS = PROFILE_AEOLUS;

readonly DOCKER_REGISTRY_LINKS = {
ghcrLink: 'https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry',
dockerhubLink: 'https://hub.docker.com/',
};
readonly DOCUMENTATION_LINK = 'https://docs.artemis.cit.tum.de/user/exercises/programming.html';

ngAfterViewInit() {
this.fieldSubscriptions.push(this.selectLanguageField.valueChanges?.subscribe(() => setTimeout(() => this.calculateFormValid())));
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/webapp/i18n/de/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,19 @@
"template": "Vorlage",
"history": "Commit-Historie",
"result": "Ergebnis"
},
"otherLanguageHints": {
"title": "Führe folgende Schritte aus, um eine andere Sprache zu benutzen. Siehe die <a href=\"{{documentationLink}}\">Dokumentation</a> für Details.",
"setImage": "Lege ein angepasstes Docker Image mit benötigten Abhängigkeiten fest (erstelle möglicherweise ein eigenes und lade es in die <a href=\"{{ghcrLink}}\">GitHub Container Registry</a> oder auf den <a href=\"{{dockerhubLink}}\">Docker Hub</a> hoch).",
"buildScript": {
"title": "Passe das Build Skript an:",
"dependencies": "Optional: Installiere aufgabenspezifische Abhängigkeiten.",
"runTests": "Führe alle Tests aus. Sie sollten JUnit XML Dateien generieren.",
"moveResults": "Bewege die XML Dateien in das <code>{{resultsDirectory}}</code> Verzeichnis."
},
"pushExercise": "Lade den Aufgaben-Code in das entsprechende Repository. Es wird in <code>{{checkoutDirectory}}</code> ausgecheckt.",
"pushSolution": "Lade den Lösungs-Code in das entsprechende Repository. Es wird nicht ausgecheckt.",
"pushTest": "Lade den Test-Code in das entsprechende Repository. Es wird in <code>{{checkoutDirectory}}</code> ausgecheckt."
}
},
"error": {
Expand Down
13 changes: 13 additions & 0 deletions src/main/webapp/i18n/en/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,19 @@
"template": "Template",
"history": "Commit History",
"result": "Result"
},
"otherLanguageHints": {
"title": "To use another language, complete the following tasks. See the <a href=\"{{documentationLink}}\">documentation</a> for details.",
"setImage": "Specify a custom Docker image with the required dependencies (potentially create a custom one and upload it to the <a href=\"{{ghcrLink}}\">GitHub Container Registry</a> or <a href=\"{{dockerhubLink}}\">Docker Hub</a>).",
"buildScript": {
"title": "Customize the build script to:",
"dependencies": "Optional: Install exercise specific dependencies.",
"runTests": "Run all tests. They should generate JUnit XML files.",
"moveResults": "Move the XML files into the <code>{{resultsDirectory}}</code> directory."
},
"pushExercise": "Push the exercise code to its repository. It will be checked out at <code>{{checkoutDirectory}}</code>.",
"pushSolution": "Push the solution code to its repository. It will not be checked out.",
"pushTest": "Push the test code to its repository. It will be checked out in <code>{{checkoutDirectory}}</code>."
}
},
"error": {
Expand Down
Loading