Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Add direct points input #248

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 15 additions & 0 deletions src/autograding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
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')
Expand Down