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

Commit

Permalink
try porting more from autograding v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishkeshan committed Dec 6, 2023
1 parent ce32d74 commit 63dbaf6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/notify-classroom.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,33 @@ exports.NotifyClassroom = async function NotifyClassroom (runnerResults) {
console.log(`Run ID: ${runId}`)
if (Number.isNaN(runId)) return

// List check runs for the repository
const checkRunsResponse = await octokit.rest.checks.listForRef({
// Fetch the workflow run
const workflowRunResponse = await octokit.rest.actions.getWorkflowRun({
owner,
repo,
check_name: 'Autograding Tests'
run_id: runId,
})

// Find the check suite run
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const checkSuiteUrl = (workflowRunResponse.data).check_suite_url
const checkSuiteId = parseInt(checkSuiteUrl.match(/[0-9]+$/)[0], 10)
const checkRunsResponse = await octokit.rest.checks.listForSuite({
owner,
repo,
check_name: 'Autograding Tests',
check_suite_id: checkSuiteId,
})

// List check runs for the repository
// const checkRunsResponse = await octokit.rest.checks.listForRef({
// owner,
// repo,
// check_name: 'Autograding Tests'
// })

// Filter to find the check run named "Autograding Tests" for the specific workflow run ID
const checkRun = checkRunsResponse.data.check_runs.find(cr => cr.name === 'Autograding Tests' && cr.check_suite.workflow_run_id === runId)
const checkRun = checkRunsResponse.data.total_count === 1 && checkRunsResponse.data.check_runs[0]
console.log(`Check run: ${checkRun}`)
if (!checkRun) return

Expand Down

0 comments on commit 63dbaf6

Please sign in to comment.