-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
173 lines (154 loc) · 5.68 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: "WD301 Action"
description: 'Handles checkout, testing, and grading for WD301 submissions'
author: 'pupilfirst'
inputs:
level_name:
description: "Name of level e.g., l1, l2, etc."
globs:
description: "This contains the list of files that will be checked during repo verification"
copy_commands:
description: "Shell commands to execute that copy the required files for running tests"
submissionUrl:
description: "It contains the url of live application"
server:
description: "Contains boolean value determining whether Server should be started for the test"
default: false
cypress_with_env:
description: "Contains boolean value indicating whether Cypress tests require an env value."
default: false
report_file_path:
description: "It contains the path to report.json file, ex: submission/someFolder/report.json"
api:
description: "Boolean value to determine if API specific steps should be run"
default: false
runs:
using: "composite"
steps:
# checkout student's repository and verify its structure
- name: Checkout student repo and verify its structure
id: check-student-repo
uses: pupilfirst/check-repo-action@v1
with:
repoPath: submission
globs: ${{inputs.globs}}
- name: Report check-repo failure to LMS
if: steps.check-student-repo.outputs.result != 'success'
uses: pupilfirst/report-action@v1
with:
status: "failure"
description: |
The check-repo action reported failure. The student should have
received automated feedback regarding the issue that was detected.
- name: Report to LMS tests in progress
if: steps.check-student-repo.outputs.result == 'success'
uses: pupilfirst/report-action@v1
with:
status: "in_progress"
description: "The automated tests are in progress"
- name: Check out the tests repo
if: steps.check-student-repo.outputs.result == 'success'
uses: actions/checkout@v2
id: checkout-tests-repo
with:
repository: pupilfirst/wd301-tests
path: tests
- name: Copy submission files to tests folder
if: steps.checkout-tests-repo.outcome == 'success'
id: copy-submission-files
run: ${{inputs.copy_commands}}
shell: bash
- name: Install Dependencies
if: steps.check-student-repo.outputs.result == 'success' && inputs.api == 'false'
run: |
cd tests/${{inputs.level_name}}
npm install
shell: bash
- name: Run server using merged code
continue-on-error: true
id: run-server
if: steps.copy-submission-files.outcome == 'success' && inputs.server == 'true'
run: |
cd tests/${{inputs.level_name}}
npm run dev &
sleep 5
shell: bash
- name: Run tests
continue-on-error: true
if: steps.copy-submission-files.outcome == 'success' && inputs.cypress_with_env == 'false' && inputs.api == 'false'
run: |
cd tests/${{inputs.level_name}}
npm run test
shell: bash
- name: Run cypress tests
continue-on-error: true
if: steps.copy-submission-files.outcome == 'success' && inputs.cypress_with_env == 'true'
run: |
cd tests/${{inputs.level_name}}
npm run cy:run -- --env STUDENT_SUBMISSION_URL="${{inputs.submissionUrl}}"
shell: bash
- name: Check out the API repo
if: steps.check-student-repo.outputs.result == 'success' && inputs.api == 'true'
uses: actions/checkout@v3
id: checkout-api-repo
with:
repository: pupilfirst/wd301-api
path: api
- name: Run the API
if: steps.checkout-api-repo.outcome == 'success' && inputs.api == 'true'
id: run-api
run: |
cd api
npm install
npx sequelize-cli db:migrate
echo PORT=3001 > .env
npm run start &
sleep 5
shell: bash
- name: Run the smarter-tasks app
if: steps.copy-submission-files.outcome == 'success' && inputs.api == 'true'
id: run-app
run: |
cd submission/smarter-tasks
rm -f .env
echo VITE_API_ENDPOINT="http://localhost:3001" > .env
npm install
npm run dev &
sleep 5
shell: bash
- name: Run cypress tests
continue-on-error: true
if: steps.run-app.outcome == 'success' && inputs.api == 'true'
run: |
cd submission/smarter-tasks
npm install cypress cypress-json-results
npx cypress run --env STUDENT_SUBMISSION_URL="http://localhost:5173/"
shell: bash
- name: Use Node.js to generate report
if: steps.copy-submission-files.outcome == 'success'
id: generate-report
run: |
if [[ "${{ inputs.level_name }}" =~ ^l([6-9])$ ]]; then
cd submission/smarter-tasks && node generateReportFromResults.js
else
cd tests/${{ inputs.level_name }} && node generateReportFromResults.js
fi
shell: bash
- name: Report to LMS the outcome of tests.
if: steps.generate-report.outcome == 'success'
uses: pupilfirst/report-action@v1
id: report-test-results
with:
report_file_path: ${{inputs.report_file_path}}
- name: Grade the submission based on test results
uses: pupilfirst/grade-action@v1
if: steps.generate-report.outcome == 'success'
with:
report_file_path: ${{inputs.report_file_path}}
- name: Report error to LMS
if: steps.report-test-results.outcome == 'skipped'
uses: pupilfirst/report-action@v1
with:
status: "error"
description: |
Automated tests could not be run successfully. Please ask a member
of the Pupilfirst team to look into this submission's VTA logs.