Sunshine/.github/workflows/cpp-lint.yml

85 lines
2.3 KiB
YAML
Raw Normal View History

2022-08-07 20:26:40 -04:00
---
# This action is centrally managed in https://github.com/<organization>/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
# the above-mentioned repo.
2023-01-02 11:17:02 -05:00
# Lint c++ source files and cmake files.
2022-12-29 08:24:13 -05:00
name: C++ Lint
2022-08-07 20:26:40 -04:00
on:
pull_request:
branches: [master, nightly]
types: [opened, synchronize, reopened]
2023-01-02 11:17:02 -05:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
2022-08-07 20:26:40 -04:00
jobs:
2023-01-02 11:17:02 -05:00
clang-format:
name: Clang Format Lint
2022-08-07 20:26:40 -04:00
runs-on: ubuntu-latest
2023-01-02 11:17:02 -05:00
2022-08-07 20:26:40 -04:00
steps:
- name: Checkout
uses: actions/checkout@v3
2023-01-02 11:17:02 -05:00
- name: Find cpp files
id: cpp_files
2022-08-07 20:26:40 -04:00
run: |
2023-01-02 11:17:02 -05:00
cpp_files=$(find . -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.m" -o -iname "*.mm")
2022-08-07 20:26:40 -04:00
2023-01-02 11:17:02 -05:00
echo "found cpp files: ${cpp_files}"
2022-08-07 20:26:40 -04:00
2023-01-02 11:17:02 -05:00
# do not quote to keep this as a single line
echo cpp_files=${cpp_files} >> $GITHUB_OUTPUT
2022-08-07 20:26:40 -04:00
- name: Clang format lint
2023-01-02 11:17:02 -05:00
if: ${{ steps.cpp_files.outputs.cpp_files }}
2022-12-10 10:02:33 -05:00
uses: DoozyX/clang-format-lint-action@v0.15
2022-08-07 20:26:40 -04:00
with:
2023-01-02 11:17:02 -05:00
source: ${{ steps.cpp_files.outputs.cpp_files }}
2022-08-07 20:26:40 -04:00
extensions: 'cpp,h,m,mm'
2023-01-02 11:17:02 -05:00
clangFormatVersion: 15
2022-08-07 20:26:40 -04:00
style: file
inplace: false
- name: Upload Artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: clang-format-fixes
2023-01-02 11:17:02 -05:00
path: ${{ steps.cpp_files.outputs.cpp_files }}
2022-12-29 08:24:13 -05:00
cmake-lint:
name: CMake Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools cmakelang
- name: Find cmake files
id: cmake_files
run: |
cmake_files=$(find . -type f -iname "CMakeLists.txt" -o -iname "*.cmake")
echo "found cmake files: ${cmake_files}"
# do not quote to keep this as a single line
echo cmake_files=${cmake_files} >> $GITHUB_OUTPUT
- name: Test with cmake-lint
run: |
cmake-lint --line-width 120 --tab-size 4 ${{ steps.cmake_files.outputs.cmake_files }}