Skip to content

Commit

Permalink
feat: Add pre-commit (#939)
Browse files Browse the repository at this point in the history
* feat: add pre-commit

* copyright fixes

* feat: pre-commit CI

* ignore copyright

* fix: dont fail on pre-commit ci

* add contributing docs
  • Loading branch information
tomadamatkinson authored Feb 27, 2024
1 parent dc50ad6 commit 4353c55
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions .copyrightignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ khrplatform.h
clang_format.py
run-clang-tidy.py
package-list.txt
.pre-commit-config.yaml
9 changes: 9 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,12 @@ jobs:
- run: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Bbuild/clang
- run: |
/usr/bin/run-clang-tidy -j $(($(nproc)/2+1)) -p build/clang -header-filter=framework,samples,app -checks=-*,google-*,-google-runtime-references -quiet ${{ needs.changed-files.outputs.all }}
pre-commit:
name: Pre-Commit Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
continue-on-error: true # we currently don't track pre-commit warnings as errors. in the future this will change. for this step to pass we will need to run `pre-commit run --all-files`
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v15.0.7'
hooks:
- id: clang-format
'types_or': [c++, c]
22 changes: 22 additions & 0 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ If you have a sample that demonstrates Vulkan like any of the above points, then
Before you start, check out the requirements and guidelines below.
Following these guidelines can help ensure that your contribution ends up being approved by reviewers and most importantly becomes a valuable addition to the Vulkan Samples repository.

== Quality Checks

Vulkan Samples has a range of quality checks to ensure that we maintain a consistent quality and style across all samples. These include formatting, linting and copyright checks.

To make this process as painless for contributors as possible we use xref:https://pre-commit.com/[pre-commit]. To install pre-commit and the hooks for this repository, run the following commands:

----
pip install pre-commit
pre-commit install
----

If you prefer not to use pre-commit, you can run the checks manually using the following commands:

----
# Run clang-format
./scripts/clang_format.py main
# Run copyright checks
./scripts/copyright.py main --fix
----

Future tooling may be added in the future. If you have any suggestions or feedback, please open an issue on the repository.

== Repository Structure

|===
Expand Down
4 changes: 2 additions & 2 deletions components/unix/include/unix/context.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Thomas Atkinson
/* Copyright (c) 2023-2024, Thomas Atkinson
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -34,4 +34,4 @@ class UnixPlatformContext final : public PlatformContext
UnixPlatformContext(int argc, char **argv);
~UnixPlatformContext() override = default;
};
} // namespace vkb
} // namespace vkb

0 comments on commit 4353c55

Please sign in to comment.