-
Notifications
You must be signed in to change notification settings - Fork 31
37 lines (35 loc) · 1.43 KB
/
check-formatting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# GitHub action workflow that performs a source code formatting check.
#
# The workflow fails if one or more of the .hpp or .cpp files in the repository
# are not properly formatted according to the rules in the .clang-format file
# located in the root of the repository directory, using clang-format version 9.
# In that case, the log file provides a list of improperly formatted files.
# Source files with other extensions (including .h, .c, .hh, .cc) are NOT tested
# to allow for differently formatted third-party code.
#
name: Check formatting
# workflow event triggers
on: pull_request
# jobs that run
jobs:
# automatic formatting check
check_formatting_job:
# job name, displayed in the action log
name: Check source code formatting
# run this job on a Github-provided runner with Ubuntu 20.04
# (and not 22.04 because we cannot install clang-format-9)
runs-on: ubuntu-20.04
# steps that make up this job
steps:
# install clang-format-9
- name: Install
run: sudo apt install clang-format-9
# checkout using a recent version of the checkout action
- name: Checkout
uses: actions/checkout@v3
# run clang-format-9 on all .hpp and .cpp files
- name: Autoformat
run: find . \( -name '*.hpp' -or -name '*.cpp' \) -exec clang-format-9 -style=file -i {} \;
# fail the workflow if anything changed to the repository
- name: Verify
run: git diff --stat --no-ext-diff --exit-code