forked from ProjectX-VJTI/Xplore-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.57 KB
/
Copy pathcheckvalidpr.yaml
File metadata and controls
76 lines (65 loc) · 2.57 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: PR Auto Grader
on:
pull_request_target:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
grade:
name: PR Auto Grader
runs-on: ubuntu-latest
env:
# Future-proofing against the Node 20 deprecation warning
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
# 1️⃣ Checkout the Student's PR branch
# We use fetch-depth: 0 to ensure we have the history needed for git diff
- name: Checkout PR Code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
# 2️⃣ Checkout Private Grader Repository
# Using the PAT to access your private test runner
- name: Checkout Private Grader
uses: actions/checkout@v4
with:
repository: Once-1296/CoC-workshop-test-runner
token: ${{ secrets.GRADER_REPO_TOKEN }}
path: grader_repo
persist-credentials: false
# 3️⃣ Fetch the Main branch from the ORIGINAL repo
# This fixes the "fatal: bad object" error by letting Git see the Base SHA
- name: Fetch Main Branch
run: |
git remote add upstream https://github.com/${{ github.repository }}
git fetch upstream main
# 4️⃣ Assemble Workspace
# Note: Ensure the folder structure matches your Python allowed_prefix logic
- name: Assemble Workspace
run: |
mkdir -p workspace/student_repo
cp -r grader_repo/grader workspace/
cp -r grader_repo/hidden_tests workspace/
# Adjusting this to match your Python script's expected path
# If the folder is SOLUTIONS/username, we copy that content
TARGET_DIR="SOLUTIONS/${{ github.event.pull_request.user.login }}"
if [ -d "$TARGET_DIR" ]; then
cp -r "$TARGET_DIR/." workspace/student_repo/
else
echo "⚠️ Warning: $TARGET_DIR not found"
fi
ls -R workspace
# 5️⃣ Validate Repository Structure
- name: Validate Structure
run: python3 grader_repo/grader/validate_structure.py
# 6️⃣ Validate Only Allowed Files Modified
- name: Validate Diff
run: python3 grader_repo/grader/validate_diff.py
env:
GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PULL_REQUEST_AUTHOR: ${{ github.event.pull_request.user.login }}