Skip to content

Commit 5da8e8c

Browse files
committed
style: Raise our formatting standard to clang-format 17 (#1761)
We had been using clang-format 14. Bump to 17 as our official reference standard for formatting. Moved the clang-format CI test from an aswf container to bare Ubuntu to make it run faster -- it doesn't need to do a real build, so there's no point wasting 2 minutes or so downloading a container holding library dependencies it won't need. Also fix a duplicate line in .clang-format that newer clang-format complained about. Document that it's specifically clang-format 17 that is our formatting standard Signed-off-by: Larry Gritz <[email protected]>
1 parent 9ceac10 commit 5da8e8c

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Language: Cpp
66
BasedOnStyle: WebKit
7-
SpaceBeforeParens: ControlStatements
87

98
AccessModifierOffset: -4
109
AlignAfterOpenBracket: Align

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
- [ ] I have updated the documentation, if applicable.
1919
- [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
2020
- [ ] My code follows the prevailing code style of this project. If I haven't
21-
already run clang-format before submitting, I definitely will look at the CI
22-
test that runs clang-format and fix anything that it highlights as being
23-
nonconforming.
21+
already run clang-format v17 before submitting, I definitely will look at
22+
the CI test that runs clang-format and fix anything that it highlights as
23+
being nonconforming.

.github/workflows/ci.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -217,25 +217,6 @@ jobs:
217217
# texture system adequately and is able to ignore the benign
218218
# "leaks."
219219

220-
# Test formatting. This test entry doesn't do a full build, it
221-
# just runs clang-format on everything, and passes if nothing is
222-
# misformatted. Upon failure, the build artifact will be the full
223-
# source code with the formatting fixed (diffs will also appear in
224-
# the console output).
225-
- desc: "clang-format"
226-
nametag: clang-format
227-
runner: ubuntu-latest
228-
container: aswftesting/ci-osl:2022-clang14
229-
vfxyear: 2022
230-
cxx_std: 17
231-
openimageio_ver: release
232-
python_ver: 3.9
233-
simd: avx2,f16c
234-
batched: b8_AVX2
235-
skip_tests: 1
236-
setenvs: export BUILDTARGET=clang-format
237-
OPENIMAGEIO_CMAKE_FLAGS=-DUSE_PYTHON=0
238-
239220
# Test ABI stability. `abi_check` is the version or commit that we
240221
# believe is the current standard against which we don't want to
241222
# break the ABI. Basically, we will build that version as well as
@@ -429,6 +410,27 @@ jobs:
429410
LLVM_DISTRO_NAME=ubuntu-18.04
430411
OPENCOLORIO_VERSION=v2.1.2
431412
PUGIXML_VERSION=v1.11.4
413+
# Test formatting. This test entry doesn't do a full build, it
414+
# just runs clang-format on everything, and passes if nothing is
415+
# misformatted. Upon failure, the build artifact will be the full
416+
# source code with the formatting fixed (diffs will also appear in
417+
# the console output).
418+
- desc: "clang-format"
419+
nametag: clang-format
420+
runner: ubuntu-latest
421+
container: aswftesting/ci-osl:2022-clang14
422+
cxx_std: 17
423+
extra_artifacts: "src/*.*"
424+
openimageio_ver: release
425+
python_ver: "3.10"
426+
simd: avx2,f16c
427+
batched: b8_AVX2
428+
skip_tests: 1
429+
setenvs: export BUILDTARGET=clang-format
430+
LLVM_VERSION=17.0.6
431+
LLVM_DISTRO_NAME=ubuntu-22.04
432+
OPENIMAGEIO_CMAKE_FLAGS=-DUSE_PYTHON=0
433+
QT_VERSION=0
432434

433435
runs-on: ${{matrix.runner}}
434436
env:
@@ -483,6 +485,7 @@ jobs:
483485
build/*.cmake
484486
build/CMake*
485487
build/testsuite/*/*.*
488+
${{ matrix.extra_artifacts }}
486489
487490
488491
macos:

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ own repository on GitHub, and then clone it to get a repository on your
115115
local machine.
116116

117117
2. Edit, compile, and test your changes. Run clang-format (see the
118-
instructions on coding style below).
118+
instructions on coding style below). Our current formatting standard,
119+
as checked by our CI, uses clang-format 17.0.
119120

120121
3. Push your changes to your fork (each unrelated pull request to a separate
121122
"topic branch", please).
@@ -170,14 +171,14 @@ file in which it appears.
170171

171172
#### Formatting
172173

173-
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
174+
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) v17
174175
to uniformly format our source code prior to PR submission. Make sure that
175176
clang-format is installed on your local machine, and just run
176177

177178
make clang-format
178179

179180
and it will automatically reformat your code according to the configuration
180-
file found in the `.clang-format` file at the root directory of the OIIO
181+
file found in the `.clang-format` file at the root directory of the OSL
181182
source code checkout.
182183

183184
One of the CI test matrix entries runs clang-format and fails if any

0 commit comments

Comments
 (0)