Skip to content
Snippets Groups Projects
Commit cc2110d2 authored by joel.vonderwe's avatar joel.vonderwe Committed by michael.minelli
Browse files

Add allowSonarFailure feature

parent d0491702
Branches
No related tags found
No related merge requests found
Pipeline #38945 failed
......@@ -28,6 +28,8 @@ let exerciseDockerCompose: ExerciseDockerCompose;
let exerciseResultsValidation: ExerciseResultsSanitizerAndValidator;
let haveResultsVolume: boolean;
let sonarSuccess: boolean | undefined = undefined;
/**
* Step 1:
......@@ -76,8 +78,8 @@ async function runSonarAnalysis() {
}
}
const runSuccess = SonarAnalyzer.runAnalysis(exercise!.sonarKey, exerciseAssignment!.assignment.language, exerciseAssignment!.assignmentFile.buildLine);
if ( !runSuccess ) {
sonarSuccess = SonarAnalyzer.runAnalysis(exercise!.sonarKey, exerciseAssignment!.assignment.language, exerciseAssignment!.assignmentFile.buildLine);
if ( !sonarSuccess && !exerciseAssignment!.assignment.allowSonarFailure ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Sonar gate failed`));
process.exit(ExerciseCheckerError.SONAR_GATE_FAILED);
}
......@@ -183,7 +185,7 @@ async function uploadResults() {
liteStats : true
});
await DojoBackendManager.sendResults(exerciseDockerCompose.exitCode, commit, exerciseResultsValidation.exerciseResults, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume));
await DojoBackendManager.sendResults(exerciseDockerCompose.exitCode, commit, exerciseResultsValidation.exerciseResults, sonarSuccess, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume));
} catch ( error ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Error while uploading the results`));
console.error(JSON.stringify(error));
......
......@@ -26,11 +26,12 @@ class DojoBackendManager {
}
}
public async sendResults(exitCode: number, commit: Record<string, string>, results: ExerciseResultsFile, files: Array<IFileDirStat>, archiveBase64: string): Promise<void> {
await axios.post(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_RESULTS, { exerciseIdOrUrl: Config.exercise.id }), {
public async sendResults(exitCode: number, commit: Record<string, string>, results: ExerciseResultsFile, sonarGatePass: boolean | undefined, files: Array<IFileDirStat>, archiveBase64: string): Promise<void> {
await axios.post(this.getApiUrl(ApiRoute.EXERCISE_RESULTS).replace('{{id}}', Config.exercise.id), {
exitCode : exitCode,
commit : JSON.stringify(commit),
results : JSON.stringify(results),
sonarGatePass: sonarGatePass?.toString() ?? "",
files : JSON.stringify(files),
archiveBase64: archiveBase64
});
......
Subproject commit 59308a719fdee1a2025e90a18774d56fc6d11d9b
Subproject commit eedbe869a561f6e9a3b02fa9374cee425af27946
# Node needed to analyze JS/TS files
FROM node:18-slim AS node_base
FROM gcc:14
ARG SONAR_HOST_URL=https://isc-sonar.edu.hesge.ch
RUN apt update && apt install -y curl unzip build-essential make g++ clang && apt clean
RUN apt update && apt install -y curl unzip build-essential make g++ clang git-core openssl libssl-dev && apt clean
# Download sonar tools
RUN mkdir -p /sonar && \
......@@ -26,3 +29,5 @@ RUN mkdir -p /usr/src && \
USER sonar
WORKDIR /usr/src
COPY --from=node_base /usr/local/bin /usr/local/bin
COPY --from=node_base /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/npm
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment