Skip to content
Open
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
20 changes: 0 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -886,25 +886,6 @@ jobs:
command: test/docsCodeStyle.sh
- matrix_notify_failure_unless_pr

chk_coding_style:
<<: *base_cimg_small
steps:
- checkout
- run:
name: Install shellcheck
command: |
sudo apt -q update
sudo apt install -y shellcheck
- run:
name: Check for C++ coding style
command: scripts/check_style.sh
- run:
name: checking shell scripts
command: scripts/chk_shellscripts/chk_shellscripts.sh
- run:
name: Check for broken symlinks
command: scripts/check_symlinks.sh
- matrix_notify_failure_unless_pr

chk_errorcodes:
<<: *base_ubuntu2404_small
Expand Down Expand Up @@ -1876,7 +1857,6 @@ workflows:
jobs:
# basic checks
- chk_spelling: *requires_nothing
- chk_coding_style: *requires_nothing
# DISABLED FOR 0.6.0 - chk_docs_examples: *requires_nothing
- chk_buglist: *requires_nothing
- chk_proofs: *requires_nothing
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Code Style Check

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
pull-requests: write
contents: read

jobs:
chk_coding_style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0

- name: Install dependencies
run: |
sudo apt -q update
sudo apt install -y shellcheck git

- name: Check for C++ coding style
id: style-check
run: |
output=$(scripts/check_style.sh 2>&1) || {
{
echo "output<<EOF"
echo "$output"
echo "EOF"
} >> $GITHUB_OUTPUT
exit 1
}

- name: Comment PR on failure
if: ${{ failure() && steps.style-check.outcome == 'failure' }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0
with:
script: |
const output = `${{ steps.style-check.outputs.output }}`;
const body = `There was an error when running \`Code Style Check\` for commit \`${context.sha}\`:
\`\`\`
${output}
\`\`\`
Please check that your changes are working as intended.`;

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});

for (const line of output.split('\n')) {
const match = line.match(/^([^:]+\.(cpp|h)):(\d+):/);
if (!match) continue;
const [, filePath, , lineNumber] = match;
await github.rest.pulls.createReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
commit_id: context.sha,
path: filePath,
line: parseInt(lineNumber),
side: 'RIGHT',
body: 'Coding style error'
});
}

- name: checking shell scripts
run: scripts/chk_shellscripts/chk_shellscripts.sh

- name: Check for broken symlinks
run: scripts/check_symlinks.sh
9 changes: 5 additions & 4 deletions scripts/check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ if [[ "$WHITESPACE" != "" ]]
then
echo "Error: Trailing whitespace found:" | tee -a "$ERROR_LOG"
echo "$WHITESPACE" | tee -a "$ERROR_LOG"
scripts/ci/post_style_errors_on_github.sh "$ERROR_LOG"
exit 1
fi

function preparedGrep
Expand Down Expand Up @@ -78,7 +76,10 @@ if [[ "$FORMATEDERRORS" != "" ]]
then
echo "Coding style error:" | tee -a "$ERROR_LOG"
echo "$FORMATEDERRORS" | tee -a "$ERROR_LOG"
scripts/ci/post_style_errors_on_github.sh "$ERROR_LOG"
exit 1
fi

if [[ -s "$ERROR_LOG" ]]
then
exit 1
fi
)