Skip to content

Commit

Permalink
Merge branch '311111111' into 311111111
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiYou-TW authored Mar 13, 2024
2 parents 971f2f9 + b62837d commit c34392c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
const title = pr.data.title;
const labRegex = /\[LAB(\d+)\]/;
const titleRegex = /^\[LAB\d+\] [\da-zA-Z]+$/;
const titleRegex = /^\[LAB\d+\] [a-zA-Z]?\d+$/;
if (!titleRegex.test(title)) {
core.setFailed('PR title does not match the required format. Please use the format [LAB#] student#.');
Expand Down Expand Up @@ -49,12 +49,33 @@ jobs:
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
const body = pr.data.body;
const checkboxes = body.match(/\- \[[x ]\]/g);
const checkboxes = body.match(/^ ?(-|\*) \[[x ]\]/gi);
if (!checkboxes || checkboxes.length !== 5) {
core.setFailed('The PR description must contain exactly 5 checkboxes.');
}
const unchecked = body.match(/\- \[ \]/g);
const unchecked = body.match(/^ ?(-|\*) \[ \]/g);
if (unchecked && unchecked.length > 0) {
core.setFailed(`There are ${unchecked.length} unchecked items in the PR description.`);
}
changed-files-check:
runs-on: ubuntu-latest
steps:
- name: Check no changes other than specific files
uses: actions/github-script@v5
with:
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 files = await github.rest.pulls.listFiles({ owner, repo, pull_number: issue_number });
const changedFiles = files.data.map((file) => file.filename);
echo changedFiles;
const allowedFiles = [
'lab1/main_test.js',
'lab2/main_test.js',
];
if (!changedFiles.every((file) => allowedFiles.includes(file))) {
core.setFailed('The PR contains changes to files other than the allowed files.');
}
7 changes: 3 additions & 4 deletions .github/workflows/lab1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: dependency (ubuntu)
run: |
curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
- uses: actions/setup-node@v4
with:
node-version: latest
- name: grading
run: |
cd lab1
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/lab2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: dependency (ubuntu)
run: |
curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
- uses: actions/setup-node@v4
with:
node-version: latest
- name: grading
run: |
cd lab2
Expand Down
8 changes: 6 additions & 2 deletions lab2/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class MailSystem {
send(name, context) {
console.log('--send mail to ' + name + '--');
// Interact with mail system and send mail
sleep(1000);
// random success or failure
const success = Math.random() > 0.5;
if (success) {
Expand Down Expand Up @@ -74,4 +73,9 @@ class Application {
// app.selectNextPerson();
// app.selectNextPerson();
// app.selectNextPerson();
// app.notifySelected();
// app.notifySelected();

module.exports = {
Application,
MailSystem,
};
8 changes: 1 addition & 7 deletions scripts/rebase-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@ for branch in $(git branch -r | grep -v HEAD); do
echo "Checkout failed for branch $branch"
exit 1
fi
git pull origin "$branch"
if [[ $? -ne 0 ]]; then
echo "Pull failed for branch $branch"
exit 1
fi
git rebase main
if [[ $? -ne 0 ]]; then
echo "Rebase failed for branch $branch"
exit 1
fi
git push origin "$branch"
fi
done

git checkout main
git checkout main

0 comments on commit c34392c

Please sign in to comment.