-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Autograding | ||
|
||
on: | ||
pull_request_target: | ||
types: [labeled, synchronize, opened, reopened, ready_for_review] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
- name: Extract lab number and Check no changes other than specific files | ||
uses: actions/github-script@v5 | ||
id: lab | ||
with: | ||
result-encoding: string | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { owner, repo, number: issue_number } = context.issue; | ||
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number }); | ||
const labels = pr.data.labels; | ||
const lab = labels.find((label) => label.name.startsWith('lab')); | ||
if (!lab) { | ||
core.setFailed('No lab label found on the PR.'); | ||
return { number: 0 }; | ||
} | ||
const labNumberMatch = lab.name.match(/lab(\d+)/); | ||
if (!labNumberMatch) { | ||
core.setFailed('Invalid lab label found on the PR.'); | ||
return { number: 0 }; | ||
} | ||
const labNumber = labNumberMatch[1]; | ||
console.log(`Lab number: ${labNumber}`) | ||
const files = await github.rest.pulls.listFiles({ owner, repo, pull_number: issue_number }); | ||
const changedFiles = files.data.map((file) => file.filename); | ||
const allowedFiles = [ | ||
`lab${labNumber}/main_test.js`, | ||
]; | ||
if (!changedFiles.every((file) => allowedFiles.includes(file))) { | ||
core.setFailed('The PR contains changes to files other than the allowed files.'); | ||
} | ||
return labNumber; | ||
- name: Grading | ||
run: | | ||
cd lab${{ steps.lab.outputs.result }} | ||
./validate.sh |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "./merge-all.sh <commit-message>" | ||
exit 1 | ||
fi | ||
|
||
git fetch origin | ||
|
||
for branch in $(git branch -r | grep -v HEAD); do | ||
# Remove the "origin/" prefix | ||
branch=${branch#origin/} | ||
|
||
if [[ "$branch" != "main" ]]; then | ||
git checkout "$branch" | ||
if [[ $? -ne 0 ]]; then | ||
echo "Checkout failed for branch $branch" | ||
exit 1 | ||
fi | ||
git merge --squash main | ||
if [[ $? -ne 0 ]]; then | ||
echo "Merge failed for branch $branch" | ||
exit 1 | ||
fi | ||
git commit -m "$1" | ||
fi | ||
done | ||
|
||
git checkout main |