feat: added c and cpp setup actions and added to format

This commit is contained in:
Ceferino Patino 2025-07-24 21:02:05 -05:00
commit b825911353
Signed by: c4patino
SSH key fingerprint: SHA256:Wu+cU1t+7zVT9wzew/4meNmeulo66NzMqc22MdDBgXI
4 changed files with 56 additions and 0 deletions

11
.github/actions/setup-c/action.yml vendored Normal file
View file

@ -0,0 +1,11 @@
name: Setup C++ Development Environment
description: Install and configure clang-format and other C++ tools
runs:
using: composite
steps:
- name: Install clang-format
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y clang-format

11
.github/actions/setup-cpp/action.yml vendored Normal file
View file

@ -0,0 +1,11 @@
name: Setup C++ Development Environment
description: Install and configure clang-format and other C++ tools
runs:
using: composite
steps:
- name: Install clang-format
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y clang-format

View file

@ -66,6 +66,20 @@ jobs:
"rust")
(cd "$TARGET_DIR" && cargo fmt --all)
;;
"cpp")
if find "$TARGET_DIR" -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/extern/*" | grep -q .; then
find "$TARGET_DIR" -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/extern/*" -exec clang-format -i --style=file {} \;
else
echo "No C++ files found in $TARGET_DIR. Skipping clang-format."
fi
;;
"c")
if find "$TARGET_DIR" -type f \( -name "*.c" -o -name "*.h" \) -not -path "*/extern/*" | grep -q .; then
find "$TARGET_DIR" -type f \( -name "*.c" -o -name "*.h" \) -not -path "*/extern/*" -exec clang-format -i --style=file {} \;
else
echo "No C files found in $TARGET_DIR. Skipping clang-format."
fi
;;
*)
echo "unsupported language: ${{ inputs.language }}"
exit 1

View file

@ -32,6 +32,12 @@ jobs:
- name: set up csharp
if: inputs.language == 'csharp'
uses: c4patino/actions/.github/actions/setup-csharp@main
- name: set up c
if: inputs.language == 'c'
uses: c4patino/actions/.github/actions/setup-c@main
- name: set up cpp
if: inputs.language == 'cpp'
uses: c4patino/actions/.github/actions/setup-cpp@main
- name: set up go
if: inputs.language == 'go'
uses: c4patino/actions/.github/actions/setup-go@main
@ -94,6 +100,20 @@ jobs:
"rust")
(cd "$TARGET_DIR" && cargo fmt --all)
;;
"cpp")
if find "$TARGET_DIR" -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/extern/*" | grep -q .; then
find "$TARGET_DIR" -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/extern/*" -exec clang-format -i --style=file {} \;
else
echo "No C++ files found in $TARGET_DIR. Skipping clang-format."
fi
;;
"c")
if find "$TARGET_DIR" -type f \( -name "*.c" -o -name "*.h" \) -not -path "*/extern/*" | grep -q .; then
find "$TARGET_DIR" -type f \( -name "*.c" -o -name "*.h" \) -not -path "*/extern/*" -exec clang-format -i --style=file {} \;
else
echo "No C files found in $TARGET_DIR. Skipping clang-format."
fi
;;
*)
echo "unsupported language: ${{ inputs.language }}"
exit 1