-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path18753.yml
81 lines (75 loc) · 3.1 KB
/
18753.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: WD-201 | L1 Milestone
on:
push:
branches: ["submission-*"]
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}
jobs:
tests:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout student repo and verify its structure
id: check-student-repo
uses: pupilfirst/check-repo-action@v1
with:
repoPath: submission
globs: |-
.gitignore
hello-world/index.js
hello-world/package.json
- name: Check submission output using Node
if: ${{ steps.check-student-repo.outputs.result == 'success' }}
id: check-submission-output
run: |
node submission/hello-world/index.js > output.txt
continue-on-error: true
- name: Report failure to run script
if: steps.check-submission-output.outcome == 'failure'
uses: pupilfirst/grade-action@v1
with:
fail_submission: true
feedback: |
We tried to run the script using the command `node hello-world/index.js`,
but some reason, we couldn't. Before submitting again, could you
please verify whether your `hello-world/index.js` file contains
valid JavaScript code? Also, please ensure that you run your script
before submitting again.
If this error persists, please ask for assistance on the
**#wd-forum** channel on the Pupilfirst School Discord server, and
one of our team members will take a look at why we're unable to
execute your code.
- name: Generate feedback report using script output
uses: actions/github-script@v6
id: generate-report
if: steps.check-submission-output.outcome == 'success'
with:
script: |
const fs = require("fs");
function checkValidString(input) {
return input.toLowerCase().indexOf("hello") > -1;
}
fs.readFile("output.txt", "utf8", (err, data) => {
if (err) {
throw err;
} else {
let passed = checkValidString(data);
let reportFile = "./report.json";
let feedback = passed
? "Good work! It looks like your code prints the output according to the specification."
: "Uh oh! It looks like you've missed some parts of the assignment! Please ensure that your `index.js` script outputs the expected message mentioned in the assignment and try again.";
let report = {
version: 0,
grade: passed ? "accept" : "reject",
status: passed ? "success" : "failure",
feedback: feedback,
};
fs.writeFileSync(reportFile, JSON.stringify(report));
}
})
- name: Grade the submission based on test results
uses: pupilfirst/grade-action@v1
if: steps.generate-report.outcome == 'success'
with:
report_file_path: "report.json"