-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
82 lines (74 loc) · 2.59 KB
/
action.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
82
name: "WD101 Action"
description: 'Handles checkout, copying, testing, and grading for WD101 submissions'
author: 'pupilfirst'
inputs:
level_name:
description: "Name of level eg. L5, L6 etc."
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
# Report to LMS tests are in progress
- name: Report to LMS that tests in progress
uses: pupilfirst/report-action@v1
with:
status: "in_progress"
description: "Automated tests are in progress."
- name: Check out the solutions repo
id: checkout-solutions-repo
uses: actions/checkout@v2
with:
repository: pupilfirst/wd101-tests
path: solution
- name: Check for .js file and copy
run: |
js_file=$(find . -maxdepth 1 -name "*.js" -print -quit)
if [ -n "$js_file" ]; then
echo "Valid JS file found: $js_file"
cp "$js_file" solution/script.js
echo "isValid=true" >> $GITHUB_ENV
else
echo "No JS file found"
echo "isValid=false" >> $GITHUB_ENV
fi
shell: bash
- name: Report invalid JS file to the LMS by rejecting submission.
if: env.isValid != 'true'
id: invalid-js-file
uses: pupilfirst/grade-action@v1
with:
fail_submission: true
feedback: |
Hi there. We tried to test the file that you submitted. Unfortunately, it didn't work as expected.
We are unable process your input, as the uploaded file is not a valid JS file. Please create another
submission with your JS file. Once you upload the file, we'll test the file to check if it returns
the correct output
Give it another go!
- name: Run tests in the solution repo
if: env.isValid == 'true'
continue-on-error: true
id: run-test
run: |
cd solution
cp -r ${{ inputs.level_name }}/script.test.js ./script.test.js
npm install
npm run test
shell: bash
- name: Generate feedback from test results
id: generate-feedback
run: |
cd solution
node generateReportFromResults.js
shell: bash
- name: Grade the submission based on test results
if: steps.generate-feedback.outcome == 'success'
uses: pupilfirst/grade-action@v1
with:
report_file_path: "solution/report.json"
# Report outcome of tests to the LMS
- name: Report outcome of tests to LMS
uses: pupilfirst/report-action@v1
if: steps.generate-feedback.outcome == 'success'
id: report-test-results
with:
report_file_path: "solution/report.json"