Skip to content

Commit

Permalink
Fixes 2024 partea 3 (#24)
Browse files Browse the repository at this point in the history
* Modificări cache, sincronizare cu sfml

* Dezactivează ASan pe macOS

* Actualizează etichete
  • Loading branch information
mcmarius committed Oct 2, 2024
1 parent fe5ebb6 commit 8122ce9
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/actions/clang-tidy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
shell: bash
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends clang-tidy-${{ env.CLANG_VER }} libc++-${{ env.CLANG_VER }}-dev libc++abi-${{ env.CLANG_VER }}-dev
sudo apt-get install --no-install-recommends clang-tidy-${{ env.CLANG_VER }} libc++-${{ env.CLANG_VER }}-dev libc++abi-${{ env.CLANG_VER }}-dev ninja-build
- name: Configure CMake
uses: ./.github/actions/configure-cmake
Expand Down
10 changes: 5 additions & 5 deletions .github/actions/configure-cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
# with:
# path: |
# ${{ env.BUILD_DIR }}/_deps
# key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ env.CXX }}-${{ env.BUILD_TYPE }}
# key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }}

# NOTE: GH Actions does not allow updating the cache yet
# Using the workaround found here: https://github.com/actions/cache/issues/171
Expand All @@ -33,8 +33,8 @@ runs:
path: |
${{ env.BUILD_DIR }}/.ninja_deps
${{ env.BUILD_DIR }}/.ninja_log
key: ${{ matrix.os }}-${{ matrix.cxx }}-ninja-cache-${{ hashFiles('CMakeLists.txt') }}
restore-keys: ${{ matrix.os }}-${{ matrix.cxx }}-ninja-cache-
key: ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-ninja-cache-${{ hashFiles('CMakeLists.txt') }}
restore-keys: ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-ninja-cache-

- name: Cache MinGW
uses: actions/cache@v4
Expand Down Expand Up @@ -68,7 +68,7 @@ runs:
bash ./scripts/cmake.sh configure -s ${GITHUB_WORKSPACE} -b ${{ env.BUILD_DIR }} \
-t ${{ env.BUILD_TYPE }} \
-i ${GITHUB_WORKSPACE}/artifacts \
-c "-DWARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}"
-c "-DPROJECT_WARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}"
- name: Configure CMake
shell: bash
Expand All @@ -78,7 +78,7 @@ runs:
bash ./scripts/cmake.sh configure -s ${GITHUB_WORKSPACE} -b ${{ env.BUILD_DIR }} \
-t ${{ env.BUILD_TYPE }} \
-i ${GITHUB_WORKSPACE}/artifacts \
-c "-DWARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}"
-c "-DPROJECT_WARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}"
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
# https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/36-local-action.yml
9 changes: 8 additions & 1 deletion .github/actions/cppcheck/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: "composite"
steps:
- name: Cache cppcheck
uses: actions/cache@v4
uses: actions/cache/restore@v4
id: cache-cppcheck
with:
path: cppcheck
Expand All @@ -17,6 +17,13 @@ runs:
run: |
bash ./scripts/build_cppcheck.sh -v ${CPPCHECK_VER}
- name: Save cppcheck cache
uses: actions/cache/save@v4
if: steps.cache-cppcheck.outputs.cache-hit != 'true'
with:
path: cppcheck
key: cppcheck-${{ env.CPPCHECK_VER }}

- name: Install cppcheck
shell: bash
# this step is fast, no need for caching
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/process-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ runs:
- name: Copy missing dylibs
shell: bash
if: runner.os == 'macOS' && matrix.cxx == 'clang++'
# FIXME: temp disable asan for macOS due to github issues
run: |
if [[ "${BUILD_TYPE}" =~ "Deb" ]]; then
mkdir lib
cp /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib lib
install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# cp /Library/Developer/CommandLineTools/usr/lib/clang/16/lib/darwin/libclang_rt.asan_osx_dynamic.dylib lib
# install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
mv lib ${{ env.ZIP_NAME }}/
fi
Expand Down
11 changes: 9 additions & 2 deletions .github/actions/runtime-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: 'Run dynamic analysis tools'
runs:
using: "composite"
steps:
- name: Cache tools
uses: actions/cache@v4
- name: Cache restore tools
uses: actions/cache/restore@v4
if: runner.os == 'Linux' && matrix.runs_msan == true
id: cache-tools
with:
Expand Down Expand Up @@ -34,6 +34,13 @@ runs:
-DCMAKE_BUILD_WITH_INSTALL_RPATH=true
cmake --build build -j6 -- cxx cxxabi
- name: Cache save tools
uses: actions/cache/save@v4
if: runner.os == 'Linux' && matrix.runs_msan == true && steps.cache-tools.outputs.cache-hit != 'true'
with:
path: tools
key: tools-clang-${{ matrix.clang_ver }}-stdlib-msan

- name: Sanitizers
shell: bash
# run one sanitizer for each env to avoid building extra binaries on one env
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ defaults:
jobs:
cppcheck:
name: "Cppcheck"
# concurrency:
# group: "Cppcheck"
runs-on: ubuntu-22.04
timeout-minutes: 5
env:
Expand All @@ -54,6 +56,8 @@ jobs:

clang-tidy:
name: "Clang-Tidy"
# concurrency:
# group: "Clang-Tidy"
runs-on: ubuntu-22.04
timeout-minutes: 5
env:
Expand All @@ -68,6 +72,8 @@ jobs:

build:
name: ${{ matrix.name }}
# concurrency:
# group: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 8
permissions:
Expand Down Expand Up @@ -128,11 +134,11 @@ jobs:
- os: macos-14
c: clang
cxx: clang++
name: "ASan: macOS 14 Apple Clang 15"
cmake_flags: "-DUSE_ASAN=ON"
name: "macOS 14 Apple Clang 15"
cmake_flags: "-DUSE_ASAN=OFF"
# cmake_generator:
# This env runs address sanitizers
runs_asan: true
runs_asan: false

- os: macos-14
c: gcc-13
Expand All @@ -144,7 +150,7 @@ jobs:
- os: windows-2022
c: cl
cxx: cl
name: "ASan: Windows 2022 MSVC 19.40"
name: "ASan: Windows 2022 MSVC 19.41"
cmake_flags: "-DUSE_ASAN=ON"
# Ninja is not faster on MSVC because... MSVC
# cmake_generator: "Ninja"
Expand Down Expand Up @@ -184,12 +190,13 @@ jobs:
warnings_as_errors: 'ON'

- name: Build
run: bash ./scripts/cmake.sh build
run: |
bash ./scripts/cmake.sh build -t ${{ env.BUILD_TYPE }}
- name: Install
# Use CMake to "install" build artifacts (only interested in CMake registered targets) to our custom artifacts directory
run: |
bash ./scripts/cmake.sh install -i artifacts
bash ./scripts/cmake.sh install -i artifacts -t ${{ env.BUILD_TYPE }}
- name: Move artifacts
run: |
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.26)
# NOTE: update executable name in .github/workflows/cmake.yml:25 when changing executable name in this file
# for now, the project name is used as the executable name
project(oop)
# set(CMAKE_PROJECT_VERSION_MAJOR 0)
# set(CMAKE_PROJECT_VERSION_MINOR 0)
# set(CMAKE_PROJECT_VERSION_PATCH 1)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -15,6 +18,9 @@ include(cmake/Options.cmake)
# external dependencies with FetchContent
# include(FetchContent)
#
# set(FETCHCONTENT_QUIET OFF)
# set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
#
# NOTE: Also update env vars used for caching in
# - .github/actions/configure-cmake/action.yml
# - .github/workflows/cmake.yml
Expand All @@ -36,8 +42,10 @@ include(cmake/Options.cmake)
###############################################################################

# NOTE: update executable name in .github/workflows/cmake.yml:25 when changing name here
add_executable(${PROJECT_NAME} main.cpp
generated/src/Helper.cpp)
add_executable(${PROJECT_NAME}
main.cpp
generated/src/Helper.cpp
)

include(cmake/CompilerFlags.cmake)

Expand Down
2 changes: 1 addition & 1 deletion cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif()

###############################################################################

if(WARNINGS_AS_ERRORS)
if(PROJECT_WARNINGS_AS_ERRORS)
set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_WARNING_AS_ERROR ON)
endif()

Expand Down
12 changes: 6 additions & 6 deletions cmake/CopyHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ function(copy_files)

# copy files to build dir
foreach(file ${ARG_FILES})
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMENT "Copying ${file}..."
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/${file} $<TARGET_FILE_DIR:${PROJECT_NAME}>)
# ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMENT "Copying ${file}..."
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/${file} $<TARGET_FILE_DIR:${PROJECT_NAME}>)
# ${CMAKE_CURRENT_BINARY_DIR})
endforeach()

# copy folders to build dir
Expand Down
Empty file modified scripts/build_cppcheck.sh
100644 → 100755
Empty file.
Empty file modified scripts/cmake.sh
100644 → 100755
Empty file.
Empty file modified scripts/run_cppcheck.sh
100644 → 100755
Empty file.

0 comments on commit 8122ce9

Please sign in to comment.