Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Use CMakePresets, add sanitizer build #71

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 21 additions & 63 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
- name: Format files
run: find src include -type f -a \( -name "*.cc" -o -name "*.h" \) -print0 | xargs -0 clang-format-${{ env.LLVM_VERSION }} -i

- uses: parkerbxyz/suggest-changes@v1
if: github.event_name == 'pull_request'
with:
comment: 'clang-format fixes:'

- name: Check for differences
run: |
git status --porcelain
Expand All @@ -55,60 +60,29 @@ jobs:
matrix:
config:
- name: macOS x86_64 Release
cxx: clang++
cc: clang
mode: Release
mimalloc: on
cxxflags: -stdlib=libc++
os: macos-13
preset: clang-release
artifact: macos-x86_64
- name: macOS arm64 Release
cxx: clang++
cc: clang
mode: Release
mimalloc: on
cxxflags: -stdlib=libc++
os: macos-14
preset: clang-release
artifact: macos-arm64
- name: GCC ${{ needs.env-vars.outputs.GCC_VERSION }} Release
cxx: g++-${{ needs.env-vars.outputs.GCC_VERSION }}
cc: gcc-${{ needs.env-vars.outputs.GCC_VERSION }}
mode: Release
mimalloc: on
os: ubuntu-latest
artifact: linux
preset: gcc-${{ needs.env-vars.outputs.GCC_VERSION }}-release
artifact: linux-amd64
- name: GCC ${{ needs.env-vars.outputs.GCC_VERSION }} Debug
cxx: g++-${{ needs.env-vars.outputs.GCC_VERSION }}
cc: gcc-${{ needs.env-vars.outputs.GCC_VERSION }}
mode: Debug
mimalloc: on
os: ubuntu-latest
preset: gcc-${{ needs.env-vars.outputs.GCC_VERSION }}-debug
- name: Clang ${{ needs.env-vars.outputs.LLVM_VERSION }} Release
cxx: clang++-${{ needs.env-vars.outputs.LLVM_VERSION }}
cc: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}
mode: Release
mimalloc: on
cxxflags: -stdlib=libc++
ldflags: -lc++abi
os: ubuntu-latest
preset: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}-release
- name: Clang Tidy
cxx: clang++-${{ needs.env-vars.outputs.LLVM_VERSION }}
cc: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}
mode: Release
mimalloc: on
cxxflags: -stdlib=libc++
ldflags: -lc++abi
lint: true
os: ubuntu-latest
# - key: Clang ${{ needs.env-vars.outputs.LLVM_VERSION }} Sanitizer
# cxx: clang++-${{ needs.env-vars.outputs.LLVM_VERSION }}
# cc: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}
# mode: Release
# mimalloc: on
# cflags: -fsanitize=address,undefined -fno-omit-frame-pointer
# cxxflags: -fsanitize=address,undefined -fno-omit-frame-pointer -stdlib=libc++
# ldflags: -lc++abi
# os: ubuntu-latest
preset: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}-tidy
- key: Clang ${{ needs.env-vars.outputs.LLVM_VERSION }} Sanitizer
os: ubuntu-latest
preset: clang-${{ needs.env-vars.outputs.LLVM_VERSION }}-sanitizer
env:
BUILDCACHE_COMPRESS: true
BUILDCACHE_DIRECT_MODE: true
Expand All @@ -129,7 +103,7 @@ jobs:
run: sudo apt-get update

- name: Install LLVM
if: ${{ !startsWith(matrix.config.os, 'macos-') && startsWith(matrix.config.cc, 'clang') }}
if: ${{ !startsWith(matrix.config.os, 'macos-') && startsWith(matrix.config.preset, 'clang') }}
uses: ./.github/actions/install-llvm
with:
version: ${{ env.LLVM_VERSION }}
Expand All @@ -144,23 +118,17 @@ jobs:
if: ${{ startsWith(matrix.config.os, 'macos-') }}
run: brew install ninja

- name: Install Valgrind
if: ${{ matrix.config.mode == 'Debug' && matrix.config.cc == 'gcc-${{ env.GCC_VERSION }}' }}
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt-get install -y --no-install-recommends valgrind

# ==== RESTORE CACHE ====
- name: Restore buildcache Cache
uses: actions/cache/restore@v4
id: restore-buildcache
with:
path: ${{ github.workspace }}/.buildcache
key: buildcache-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.mode }}-${{ contains(matrix.config.cxxflags, 'sanitize') }}-${{ matrix.config.lint }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }}
key: buildcache-${{ matrix.config.os }}-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }}
restore-keys: |
buildcache-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.mode }}-${{ contains(matrix.config.cxxflags, 'sanitize') }}-${{ matrix.config.lint }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-
buildcache-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.mode }}-${{ contains(matrix.config.cxxflags, 'sanitize') }}-${{ matrix.config.lint }}-${{ hashFiles('.pkg') }}-
buildcache-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.mode }}-${{ contains(matrix.config.cxxflags, 'sanitize') }}-${{ matrix.config.lint }}-
buildcache-${{ matrix.config.os }}-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-
buildcache-${{ matrix.config.os }}-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-
buildcache-${{ matrix.config.os }}-${{ matrix.config.preset }}-

- name: Restore Dependencies Cache
uses: actions/cache/restore@v4
Expand All @@ -172,17 +140,7 @@ jobs:

# ==== BUILD ====
- name: CMake
run: |
cmake \
-G Ninja -S . -B build \
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-DCMAKE_C_FLAGS="${{ matrix.config.cflags }}" \
-DCMAKE_CXX_FLAGS="${{ matrix.config.cxxflags }}" \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.config.ldflags }}" \
-DCMAKE_BUILD_TYPE=${{ matrix.config.mode }} \
-DPPR_LINT=${{ matrix.config.lint }} \
-DPPR_MIMALLOC=${{ matrix.config.mimalloc }}
run: cmake -S . -B build --preset=${{ matrix.config.preset }}

- name: Build
run: |
Expand Down
41 changes: 22 additions & 19 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ jobs:
strategy:
fail-fast: false
matrix:
mode: [ Debug, Release ]
config:
- name: Debug
preset: msvc-debug
- name: Release
preset: msvc-release
artifact: windows


env:
CXX: cl.exe
CC: cl.exe
BUILDCACHE_COMPRESS: true
BUILDCACHE_DIRECT_MODE: true
BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache
Expand All @@ -44,11 +48,11 @@ jobs:
id: restore-buildcache
with:
path: ${{ github.workspace }}/.buildcache
key: buildcache-windows-${{ matrix.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }}
key: buildcache-windows-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }}
restore-keys: |
buildcache-windows-${{ matrix.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}
buildcache-windows-${{ matrix.mode }}-${{ hashFiles('.pkg') }}-
buildcache-windows-${{ matrix.mode }}-
buildcache-windows-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}
buildcache-windows-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-
buildcache-windows-${{ matrix.config.preset }}-

- name: Restore Dependencies Cache
uses: actions/cache/restore@v4
Expand All @@ -59,14 +63,13 @@ jobs:
restore-keys: deps-

# ==== BUILD ====
- uses: ilammy/msvc-dev-cmd@v1

- name: CMake
run: cmake -S . -B build --preset=${{ matrix.config.preset }}

- name: Build
run: |
$devShell = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find **\Microsoft.VisualStudio.DevShell.dll
$installPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath
Import-Module $devShell
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments "-arch=amd64"
Get-ChildItem env:
cmake -GNinja -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DPPR_DEBUG_SYMBOLS=OFF -DPPR_MIMALLOC=ON
.\build\buildcache\bin\buildcache.exe -z
cmake --build build --target ppr-preprocess ppr-backend footrouting ppr-benchmark ppr-test
$CompilerExitCode = $LastExitCode
Expand All @@ -79,30 +82,30 @@ jobs:

# ==== DISTRIBUTION ====
- name: Create Distribution
if: matrix.mode == 'Release'
if: matrix.config.artifact != ''
run: |
mkdir dist
mv .\build\*.exe dist
mv .\build\*.dll dist
mv .\ui\web dist

- name: Upload Distribution
if: matrix.mode == 'Release'
if: matrix.config.artifact != ''
uses: actions/upload-artifact@v4
with:
name: ppr-windows
name: ppr-${{ matrix.config.artifact }}
path: dist

# ==== RELEASE ====
- name: Upload Release
if: github.event.action == 'published' && matrix.mode == 'Release'
if: github.event.action == 'published' && matrix.config.artifact != ''
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./ppr-windows.zip
asset_name: ppr-windows.zip
asset_path: ./ppr-${{ matrix.config.artifact }}.zip
asset_name: ppr-${{ matrix.config.artifact }}.zip
asset_content_type: application/zip

# ==== SAVE CACHE ====
Expand Down
Loading
Loading