-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.64 KB
/
auto-grade.yml
File metadata and controls
58 lines (50 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Auto grade Assignment
on:
workflow_call:
inputs:
working-directory:
required: false
default: ".hyf"
type: string
jobs:
test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
# Checkout the trainee's assignment code
- name: Checkout assignment code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
path: assignment
# Checkout the grading workflow scripts
- name: Checkout workflow scripts
uses: actions/checkout@v6
with:
repository: HackYourFuture/github-actions
path: workflow-scripts
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
# Run the tests from the assignment directory
- name: Run tests
working-directory: assignment/${{ inputs.working-directory }}
run: bash test.sh > test-output.txt 2>&1
# Post the test results as a comment on the PR
- name: Comment PR
uses: actions/github-script@v8
with:
script: |
const path = require('path');
const run = require(path.join(process.env.GITHUB_WORKSPACE, 'workflow-scripts/workflow-scripts/comment-pr.js'));
process.chdir(path.join(process.env.GITHUB_WORKSPACE, 'assignment'));
await run({ github, context, core });
- name: Fail if tests failed
run: |
PASS=$(jq -r '.pass' assignment/${{ inputs.working-directory }}/score.json)
if [ "$PASS" != "true" ]; then
exit 1
fi