Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions .github/workflows/auto-assign-reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Date Author Notes
# 2025-01-21 kurisaW Initial version
# 2025-03-14 hydevcode
# 2025-05-10 kurisaW Fixed file existence, cache, and comment time issues

# Script Function Description: Assign PR reviews based on the MAINTAINERS list.

Expand Down Expand Up @@ -50,6 +51,10 @@ jobs:
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.extract-pr.outputs.PR_NUMBER }}/comments" | \
jq -r '.[] | select(.user.login == "github-actions[bot]") | {body: .body} | @base64')

echo "=== Changed Files ==="
cat changed_files.txt
echo "====================="

comment_body=""
if [[ ! -z "$existing_comment" ]]; then
comment_body=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .body|sed -nE 's/.*Last Updated: ([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2} UTC).*/\1/p')
Expand All @@ -63,6 +68,8 @@ jobs:
echo "COMMENT_TIME=${comment_time}" >> $GITHUB_OUTPUT
fi
echo "COMMENT_TIME=${comment_time}"


- name: Parse MAINTAINERS file
id: parse_maintainer
run: |
Expand All @@ -72,8 +79,10 @@ jobs:
/^tag:/ {
tag = substr($0, index($0, $2)) # 提取标签内容
}
/^path:/ {
path = substr($0, index($0, $2)) # 提取路径内容
/^path:/ {
# 提取 path 字段并去除前后空格
path = substr($0, index($0, $2))
gsub(/^[ \t]+|[ \t]+$/, "", path) # 清理前后空格和制表符
}
/^owners:/ {
owners = substr($0, index($0, $2)) # 提取维护者信息
Expand All @@ -85,21 +94,35 @@ jobs:
print tag "|" path "|" github_ids
}
' MAINTAINERS > tag_data.csv

- name: Generate reviewers list
id: generate_reviewers
run: |
# 根据变更文件路径匹配维护者规则
rm -f triggered_reviewers.txt
rm -f triggered_tags.txt
rm -f triggered_reviewers.txt triggered_tags.txt unique_reviewers.txt unique_tags.txt
touch triggered_reviewers.txt triggered_tags.txt unique_reviewers.txt unique_tags.txt

while IFS='|' read -r tag path reviewers; do
# 使用正则匹配路径(支持子目录)
if grep -qE "^$path(/|$)" changed_files.txt; then
echo "$reviewers" | tr ' ' '\n' >> triggered_reviewers.txt
echo "$tag" | tr ' ' '\n' >> triggered_tags.txt
# 转义路径中的正则特殊字符
escaped_path=$(sed 's/[.[\*^$]/\\&/g' <<< "$path")

# 使用增强型正则匹配路径及其所有子目录
if grep -qE "^$escaped_path(/.*)*" changed_files.txt; then
echo "$reviewers" | tr -s ' ' '\n' | sed '/^$/d' >> triggered_reviewers.txt
echo "$tag" >> triggered_tags.txt
echo "Matched: $path → $tag"
fi
done < tag_data.csv
awk 'NF && !seen[$0]++' triggered_reviewers.txt > unique_reviewers.txt
awk 'NF && !seen[$0]++' triggered_tags.txt > unique_tags.txt

# 从 triggered_reviewers.txt 生成 unique_reviewers.txt(去重)
sort triggered_reviewers.txt | uniq > unique_reviewers.txt
# 从 triggered_tags.txt 生成 unique_tags.txt(去重)
sort triggered_tags.txt | uniq > unique_tags.txt

echo "=== Matched Paths ==="
cat unique_tags.txt
echo "=== Matched Reviewers ==="
cat unique_reviewers.txt

- name: Restore Reviewers Cache
id: reviewers-cache-restore
if: ${{ steps.changed_files.outputs.COMMENT_TIME != '' }}
Expand All @@ -113,12 +136,20 @@ jobs:
id: get_approval
run: |
current_time=$(date -u +"%Y-%m-%d %H:%M UTC")

# 检查 unique_reviewers.txt 是否存在
if [[ ! -f unique_reviewers.txt ]]; then
echo "Error: unique_reviewers.txt not found. Skipping approval status generation."
echo "CURRENT_TIME=${current_time}" >> $GITHUB_OUTPUT
exit 0
fi

reviewers=$(cat unique_reviewers.txt | tr '\n' '|')

# 获取 PR 的所有评论
comments=$(curl -s \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.extract-pr.outputs.PR_NUMBER }}/comments")

echo '#!/bin/bash' > approval_data.sh
echo 'declare -A approvals=()' >> approval_data.sh

Expand All @@ -136,7 +167,7 @@ jobs:
# 加载审查数据并生成状态报告
chmod +x approval_data.sh
source ./approval_data.sh

jq -r --arg reviewers "$reviewers" '
.[] |
select(.user.login != "github-actions[bot]") | # 排除 bot 的评论
Expand All @@ -146,30 +177,29 @@ jobs:
select($mention | inside($reviewers)) | # 过滤有效审查者
"\($mention) \(.created_at)" # 输出审查者和时间
' <<< "$comments" >> approval_data.txt

notified_users=""
if [[ -f unique_reviewers_bak.txt ]]; then
notified_users=$(cat unique_reviewers_bak.txt | xargs)
else
notified_users=""
fi

{
echo "---"
echo "### 📊 Current Review Status (Last Updated: $current_time)"
while read -r reviewer; do
formatted_reviewers=""
for r in $reviewers; do
if [[ " ${notified_users[@]} " =~ " $reviewer " ]]; then
formatted_reviewers+="${reviewer#@}"
formatted_reviewers+="${reviewer#@}"
else
formatted_reviewers+="$reviewer"
formatted_reviewers+="$reviewer"
fi
done

if [[ -n "${approvals[$reviewer]}" ]]; then
timestamp=$(date -d "${approvals[$reviewer]}" -u +"%Y-%m-%d %H:%M UTC")

echo "- ✅ **$formatted_reviewers** Reviewed On $timestamp"
else
echo "- ⌛ **$formatted_reviewers** Pending Review"
Expand All @@ -178,6 +208,7 @@ jobs:
} > review_status.md

echo "CURRENT_TIME=${current_time}" >> $GITHUB_OUTPUT

- name: Generate review data
id: generate_review
run: |
Expand Down Expand Up @@ -289,4 +320,4 @@ jobs:
path: |
unique_tags_bak.txt
unique_reviewers_bak.txt
key: ${{ runner.os }}-auto-assign-reviewers-${{ steps.extract-pr.outputs.PR_NUMBER }}-${{ steps.get_comment_time.outputs.CURRENT_TIME }}
key: ${{ runner.os }}-auto-assign-reviewers-${{ steps.extract-pr.outputs.PR_NUMBER }}-${{ steps.get_comment_time.outputs.CURRENT_TIME }}
6 changes: 5 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ path: .github
owners: supper thomas(supperthomas)<78900636@qq.com>, Bingru Zhang(Rbb666)<751061401@qq.com>, Yuqiang Wang(kurisaW)<2053731441@qq.com>

tag: stm32f407-rt-spark
path: bsp/stm32/stm32f407-rt-spark
path: bsp/stm32/stm32f407-rt-spark
owners: Bingru Zhang(Rbb666)<751061401@qq.com>, Yuqiang Wang(kurisaW)<2053731441@qq.com>

tag: renesas
path: bsp/renesas
owners: Yuqiang Wang(kurisaW)<2053731441@qq.com>

tag: libc
path: components/libc
owners: Meco Jianting Man(mysterywolf)<920369182@qq.com>
1 change: 1 addition & 0 deletions bsp/renesas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RA 系列 BSP 目前支持情况如下表所示:
| **RZ 系列** | |
| [rzt2m_rsk](rzt2m_rsk) | Renesas 官方 RSK-RZT2M 开发板 |
| [rzn2l_rsk](rzn2l_rsk) | Renesas 官方 RSK-RZN2L 开发板 |
| [rzn2l_etherkit](rzn2l_etherkit) | Renesas 联合 RT-Thread rzn2l_etherkit 开发板 |

可以通过阅读相应 BSP 下的 README 来快速上手,如果想要使用 BSP 更多功能可参考 docs 文件夹下提供的说明文档,如下表所示:

Expand Down
141 changes: 0 additions & 141 deletions bsp/renesas/ra6m3-hmi-board/buildinfo.gpdsc

This file was deleted.

2 changes: 1 addition & 1 deletion bsp/stm32/stm32f407-rt-spark/applications/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, RT-Thread Development Team
* Copyright (c) 2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down
2 changes: 1 addition & 1 deletion bsp/stm32/stm32f407-rt-spark/board/board.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, RT-Thread Development Team
* Copyright (c) 2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down
1 change: 0 additions & 1 deletion bsp/stm32/stm32f407-rt-spark/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'

elif PLATFORM == 'iccarm':
# toolchains
CC = 'iccarm'
CXX = 'iccarm'
AS = 'iasmarm'
Expand Down