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

[WRONG PR] #19

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/workflows/deploy.yml

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@types/node": "^18.8.4",
"axios": "^0.27.2",
"del": "^6.1.1",
"dotenv": "^16.0.3",
"minimist": "^1.2.7",
"newman": "^5.3.2",
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ReviewResult from "./entities/review-result/course-submission-review/revi
import SubmissionProjectFactory from "./factories/submission-project/submission-project-factory";
import getSubmissionRequirement, {SubmissionRequirement} from "./config/submission-requirement";
import raiseDomainEvent from "./common/domain-event";
import { sync } from 'del'

class Main {
private postmanRunner: PostmanRunner;
Expand Down Expand Up @@ -59,6 +60,9 @@ class Main {
} else {
console.log(e)
}
} finally {
// remove all files in submissionPath except report.json
sync([`${submissionPath}/**`, `!${submissionPath}/report.json`])
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/interface/implementation-test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {readdirSync} from "fs";
import * as path from "path";
import {join} from "path";
import {main} from "../service-provider";
import ReportGenerator from "../service/report-generator/report-generator";

const reportGenerator = new ReportGenerator('./report')
async function run() {
const allSubmission = readdirSync('../experiment-storage/project')
const experimentStorageProjectPath = join(process.cwd(), 'experiment-storage', 'project')
const allSubmission = readdirSync(experimentStorageProjectPath)

for (const submission of allSubmission) {
console.log(`checking ${submission}`)
const submissionPath = path.resolve('../experiment-storage/project', submission)
const submissionPath = join(experimentStorageProjectPath, submission)
const reviewResult = await main.reviewSubmission(submissionPath)
const reportGenerator = new ReportGenerator(submissionPath)
reportGenerator.generate(reviewResult, submission)
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/service/report-generator/report-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
import ReviewResult, {ReviewResultStatus} from "../../entities/review-result/course-submission-review/review-result";
import * as fs from "fs";

function itShouldMeetAGRSReportSpec(report: any): void {

Check warning on line 6 in src/service/report-generator/report-generator.test.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type
expect(report.submission_id).toBeDefined()
expect(typeof report.submission_id).toEqual('number')
expect(report.message).toBeDefined()
expect(typeof report.message).toEqual('string')
expect(report.rating).toBeDefined()
expect(typeof report.rating).toEqual('number')
expect(report.is_passed).toBeDefined()
expect(typeof report.is_passed).toEqual('boolean')
expect(report.is_draft).toBeDefined()
expect(typeof report.is_draft).toEqual('boolean')
expect(report.checklist_keys).toBeDefined()
expect(Array.isArray(report.checklist_keys)).toEqual(true)
}

describe('checklist id resolver test', () => {
const reportGenerator = new ReportGenerator('./test/student/review-result/')

Expand All @@ -29,6 +44,8 @@

const result = JSON.parse(fs.readFileSync('./test/student/review-result/report.json').toString())[0]

itShouldMeetAGRSReportSpec(result)

expect(result.checklist_keys).toEqual([
"project_have_correct_port",
"project_have_correct_runner_script",
Expand Down
8 changes: 6 additions & 2 deletions src/service/report-generator/report-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {existsSync, readFileSync, writeFileSync} from "fs";
import * as templates from "../../config/review-template.json";
import raiseDomainEvent from "../../common/domain-event";
import {join} from "path";

class ReportGenerator {
private readonly reportPath: string;
Expand All @@ -25,13 +26,16 @@
message: this.getReviewMessageWithTemplate(reviewResult, autoReviewConfig),
submission_path: submissionPath,
checklist: reviewResult.checklist,
checklist_keys: this.getCompletedChecklist(reviewResult)
checklist_keys: this.getCompletedChecklist(reviewResult),
is_passed: isApproved,
is_draft: true,
};

this.result.push(summary);
fs.mkdirSync(this.reportPath, {recursive: true});
const fileReportPath = join(this.reportPath, 'report.json')

writeFileSync(`${this.reportPath}/report.json`, JSON.stringify(this.result), {
writeFileSync(fileReportPath, JSON.stringify(this.result), {
mode: '0664'
})
raiseDomainEvent('report generated')
Expand Down Expand Up @@ -63,7 +67,7 @@
}


private getAutoReviewConfig(projectPath: string): any | null {

Check warning on line 70 in src/service/report-generator/report-generator.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type

const configFilePath = `${projectPath}/auto-review-config.json`
if (!existsSync(configFilePath)) {
Expand Down
Loading
Loading