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

Add pre-commit #2549

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI uses clang-format-16:

wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
sudo apt-get update && sudo apt-get install -y --no-install-recommends clang-format-16

hooks:
- id: clang-format
- repo: https://github.com/google/yapf
rev: v0.43.0
hooks:
- id: yapf-diff
5 changes: 5 additions & 0 deletions Developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ for Python. The CUDA-Q internals on the other hand follow the [MLIR/LLVM style
guide][llvm_style]. Please ensure that your code includes comprehensive doc
comments as well as a comment at the top of the file to indicating its purpose.

`pre-commit` is being test-flown in this repository. If you have the tool
installed or are using the provided container, run `pre-commit install` to
enable the hooks. `clang-format` and `yapf` will be automatically run on all
staged changes.

[python_style]: https://google.github.io/styleguide/pyguide.html
[cpp_style]: https://www.gnu.org/prep/standards/standards.html
[llvm_style]: https://llvm.org/docs/CodingStandards.html
Expand Down
11 changes: 8 additions & 3 deletions docker/build/cudaq.dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# Build from the repo root with
# docker build -t nvidia/cuda-quantum-dev:latest -f docker/build/cudaq.dev.Dockerfile .
#
# If a custom base image is used, then that image (i.e. the build environment) must
# If a custom base image is used, then that image (i.e. the build environment) must
# 1) have all the necessary build dependendencies installed
# 2) define the LLVM_INSTALL_PREFIX environment variable indicating where the
# 2) define the LLVM_INSTALL_PREFIX environment variable indicating where the
# the LLVM binaries that CUDA-Q depends on are installed
# 3) set the CC and CXX environment variable to use the same compiler toolchain
# as the LLVM dependencies have been built with.
Expand Down Expand Up @@ -41,8 +41,13 @@ RUN if [ -n "$mpi" ]; \
fi \
fi

# Install pre-commit
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& python3 -m pip install --no-cache-dir pre-commit==4.1.0 \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Configuring a base image that contains the necessary dependencies for GPU
# accelerated components and passing a build argument
# accelerated components and passing a build argument
# install="CMAKE_BUILD_TYPE=Release CUDA_QUANTUM_VERSION=latest"
# creates a dev image that can be used as argument to docker/release/cudaq.Dockerfile
# to create the released cuda-quantum image.
Expand Down
Loading