diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b695e82c..d818e350 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,4 +33,11 @@ jobs: - run: npm ci - run: npm run build + # run the action from the local path - uses: ./ + + # run the local action with point inputs + - uses: ./ + with: + points: 10 + available-points: 20 diff --git a/action.yml b/action.yml index 594f7960..41812999 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,14 @@ inputs: by replacing this token with a user token which has write-access to your repository. Note that the token will be accessible to all repository collaborators. default: ${{ github.token }} + points: + description: > + The number of points scored for this assignment. Must be an integer. + required: false + available-points: + description: > + The total number of points available for this assignment. Must be an integer. + required: false runs: using: "node16" main: "./dist/index.js" diff --git a/src/autograding.ts b/src/autograding.ts index aead50e8..d6ad813d 100644 --- a/src/autograding.ts +++ b/src/autograding.ts @@ -2,9 +2,24 @@ import * as core from '@actions/core' import fs from 'fs' import path from 'path' import {Test, runAll} from './runner' +import {setCheckRunOutput} from './output' const run = async (): Promise => { try { + // try to get points inputs + const points = core.getInput('points') + const availablePoints = core.getInput('available-points') + + // if points inputs are present, set the output and call checkRun + if (points && availablePoints) { + core.info(`Using direct input points.`) + const text = `Points ${points}/${availablePoints}` + core.setOutput('Points', `${points}/${availablePoints}`) + await setCheckRunOutput(text) + return + } + + // Otherwise, try to run the tests const cwd = process.env['GITHUB_WORKSPACE'] if (!cwd) { throw new Error('No GITHUB_WORKSPACE')