Skip to content
Merged
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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ BreakInheritanceList: BeforeComma
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Left
SpaceAfterTemplateKeyword: false
IndentRequires: false
38 changes: 38 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Clang-Format Workflow

on:
push:
branches: '**'
pull_request:

env:
LLVM_VERSION: 18

jobs:
format:
name: Check the formatting
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Pin to a specific version
run: |
$latestChocoVersion = (Resolve-ChocoPackageVersion -PackageName "llvm" -TargetVersion $env:LLVM_VERSION)
Install-ChocoPackage -PackageName llvm -ArgumentList '--allow-downgrade', '--version', $latestChocoVersion

- name: Run clang-format
env:
RED4EXT_COMMIT_BEFORE: ${{ github.event.pull_request.base.sha || github.event.before }}
RED4EXT_COMMIT_AFTER: ${{ github.sha }}
run: |
git `
-c core.autocrlf=false `
-c core.eol=lf `
-c color.ui=always `
clang-format `
--style file `
--diff $env:RED4EXT_COMMIT_BEFORE $env:RED4EXT_COMMIT_AFTER `
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: (^vendor/|(stdafx\.hpp|Resource\.(rc|hpp))$)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ The project is using [C++20](https://en.cppreference.com/w/cpp/20), any C++20 fe
### General

* Use [EditorConfig](https://editorconfig.org/) and [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to style your code before pushing.
* Ideally, set up pre-commit hook using [pre-commit](https://pre-commit.com).
All that should be required to set it up is to have [Python 3.x](https://www.python.org/) with [pip](https://pypi.org/project/pip/) installed and run the following command inside of the cloned repository folder: `pip install pre-commit && pre-commit install`
* Note that first commit after setting up the hook will take longer as it has to download required packages.
* You don't have to run it every single time there is some update, hook is auto-updated after initial installation.
* Use names that describe the purpose or intent of the object. Names should be self-explanatory and easily recognizable in the context.
* Minimize the use of abbreviations that would likely be unknown to someone outside of the project.
* Use `auto` whenever it is possible, if the intended type is the correct one (in case of primitive types).
Expand Down