-
Notifications
You must be signed in to change notification settings - Fork 1
/
1603.yml
108 lines (106 loc) · 4.12 KB
/
1603.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
name: Ruby Test Runner
on:
push:
branches: ["submission-*"]
jobs:
repo_check:
runs-on: ubuntu-latest
outputs:
outcome: ${{steps.get-repo-name.outcome}}
repoName: ${{steps.get-repo-name.outputs.result}}
steps:
- name: Check out the parent repository with student submission data
uses: actions/checkout@v2
- name: Extract the student submission repo from URL
uses: actions/github-script@v5
id: get-repo-name
continue-on-error: true
with:
script: |
const submission = require('./submission.json')
const gitURL = submission.checklist[0].result
const regex = /(?:git@|https:\/\/)github.com[:\/]([a-zA-Z0-9\-_.]+\/[a-zA-Z0-9\-_.\/]+)$/g
const repoName = regex.exec(gitURL)[1].replace(/.git$|\/$/, "")
if (repoName.split("/").length == 2) {
return repoName
} else {
throw "The submitted URL seems to be of a folder inside a repository"
}
result-encoding: string
- name: Report invalid repository URL in submission
if: steps.get-repo-name.outcome != 'success'
uses: pupilfirst/grade-action@v1
with:
fail_submission: true
feedback: The submitted repository URL is either invalid or private. Please make sure that you submit a valid public repository URL and not a link to directory or branch.
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}
tests:
needs: repo_check
if: needs.repo_check.outputs.outcome == 'success'
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["3.1.1"]
steps:
- name: Check out the parent repository with student submission data
uses: actions/checkout@v2
- name: Check out the repository with student code
uses: actions/checkout@v2
continue-on-error: true
id: checkout-student-repo
with:
repository: ${{needs.repo_check.outputs.repoName}}
path: submission
- name: Report invalid repository URL in submission
if: steps.checkout-student-repo.outcome != 'success'
uses: pupilfirst/report-action@v1
with:
status: "error"
description: "The student repo does not exist"
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}
- name: Check out the repository with solutions and tests
uses: actions/checkout@v2
with:
repository: "pupilfirst/wd201-solutions"
path: solution
- name: Report to LMS tests in progress
uses: pupilfirst/report-action@v1
with:
status: "in_progress"
description: "The automated tests are in progress"
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}
- name: Install Ruby dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
working-directory: solution/l2
bundler-cache: true
- name: Copy student lookup file to solution directory
id: copy-student-file
continue-on-error: true
run: |
rm solution/l2/lookup.rb
cp submission/lookup.rb solution/l2
- name: Run tests on student submission
working-directory: solution/l2
run: bundle exec ruby test.rb
- name: Grade the submission based on test results
uses: pupilfirst/grade-action@v1
with:
report_file_path: "solution/l2/report.json"
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}
- name: Report to LMS the outcome of tests.
uses: pupilfirst/report-action@v1
with:
report_file_path: "solution/l2/report.json"
env:
REVIEW_END_POINT: ${{ secrets.REVIEW_END_POINT }}
REVIEW_BOT_USER_TOKEN: ${{ secrets.REVIEW_BOT_USER_TOKEN }}