Skip to content

Commit c5d5dee

Browse files
committed
Add pre-commit
Signed-off-by: Dobri Y <[email protected]>
1 parent bd49915 commit c5d5dee

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.pre-commit-config.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- repo: https://github.com/pre-commit/mirrors-clang-format
8+
rev: v19.1.7
9+
hooks:
10+
- id: clang-format
11+
- repo: https://github.com/google/yapf
12+
rev: v0.43.0
13+
hooks:
14+
- id: yapf-diff

Developing.md

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ for Python. The CUDA-Q internals on the other hand follow the [MLIR/LLVM style
6161
guide][llvm_style]. Please ensure that your code includes comprehensive doc
6262
comments as well as a comment at the top of the file to indicating its purpose.
6363

64+
`pre-commit` is being test-flown in this repository. If you have the tool
65+
installed or are using the provided Dev container, run `pre-commit install` to
66+
enable the hooks. `clang-format` and `yapf` will be automatically run on all
67+
staged changes.
68+
6469
[python_style]: https://google.github.io/styleguide/pyguide.html
6570
[cpp_style]: https://www.gnu.org/prep/standards/standards.html
6671
[llvm_style]: https://llvm.org/docs/CodingStandards.html

docker/build/cudaq.dev.Dockerfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# Build from the repo root with
1111
# docker build -t nvidia/cuda-quantum-dev:latest -f docker/build/cudaq.dev.Dockerfile .
1212
#
13-
# If a custom base image is used, then that image (i.e. the build environment) must
13+
# If a custom base image is used, then that image (i.e. the build environment) must
1414
# 1) have all the necessary build dependendencies installed
15-
# 2) define the LLVM_INSTALL_PREFIX environment variable indicating where the
15+
# 2) define the LLVM_INSTALL_PREFIX environment variable indicating where the
1616
# the LLVM binaries that CUDA-Q depends on are installed
1717
# 3) set the CC and CXX environment variable to use the same compiler toolchain
1818
# as the LLVM dependencies have been built with.
@@ -41,8 +41,13 @@ RUN if [ -n "$mpi" ]; \
4141
fi \
4242
fi
4343

44+
# Install pre-commit
45+
RUN apt-get update && apt-get install -y --no-install-recommends git \
46+
&& python3 -m pip install --no-cache-dir pre-commit==4.1.0 \
47+
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*
48+
4449
# Configuring a base image that contains the necessary dependencies for GPU
45-
# accelerated components and passing a build argument
50+
# accelerated components and passing a build argument
4651
# install="CMAKE_BUILD_TYPE=Release CUDA_QUANTUM_VERSION=latest"
4752
# creates a dev image that can be used as argument to docker/release/cudaq.Dockerfile
4853
# to create the released cuda-quantum image.

0 commit comments

Comments
 (0)