From 9b6d603cfd00fdde0a48004acdac0b01ea98a622 Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Tue, 5 Nov 2024 09:56:34 -0500 Subject: [PATCH] Add GitHub Actions workflows for build and Clang format checks --- .github/workflows/build.yaml | 51 +++++++++++++++++++++++ .github/workflows/clang-format-check.yaml | 21 ++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/clang-format-check.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..72aba9e --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,51 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + check-format: + name: Check Formatting 🔍 + uses: ./.github/workflows/clang-format-check.yaml + permissions: + contents: read + + build: + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + build_type: [Release, Debug] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up CMake + uses: jwlawson/actions-setup-cmake@v2 + + - name: Set up dependencies + run: | + if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then + sudo apt-get update + sudo apt-get install -y cmake g++ wget + elif [ "${{ matrix.os }}" == "macos-latest" ]; then + brew update + brew install cmake + elif [ "${{ matrix.os }}" == "windows-latest" ]; then + choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' + fi + + - name: Configure CMake + run: cmake -B build -S . -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Install + run: cmake --install build --prefix dist \ No newline at end of file diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml new file mode 100644 index 0000000..6cd76ee --- /dev/null +++ b/.github/workflows/clang-format-check.yaml @@ -0,0 +1,21 @@ +name: Clang Format Check + +on: + workflow_call: + +jobs: + clang-format-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Clang + run: sudo apt-get install -y clang-format + + - name: Run Clang Format + run: | + clang-format --version + find ./src -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i + git diff --exit-code \ No newline at end of file