Skip to content
Snippets Groups Projects
Commit c5770e2b authored by joel.vonderwe's avatar joel.vonderwe
Browse files

Add allowSonarFailure feature

parent 263434e6
No related branches found
No related tags found
No related merge requests found
Pipeline #38944 passed
......@@ -29,9 +29,7 @@ import ExerciseAssignment from './sharedByClients/models/Exerc
import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsSharedExerciseHelper';
import Icon from './shared/types/Icon';
import SharedConfig from './shared/config/SharedConfig';
import assignment from './sharedByClients/models/Assignment';
import SonarAnalyzer from './sharedByClients/helpers/Dojo/SonarAnalyzer';
import AssignmentCheckerError from './shared/types/Dojo/AssignmentCheckerError';
import Exercise from './sharedByClients/models/Exercise';
......@@ -46,6 +44,7 @@ import Exercise from './sharedByClients/models/Exerc
let exerciseResultsValidation: ExerciseResultsSanitizerAndValidator;
let haveResultsVolume: boolean;
let sonarSuccess: boolean | undefined = undefined;
/*
......@@ -75,9 +74,6 @@ import Exercise from './sharedByClients/models/Exerc
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 2:
- Run sonar analysis
*/
console.log(SharedConfig.sonar);
console.log(exerciseAssignment.assignment.useSonar)
console.log(exercise);
if (SharedConfig.sonar.enabled && exerciseAssignment.assignment.useSonar) {
console.log(Styles.INFO(`${ Icon.INFO }Running Sonar analysis on the exercise`));
......@@ -95,8 +91,8 @@ import Exercise from './sharedByClients/models/Exerc
}
}
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);
}
......@@ -194,7 +190,7 @@ import Exercise from './sharedByClients/models/Exerc
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));
......
......@@ -30,11 +30,12 @@ class DojoBackendManager {
}
}
public async sendResults(exitCode: number, commit: Record<string, string>, results: ExerciseResultsFile, files: Array<IFileDirStat>, archiveBase64: string): Promise<void> {
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 d15be9b16181f5f172d51b13966e0e44bd34f55d
Subproject commit 047bc2e9e1c2ef6eed1c04806c2cba8e08bb1c3e
# 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