Skip to content
Open
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
1 change: 1 addition & 0 deletions dist/grading/builders/Builder.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/grading/builders/GradleBuilder.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/grading/builders/PythonScriptBuilder.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/grading/graders/OverlayGrader.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 30 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/grading/builders/Builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export abstract class Builder {
return undefined
}
abstract setupVenv(dir: string, key: string): Promise<void>
abstract withGradingDir(gradingDir: string): Builder
}

export type BuildStepOptions = {
Expand Down
3 changes: 3 additions & 0 deletions src/grading/builders/GradleBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,7 @@ export default class GradleBuilder extends Builder {
)
}
}
withGradingDir(gradingDir: string): Builder {
return new GradleBuilder(this.logger, gradingDir, this.regressionTestJob)
}
}
11 changes: 10 additions & 1 deletion src/grading/builders/PythonScriptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export default class PythonScriptBuilder extends Builder {
super(logger, gradingDir, regressionTestJob)
}

withGradingDir(gradingDir: string): Builder {
return new PythonScriptBuilder(
this.logger,
gradingDir,
this.script_info,
this.regressionTestJob
)
}

async activateVenvAndExecuteCommand(
command: string,
timeoutSeconds?: number,
Expand All @@ -54,7 +63,7 @@ export default class PythonScriptBuilder extends Builder {
async setupVenv(dir: string, key: string): Promise<void> {
const isGitHubAction = process.env.GITHUB_ACTIONS === 'true'
let found_cache = false
const venv_dir = `pawtograder-grading/${dir}`
const venv_dir = `${this.gradingDir}/${dir}`
console.log(venv_dir)
if (isGitHubAction) {
console.log('Looking for existing cached virtual environment')
Expand Down
38 changes: 36 additions & 2 deletions src/grading/graders/OverlayGrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { access, readdir } from 'fs/promises'
import { tmpdir } from 'os'
import path from 'path'
import { AutograderFeedback } from '../../api/adminServiceSchemas.js'
import { Builder, MutantResult, TestResult } from '../builders/Builder.js'
import {
Builder,
LintResult,
MutantResult,
TestResult
} from '../builders/Builder.js'
import GradleBuilder from '../builders/GradleBuilder.js'
import PythonScriptBuilder from '../builders/PythonScriptBuilder.js'
import {
Expand Down Expand Up @@ -66,6 +71,35 @@ export class OverlayGrader extends Grader<OverlayPawtograderConfig> {
}
}

private async lintInCleanStudentDir(): Promise<LintResult> {
if (!this.builder) {
throw new Error('Builder is not set')
}
const tmpDir = path.join(process.cwd(), 'pawtograder-student-linting')
await io.mkdirP(tmpDir)
//Copy ALL files from the student directory to the tmpDir
const studentFiles = await readdir(this.submissionDir)
await Promise.all(
studentFiles.map(async (file) => {
await io.cp(
path.join(this.submissionDir, file),
path.join(tmpDir, file),
{ recursive: true }
)
})
)
const builder = this.builder.withGradingDir(tmpDir)
if (this.config.build.venv?.cache_key && this.config.build.venv?.dir_name) {
const venv_dir = this.config.build.venv.dir_name
const cache_key = this.config.build.venv.cache_key
await builder.setupVenv(venv_dir, cache_key)
}

const lintResult = await builder.lint()
await io.rmRF(tmpDir)
return lintResult
}

async copyStudentFiles(whichFiles: 'files' | 'testFiles') {
const files = this.config.submissionFiles[whichFiles]

Expand Down Expand Up @@ -371,7 +405,7 @@ export class OverlayGrader extends Grader<OverlayPawtograderConfig> {
}

this.logger.log('visible', 'Linting student submission')
const lintResult = await this.builder.lint()
const lintResult = await this.lintInCleanStudentDir()
if (this.config.build.linter?.policy === 'fail') {
if (lintResult.status === 'fail') {
this.logger.log(
Expand Down