ci: tidy and format checks
This commit is contained in:
parent
0c654104d5
commit
e5b4a231fc
3 changed files with 68 additions and 21 deletions
21
.github/actions/setup-compilers/action.yml
vendored
Normal file
21
.github/actions/setup-compilers/action.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: "Setup compilers"
|
||||||
|
description: "Setup compilers and build tools"
|
||||||
|
inputs:
|
||||||
|
clang:
|
||||||
|
required: false
|
||||||
|
default: "18"
|
||||||
|
gcc:
|
||||||
|
required: false
|
||||||
|
default: "14"
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo add-apt-repository universe multiverse
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install gcc-${{ inputs.gcc }} g++-${{ inputs.gcc }}
|
||||||
|
wget https://apt.llvm.org/llvm.sh
|
||||||
|
chmod u+x llvm.sh
|
||||||
|
sudo ./llvm.sh ${{ inputs.clang }}
|
29
.github/workflows/cmake-multi-platform.yml
vendored
29
.github/workflows/cmake-multi-platform.yml
vendored
|
@ -7,6 +7,24 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
tidy:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup compilers
|
||||||
|
uses: ./.github/actions/setup-compilers
|
||||||
|
- name: Run clang tidy
|
||||||
|
run: make tidy CI=1
|
||||||
|
|
||||||
|
format:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup compilers
|
||||||
|
uses: ./.github/actions/setup-compilers
|
||||||
|
- name: Run clang format
|
||||||
|
run: make format CI=1
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
@ -35,16 +53,7 @@ jobs:
|
||||||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
|
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
|
||||||
- name: Setup compilers
|
- name: Setup compilers
|
||||||
id: compilers
|
id: compilers
|
||||||
shell: bash
|
uses: ./.github/actions/setup-compilers
|
||||||
run: |
|
|
||||||
sudo apt update
|
|
||||||
sudo add-apt-repository universe multiverse
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install gcc-14 g++-14
|
|
||||||
wget https://apt.llvm.org/llvm.sh
|
|
||||||
chmod u+x llvm.sh
|
|
||||||
sudo ./llvm.sh 18
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -1,13 +1,20 @@
|
||||||
MAKEFILE_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
MAKEFILE_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
TESTS_BIN = $(MAKEFILE_DIR)/build/cserver_tests
|
TESTS_BIN = $(MAKEFILE_DIR)/build/cserver_tests
|
||||||
|
|
||||||
|
CC = clang
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
|
|
||||||
CMAKE_CMD ?= cmake
|
CMAKE_CMD ?= cmake
|
||||||
CMAKE_BUILD_TYPE ?= Debug
|
CMAKE_BUILD_TYPE ?= Debug
|
||||||
CMAKE_GENERATOR ?= Ninja
|
|
||||||
|
ifdef CI
|
||||||
|
CMAKE_GENERATOR ?= "Unix Makefiles"
|
||||||
|
else
|
||||||
|
CMAKE_GENERATOR ?= Ninja
|
||||||
|
endif
|
||||||
|
|
||||||
CMAKE_FLAGS += -DCMAKE_CXX_COMPILER=$(CXX) \
|
CMAKE_FLAGS += -DCMAKE_CXX_COMPILER=$(CXX) \
|
||||||
|
-DCMAKE_C_COMPILER=$(CC) \
|
||||||
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
|
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
|
||||||
-DENABLE_TESTS=1 \
|
-DENABLE_TESTS=1 \
|
||||||
|
@ -28,6 +35,12 @@ else
|
||||||
BUILD_TOOL = $(MAKE)
|
BUILD_TOOL = $(MAKE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef CI
|
||||||
|
FORMAT_FLAGS = -n --Werror
|
||||||
|
else
|
||||||
|
FORMAT_FLAGS = -i
|
||||||
|
endif
|
||||||
|
|
||||||
all: $(TESTS_BIN)
|
all: $(TESTS_BIN)
|
||||||
|
|
||||||
build/.ran-cmake:
|
build/.ran-cmake:
|
||||||
|
@ -42,7 +55,7 @@ cmake:
|
||||||
$(MAKE) build/.ran-cmake
|
$(MAKE) build/.ran-cmake
|
||||||
|
|
||||||
format:
|
format:
|
||||||
clang-format -Werror -i \
|
clang-format $(FORMAT_FLAGS) \
|
||||||
$(shell find include -name *.hpp) \
|
$(shell find include -name *.hpp) \
|
||||||
$(shell find examples -name *.cpp) \
|
$(shell find examples -name *.cpp) \
|
||||||
$(shell find tests -name *.cpp)
|
$(shell find tests -name *.cpp)
|
||||||
|
@ -53,11 +66,15 @@ clean:
|
||||||
distclean:
|
distclean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
|
||||||
# Test
|
|
||||||
|
|
||||||
test: $(TESTS_BIN)
|
test: $(TESTS_BIN)
|
||||||
$(TESTS_BIN)
|
$(TESTS_BIN)
|
||||||
|
|
||||||
|
tidy: build/.ran-cmake
|
||||||
|
clang-tidy -p build \
|
||||||
|
$(shell find include -name *.hpp) \
|
||||||
|
$(shell find examples -name *.cpp) \
|
||||||
|
$(shell find tests -name *.cpp)
|
||||||
|
|
||||||
FORCE: ;
|
FORCE: ;
|
||||||
|
|
||||||
.PHONY: all cmake test format clean distclean
|
.PHONY: all cmake test format clean distclean
|
Loading…
Reference in a new issue