Skip to content
Merged
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
34 changes: 33 additions & 1 deletion .github/workflows/zxc-code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,36 @@ jobs:
npm ci

- name: Check Code Style
run: task check
run: |
task check
mv eslint.log eslint-branch.log || true

- name: Compare warnings with target branch
if: ${{ github.event_name == 'pull_request' }}
run: |
get_warnings() {
file="$1"
if [ -f "$file" ]; then
# Use awk to find the line containing "problems" and print the token before "warnings"
awk -F'[(), ]+' '/problems/ { for(i=1;i<=NF;i++) if($i=="warnings") print $(i-1) }' "$file" | tail -n1
else
echo 0
fi
}
# Determine the PR target (base) branch
target_branch="${{ github.event.pull_request.base.ref }}"
echo "Target branch: $target_branch"
# Fetch and check out the target branch from origin
git fetch origin "$target_branch":"$target_branch"
git checkout "$target_branch"
task check
branch_warnings=$(get_warnings eslint-branch.log)
target_warnings=$(get_warnings eslint.log)
echo "Warnings on branch: $branch_warnings"
echo "Warnings on target ($target_branch): $target_warnings"
if [ "$branch_warnings" -gt "$target_warnings" ]; then
echo "✘ Warnings have increased from $target_warnings to $branch_warnings"
exit 1
else
echo "✔ Warnings have not increased"
fi
Loading