Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add pre-commit #939

Merged
merged 6 commits into from
Feb 27, 2024
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 .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]
24 changes: 23 additions & 1 deletion CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
////
- Copyright (c) 2019-2023, Arm Limited and Contributors
- Copyright (c) 2019-2024, Arm Limited and Contributors
-
- SPDX-License-Identifier: Apache-2.0
-
Expand Down 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
Loading