-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add weekly report PR check workflows #11
Merged
Ligoml
merged 2 commits into
PFCCLab:main
from
MarioLulab:luqi/add_weeklyreport_pr_check
Oct 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Weekly Report Mentor Comment Check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
check-mentor-comment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check Filenames without White Space | ||
run: | | ||
# Find all files with spaces in their names | ||
files_with_spaces=$(find . -name "* *" -type f) | ||
|
||
# If any files with spaces are found, output an error message and fail the job | ||
if [ -n "$files_with_spaces" ]; then | ||
echo "Error: The following files have spaces in their names:" | ||
echo "$files_with_spaces" | ||
exit 1 | ||
fi | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v14.6 | ||
|
||
- name: List all changed files | ||
run: | | ||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
echo "$file was changed" | ||
done | ||
|
||
- name: Check Weekly Report | ||
run: | | ||
DEFAULT_VALUE="待填写" | ||
|
||
weeklyReports=() | ||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
file_basename=$(basename $file) | ||
echo "file_basename="${file_basename} | ||
if [[ "$file_basename" =~ \[WeeklyReport\] ]]; then | ||
weeklyReports+=("$file") | ||
fi | ||
done | ||
|
||
if [ ${#weeklyReports[@]} -eq 0 ]; then | ||
echo "没有周报文件, 或周报文件不符合命名要求: ${{ steps.changed-files.outputs.all_changed_files }}" | ||
exit 0 | ||
fi | ||
|
||
# 检查文件是否包含 "### 导师点评" 字段以及该字段所在行下面的内容是否为空或者为 ${DEFAULT_VALUE} | ||
function check_tutor_review() { | ||
if grep -q "### 导师点评" "$1"; then | ||
line_number=$(grep -n "### 导师点评" "$1" | cut -d ":" -f 1) | ||
|
||
count=1 | ||
while [ $count -le 5 ] | ||
do | ||
next_line=$(($line_number + $count)) | ||
next_line_content=$(sed -n "${next_line}p" "$1" | tr -d '[:space:]') | ||
if [[ -n "$next_line_content" && "$next_line_content" != ${DEFAULT_VALUE} ]]; then | ||
return 0 | ||
fi | ||
|
||
count=$((count+1)) | ||
done | ||
|
||
echo "failed: $1 \"### 导师点评\" 字段下面${count}行内容为空" | ||
return 1 | ||
else | ||
echo "failed: $1 没有字段 \"### 导师点评\"" | ||
return 1 | ||
fi | ||
} | ||
|
||
|
||
# 检查所有文件 | ||
for file in ${weeklyReports}; do | ||
if check_tutor_review "$file"; then | ||
echo "$file 符合要求" | ||
else | ||
echo "$file 导师点评内容缺失." | ||
echo "如有疑问, 请联系助教 MarioLulab" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "所有文件都符合要求" | ||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
周报模板中的DEFAULT_VALUE好像不是"待填写"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到。我统一了以下两处的 DEFAULT_VALUE 为 "请联系导师填写" :