Skip to content

Refactor config and logging #98

Refactor config and logging

Refactor config and logging #98

Workflow file for this run

name: CMake
on:
pull_request:
branches: [ "dev" ]
paths: [ "src/**" ]
types: [ opened, synchronize, reopened, ready_for_review ]
jobs:
build:
if: ${{ github.event.pull_request.draft == false }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
build_type: [Release]
c_compiler: [gcc, clang]
include:
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Prepare environment
id: env
uses: ./.github/actions/prepare_env
- name: Load cache build directory
uses: actions/cache/restore@v3
id: restore-cache
with:
path: ${{ steps.env.outputs.build-output-dir }}
key: ${{ runner.os }}-build-${{ matrix.c_compiler }}-${{ matrix.cpp_compiler }}-${{ matrix.build_type }}-${{ hashFiles('src/engine/module/**/*', 'src/game/**/*') }}
restore-keys: ${{ runner.os }}-build-${{ matrix.c_compiler }}-${{ matrix.cpp_compiler }}-${{ matrix.build_type }}-
- name: Configure ccache
run: |
export CCACHE_DIR=${{ steps.env.outputs.ccache-output-dir }}
echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
ccache --max-size=10M --zero-stats
- name: Configure CMake
working-directory: ${{ steps.env.outputs.build-output-dir }}
run: >
cmake
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
..
- name: Build
# Build your program with the given configuration. Note that --config is needed because the
# default Windows generator is a multi-config generator (Visual Studio generator).
working-directory: ${{ steps.env.outputs.build-output-dir }}
run: cmake --build . --config ${{ matrix.build_type }} --parallel
- name: Show ccache statistics
run: |
ccache --show-stats --verbose
du -sh $CCACHE_DIR
ccache --zero-stats # Statistics are not necessary in cache artifact
- name: Cache build directory
uses: actions/cache/save@v3
with:
path: ${{ steps.env.outputs.build-output-dir }}
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
# - name: Test
# working-directory: ${{ steps.env.outputs.build-output-dir }}
# # Execute tests defined by the CMake configuration. Note that --build-config is needed
# # because the default Windows generator is a multi-config generator (Visual Studio generator).
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest --build-config ${{ matrix.build_type }}