import * as core from '@actions/core' ; import fs from 'fs' ; import path from 'path' ; import { Test , runAll } from './runner' ; const run = async ( ) : Promise < void > => { try { const cwd = process . env [ 'GITHUB_WORKSPACE' ] ; if ( ! cwd ) { throw new Error ( 'No GITHUB_WORKSPACE' ) ; } const data = fs . readFileSync ( path . resolve ( cwd , '.github/classroom/autograding.json' ) ) ; const json = JSON . parse ( data . toString ( ) ) ; await runAll ( json . tests as Array < Test > , cwd ) ; } catch ( error ) { console . error ( error . message ) ; core . setFailed ( `Autograding failure: ${ error }` ) ; } } ; if ( process . env [ 'NODE_ENV' ] !== 'test' ) { run ( ) ; } export default run ;