Skip to content

scripts/build: add a python script for checking style rules #10

scripts/build: add a python script for checking style rules

scripts/build: add a python script for checking style rules #10

Workflow file for this run

name: Style Check
on:
pull_request:
paths:
- ".github/workflows/**"
- "src/**.cpp"
- "src/**.h"
jobs:
stylecheck:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Run style check
id: style-check
run: echo "reviews=$(python3 scripts/build/style.py --base-sha ${{ github.event.pull_request.base.sha }} | jq -s -c .)" >> $GITHUB_OUTPUT
- name: Post review
uses: actions/github-script@v8
id: post-comments
env:
COMMENTS: ${{ steps.style-check.outputs.reviews }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const reviews = JSON.parse(process.env.COMMENTS || "[]");
const comments = reviews.map(r => ({
path: r.path,
line: r.line,
side: "RIGHT",
body: r.body
}));
if (comments.length > 0) {
console.debug("Reviews: ", reviews);
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
event: "COMMENT",
comments,
});
} else {
console.info("Review list empty.");
}
if (comments.length > 50) {
console.error("More than 50 comments");
}