Skip to content

Commit 25538c1

Browse files
committed
Support the 'none' builder
1 parent ed0e37a commit 25538c1

File tree

5 files changed

+62
-20
lines changed

5 files changed

+62
-20
lines changed

dist/grader/types.d.ts

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grader/Grader.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function icon(result: TestResult) {
4747
}
4848
}
4949
class Grader {
50-
private builder: Builder
50+
private builder: Builder | undefined
5151
private logger: Logger
5252
constructor(
5353
private solutionDir: string,
@@ -57,11 +57,17 @@ class Grader {
5757
private regressionTestJob?: number
5858
) {
5959
this.logger = new Logger(regressionTestJob)
60-
this.builder = new GradleBuilder(
61-
this.logger,
62-
this.gradingDir,
63-
this.regressionTestJob
64-
)
60+
if (this.config.build.preset == 'java-gradle') {
61+
this.builder = new GradleBuilder(
62+
this.logger,
63+
this.gradingDir,
64+
this.regressionTestJob
65+
)
66+
} else if (this.config.build.preset == 'none') {
67+
this.builder = undefined
68+
} else {
69+
throw new Error(`Unsupported build preset: ${this.config.build.preset}`)
70+
}
6571
if (regressionTestJob) {
6672
console.log(
6773
`Autograder configuration: ${JSON.stringify(this.config, null, 2)}`
@@ -257,6 +263,18 @@ class Grader {
257263
)
258264
}
259265
async grade(): Promise<AutograderFeedback> {
266+
if (!this.builder) {
267+
return {
268+
lint: {
269+
status: 'pass',
270+
output: 'Linter is not enabled for this assignment'
271+
},
272+
output: this.logger.getEachOutput(),
273+
tests: [],
274+
score: 0,
275+
artifacts: []
276+
}
277+
}
260278
// const tmpDir = await mkdtemp(path.join(tmpdir(), 'pawtograder-'));
261279
console.log('Beginning grading')
262280
const tmpDir = path.join(process.cwd(), 'pawtograder-grading')
@@ -292,7 +310,8 @@ class Grader {
292310
`Build failed, submission can not be graded. Please fix the above errors below and resubmit. This submission will not count towards any submisison limits (if applicable for this assignment).`
293311
)
294312
this.logger.log('visible', msg)
295-
const allTests: AutograderTestFeedback[] = this.config.gradedParts
313+
const gradedParts = this.config.gradedParts || []
314+
const allTests: AutograderTestFeedback[] = gradedParts
296315
.filter((part) => !part.hide_until_released)
297316
.map((part) =>
298317
part.gradedUnits.map((gradedUnit) => {
@@ -397,7 +416,8 @@ class Grader {
397416
studentTestResults = await this.builder.test()
398417
}
399418
console.log('Wrapping up')
400-
const testFeedbacks = this.config.gradedParts
419+
const gradedParts = this.config.gradedParts || []
420+
const testFeedbacks = gradedParts
401421
.map((part) =>
402422
this.gradePart(part, testResults, mutantResults, mutantFailureAdvice)
403423
)

src/grader/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { AutograderFeedback } from '../api/adminServiceSchemas.js'
22

33
// Build configuration types
44
export interface BuildConfig {
5-
preset: 'java-gradle'
6-
cmd: string
5+
preset: 'java-gradle' | 'none'
6+
cmd?: string
77
artifacts?: GraderArtifact[]
8-
linter: {
8+
linter?: {
99
preset: 'checkstyle'
1010
policy: 'fail' | 'warn' | 'ignore'
1111
}
@@ -54,7 +54,7 @@ export interface GradedPart {
5454
// Main configuration type
5555
export interface PawtograderConfig {
5656
build: BuildConfig
57-
gradedParts: GradedPart[]
57+
gradedParts?: GradedPart[]
5858
submissionFiles: {
5959
files: string[]
6060
testFiles: string[]

0 commit comments

Comments
 (0)