Skip to content

[EP] Improve low-latency kernel #1938

[EP] Improve low-latency kernel

[EP] Improve low-latency kernel #1938

name: Clang Format Check
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format 14
run: |
sudo apt-get update
sudo apt-get install -y clang-format-14
sudo ln -sf /usr/bin/clang-format-14 /usr/bin/clang-format
- name: Show clang-format version
run: clang-format --version
- name: Check C++ formatting
run: |
set -e
DIRECTORIES=("collective" "ep" "misc" "p2p" "include")
EXTENSIONS=("cpp" "cxx" "cc" "h" "hpp" "cu" "cuh")
EXCLUDE=("collective/afxdp/lib")
EXCLUDE_ARGS=()
for EXC in "${EXCLUDE[@]}"; do
EXCLUDE_ARGS+=( -path "$EXC" -prune -o )
done
FILES=()
for DIR in "${DIRECTORIES[@]}"; do
if [ -d "$DIR" ]; then
for EXT in "${EXTENSIONS[@]}"; do
while IFS= read -r -d '' FILE; do
FILES+=("$FILE")
done < <(find "$DIR" "${EXCLUDE_ARGS[@]}" -type f -name "*.${EXT}" -print0)
done
fi
done
if [ ${#FILES[@]} -eq 0 ]; then
echo "No files found to check."
exit 0
fi
echo "Checking formatting on files:"
for FILE in "${FILES[@]}"; do
echo "$FILE"
done
clang-format --dry-run --Werror "${FILES[@]}"
python-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install black
run: |
pip install black
- name: Check Python formatting
run: |
PYTHON_DIRS=("p2p" "ep")
EXCLUDES="thirdparty|docs|build"
for DIR in "${PYTHON_DIRS[@]}"; do
if [ -d "$DIR" ]; then
echo "Checking Python formatting in $DIR..."
black "$DIR" --exclude "$EXCLUDES" --check
fi
done