diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..c618a9fd130 --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +AllowShortFunctionsOnASingleLine: Empty +DerivePointerAlignment: false +PointerAlignment: Left +ReflowComments: true diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 00000000000..e657d21796b --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,73 @@ +name: "Pre-commit Format & Lint" +on: + pull_request: + branches: + - develop + - staging + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + + - name: Checkout code (initial) + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + sparse-checkout: .github + sparse-checkout-cone-mode: true + token: ${{ secrets.ROCM_SV_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pydantic requests pre-commit + sudo apt-get update + sudo apt-get install -y clang-format + + - name: Configure Git + run: | + git config user.name "assistant-librarian[bot]" + git config user.email "assistant-librarian[bot]@users.noreply.github.com" + + - name: Detect changed subtrees + id: detect + env: + GH_TOKEN: ${{ secrets.ROCM_SV_TOKEN }} + run: | + python .github/scripts/pr_detect_changed_subtrees.py \ + --repo "${{ github.repository }}" \ + --pr "${{ github.event.pull_request.number }}" \ + --config ".github/repos-config.json" \ + --require-fanout + + - name: Checkout full repo with changed subtrees + if: steps.detect.outputs.subtrees + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + sparse-checkout: | + .github + ${{ steps.detect.outputs.subtrees }} + fetch-depth: 0 + token: ${{ secrets.ROCM_SV_TOKEN }} + + - name: Get list of changed files + id: changed-files + uses: tj-actions/changed-files@v34 + + - name: Run pre-commit hooks + run: | + CHANGED="${{ steps.changed-files.outputs.all_modified_files }}" + if [ -z "$CHANGED" ]; then + echo "No files changed, skipping pre-commit." + exit 0 + fi + echo "Running pre-commit on these files:" + echo "$CHANGED" + pre-commit run --files $CHANGED --show-diff-on-failure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..f8c37b93ad8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +exclude: | + third_party/ + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + language_version: python3 + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.4 + hooks: + - id: clang-format + name: clang-format (C/C++/ObjC) + entry: clang-format -i -style=file + files: '\.(c|cpp|cc|h|hpp|m|mm)$' diff --git a/projects/hipcub/hipcub/include/hipcub/tuple.hpp b/projects/hipcub/hipcub/include/hipcub/tuple.hpp index 2cacf99ee9d..65a125a18c6 100644 --- a/projects/hipcub/hipcub/include/hipcub/tuple.hpp +++ b/projects/hipcub/hipcub/include/hipcub/tuple.hpp @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef HIPCUB_TUPLE_HPP_ +#ifndef HIPCUB_TUPLE_HPP_ #define HIPCUB_TUPLE_HPP_ #include "config.hpp"