From 5cb0feb956e67080d0b84381926ae7c7dd21ed8b Mon Sep 17 00:00:00 2001 From: Michael Tsukanov Date: Thu, 14 Nov 2024 20:33:48 +0300 Subject: [PATCH] Add CICD --- .github/workflows/ubuntu.yml | 70 +++++++++++++++++++++++++++++++++++ .github/workflows/windows.yml | 51 +++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .github/workflows/ubuntu.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..7edb27e --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,70 @@ +name: Ubuntu CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [ubuntu-24.04] + build_type: [Release, Debug] + cpp_compiler: [g++, clang++] + + steps: + - uses: actions/checkout@v3 + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + + - name: Set up cache + id: cache-cpm + uses: actions/cache@v2 + with: + path: ~/cpm-cache + key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + restore-keys: | + ${{ runner.os }}-cpm-a + + # Download GLFW dependencies + - name: Setup GLFW deps + run: | + sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources + sudo apt-get update + sudo apt-get build-dep glfw3 + + - name: Configure CMake (GCC) + if: ${{ matrix.cpp_compiler == 'g++' }} + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCPM_SOURCE_CACHE=~/cpm-cache + -DCMAKE_CXX_COMPILER=g++ + -DCMAKE_C_COMPILER=gcc + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Configure CMake (Clang) + if: ${{ matrix.cpp_compiler == 'clang++' }} + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCPM_SOURCE_CACHE=~/cpm-cache + -DCMAKE_CXX_COMPILER=clang++ + -DCMAKE_C_COMPILER=clang + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..bf58ab4 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,51 @@ +name: Windows CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [windows-latest] + build_type: [Release, Debug] + c_compiler: [cl] + + steps: + - uses: actions/checkout@v3 + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + + - name: Set up cache + id: cache-cpm + uses: actions/cache@v2 + with: + path: ~/cpm-cache + key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + restore-keys: | + ${{ runner.os }}-cpm-a + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCPM_SOURCE_CACHE=~/cpm-cache + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}