From d538b3eb42fd5b16b64549b7102ac40683cd4064 Mon Sep 17 00:00:00 2001 From: Mark Patterson <35724907+markpatterson27@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:29:44 +0000 Subject: [PATCH 1/4] add points input to action --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) 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" From 537130378f287a5e3ee3a25ca03bfc90b8eb886c Mon Sep 17 00:00:00 2001 From: Mark Patterson <35724907+markpatterson27@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:30:48 +0000 Subject: [PATCH 2/4] post check run directly if points inputs exist --- src/autograding.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/autograding.ts b/src/autograding.ts index aead50e8..23da4124 100644 --- a/src/autograding.ts +++ b/src/autograding.ts @@ -2,9 +2,23 @@ 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) { + 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') From f648c91f924f90c018e0b3b7fd276aa72fb20d38 Mon Sep 17 00:00:00 2001 From: Mark Patterson <35724907+markpatterson27@users.noreply.github.com> Date: Mon, 4 Dec 2023 07:35:04 +0000 Subject: [PATCH 3/4] add integration test for point inputs --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 2a9337b695df8c090bfc4c2f3e22c010aaeb8196 Mon Sep 17 00:00:00 2001 From: Mark Patterson <35724907+markpatterson27@users.noreply.github.com> Date: Mon, 4 Dec 2023 07:48:39 +0000 Subject: [PATCH 4/4] set info message --- src/autograding.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autograding.ts b/src/autograding.ts index 23da4124..d6ad813d 100644 --- a/src/autograding.ts +++ b/src/autograding.ts @@ -12,6 +12,7 @@ const run = async (): Promise => { // 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)