mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
C++ formatting suggestions on PRs (#3829)
This commit is contained in:
parent
3ff6b59a49
commit
5a85bd92f2
1 changed files with 29 additions and 1 deletions
30
.github/workflows/format-check.yml
vendored
30
.github/workflows/format-check.yml
vendored
|
|
@ -5,6 +5,12 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
- labeled
|
||||
- unlabeled
|
||||
branches:
|
||||
- develop
|
||||
- master
|
||||
|
|
@ -12,6 +18,9 @@ on:
|
|||
jobs:
|
||||
cpp-linter:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cpp-linter/cpp-linter-action@v2
|
||||
|
|
@ -23,10 +32,29 @@ jobs:
|
|||
files-changed-only: true
|
||||
tidy-checks: '-*'
|
||||
version: '15' # clang-format version
|
||||
format-review: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
|
||||
passive-reviews: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
|
||||
file-annotations: true
|
||||
step-summary: true
|
||||
extensions: 'cpp,h'
|
||||
|
||||
- name: Comment with suggestion instructions
|
||||
if: steps.linter.outputs.checks-failed > 0 && !contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest')
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const {owner, repo} = context.repo;
|
||||
const issue_number = context.payload.pull_request.number;
|
||||
await github.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number,
|
||||
body: "C++ formatting checks failed. Add the `cpp-format-suggest` label to this PR for inline formatting suggestions on the next run."
|
||||
});
|
||||
|
||||
- name: Failure Check
|
||||
if: steps.linter.outputs.checks-failed > 0
|
||||
run: echo "Some files failed the formatting check! See job summary and file annotations for more info" && exit 1
|
||||
run: |
|
||||
echo "Some files failed the formatting check."
|
||||
echo "See job summary and file annotations for details."
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue