Skip to content

Commit

Permalink
Upgrade yml files, add version tracking (#45)
Browse files Browse the repository at this point in the history
* Upgrade yml files, add version tracking to PathTracer and build artifact generation. Add clang-tidy instructions.

* fix clang format

* add a debug build stage.

* fix debug build

* windows debug builds are too slow. Disable them for now.

Co-authored-by: Farzon Lotfi <[email protected]>
  • Loading branch information
farzonl and farzonl committed Aug 21, 2022
1 parent 369cd26 commit 9119afb
Show file tree
Hide file tree
Showing 24 changed files with 779 additions and 90 deletions.
44 changes: 44 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#clang-tidy copied from chromium
---
Checks: '-*,
bugprone-argument-comment,
bugprone-dangling-handle,
bugprone-inaccurate-erase,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-unused-raii,
bugprone-use-after-move,
google-build-explicit-make-pair,
#google-explicit-constructor,
#google-readability-casting,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
#modernize-loop-convert,
#modernize-make-shared,
#modernize-make-unique,
#modernize-redundant-void-arg,
#modernize-replace-random-shuffle,
#modernize-shrink-to-fit,
modernize-use-bool-literals,
#modernize-use-default-member-init,
#modernize-use-emplace,
#modernize-use-equals-default,
#modernize-use-equals-delete,
#modernize-use-noexcept,
#modernize-use-nullptr,
#modernize-use-override,
#modernize-use-transparent-functors,
#readability-redundant-member-init'
CheckOptions:
- key: bugprone-dangling-handle.HandleClasses
value: ::std::basic_string_view;::std::span;::absl::string_view;::base::BasicStringPiece;::base::span
- key: bugprone-string-constructor.StringNames
value: ::std::basic_string;::std::basic_string_view;::base::BasicStringPiece
- key: modernize-use-default-member-init.UseAssignment
value: 1
# This relaxes modernize-use-emplace in some cases; we might want to make it
# more aggressive in the future. See discussion on
# https://groups.google.com/a/chromium.org/g/cxx/c/noMMTNYiM0w .
- key: modernize-use-emplace.IgnoreImplicitConstructors
value: 1
...
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v3.2.0
uses: jidicula/clang-format-action@v4.8.0
with:
clang-format-version: '11'
clang-format-version: '14'
check-path: ${{ matrix.path }}
139 changes: 139 additions & 0 deletions .github/workflows/cmake-debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: CMake Debug

on:
push:
branches:
- main
paths:
- src/**
- test/**
- .github/workflows/cmake.yml
pull_request:
branches:
- '**'
paths:
- src/**
- test/**
- .github/workflows/cmake.yml
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_dlib_ext: .so
artifact_staticlib_ext: .a
- os: windows-latest
artifact_exec_ext: .exe
artifact_dlib_ext: .dll
artifact_staticlib_ext: .lib
# Note: I wanted to use env.BUILD_TYPE, but it isn't taking
#artifact_out_dir: ${{ BUILD_TYPE }}/
artifact_out_dir: Debug/
artifact_os_name: Windows
artifact_arch: x86_64
- os: macos-latest
artifact_dlib_ext: .dylib
artifact_staticlib_ext: .a
steps:
- uses: actions/checkout@v2
- run: sudo apt install libgl1-mesa-dev mesa-utils libgl1-mesa-glx libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
if: matrix.os == 'ubuntu-latest'
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Cache C++ dependencies in Packages Directory
uses: actions/cache@v3
with:
path: |
packages
key: ${{ runner.OS }}-c++-packages-cache-Debug-${{ hashFiles('depsCache.json') }}
restore-keys: |
${{ runner.OS }}-c++-packages-cache-Debug-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS="-coverage"

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Set variables (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
run: |
APP=$(cat $GITHUB_WORKSPACE/src/version/AppName.txt)
VER=$(cat $GITHUB_WORKSPACE/src/version/Version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
echo "APPNAME=$APP" >> $GITHUB_ENV
- name: Set variables (Windows)
if: matrix.os == 'windows-latest'
run: |
$APP = type .\src\version\AppName.txt
$VER = type .\src\version\Version.txt
echo "VERSION=$VER" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "APPNAME=$APP" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Test Unix-like
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test/${{ env.APPNAME }}_TEST

#- name: Test Windows
# if: matrix.os == 'windows-latest'
# working-directory: ${{github.workspace}}/build
# shell: bash
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ./test/Debug/${{ env.APPNAME }}_TEST.exe

- name: Linux Code Coverage
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./scripts/runGcov.sh
- name: Prepare Binaries for upload (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
shell: bash
run: |
mkdir ${{github.workspace}}/artifacts
cp build/src/lib${{ env.APPNAME }}${{ matrix.artifact_staticlib_ext }} ${{github.workspace}}/artifacts
cp build/src/main/${{ env.APPNAME }}_exe ${{github.workspace}}/artifacts
cp -r build/src/main/shaders ${{github.workspace}}/artifacts
pushd ${{github.workspace}}
zip -r ${{ env.APPNAME }}-$(uname -s)-$(uname -m).zip artifacts
popd
- name: Prepare Binaries for upload (windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
[system.io.directory]::CreateDirectory("${{github.workspace}}/artifacts")
Copy-Item "build/src/${{ matrix.artifact_out_dir}}${{ env.APPNAME }}${{ matrix.artifact_staticlib_ext }}" -Destination "${{github.workspace}}/artifacts"
Copy-Item "build/src/main/${{ matrix.artifact_out_dir }}${{ env.APPNAME }}_exe${{ matrix.artifact_exec_ext }}" -Destination "${{github.workspace}}/artifacts"
Compress-Archive -Path ${{github.workspace}}/artifacts/* -DestinationPath ${{ env.APPNAME }}-${{matrix.artifact_os_name}}-${{matrix.artifact_arch}}.zip
- name: 'Upload Pull Request Artifact'
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/pull/')
with:
name: ${{ env.APPNAME }} Pull Request Artifacts
path: ${{ env.APPNAME }}-*.zip
retention-days: 5
146 changes: 146 additions & 0 deletions .github/workflows/cmake-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: CMake Release

on:
push:
branches:
- main
paths:
- src/**
- test/**
- .github/workflows/cmake.yml
pull_request:
branches:
- '**'
paths:
- src/**
- test/**
- .github/workflows/cmake.yml
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_dlib_ext: .so
artifact_staticlib_ext: .a
- os: windows-latest
artifact_exec_ext: .exe
artifact_dlib_ext: .dll
artifact_staticlib_ext: .lib
# Note: I wanted to use env.BUILD_TYPE, but it isn't taking
#artifact_out_dir: ${{ BUILD_TYPE }}/
artifact_out_dir: Release/
artifact_os_name: Windows
artifact_arch: x86_64
- os: macos-latest
artifact_dlib_ext: .dylib
artifact_staticlib_ext: .a
steps:
- uses: actions/checkout@v2
- run: sudo apt install libgl1-mesa-dev mesa-utils libgl1-mesa-glx libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
if: matrix.os == 'ubuntu-latest'
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Cache C++ dependencies in Packages Directory
uses: actions/cache@v3
with:
path: |
packages
key: ${{ runner.OS }}-c++-packages-cache-Release-${{ hashFiles('depsCache.json') }}
restore-keys: |
${{ runner.OS }}-c++-packages-cache-Release-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS="-coverage"

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Set variables (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
run: |
APP=$(cat $GITHUB_WORKSPACE/src/version/AppName.txt)
VER=$(cat $GITHUB_WORKSPACE/src/version/Version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
echo "APPNAME=$APP" >> $GITHUB_ENV
- name: Set variables (Windows)
if: matrix.os == 'windows-latest'
run: |
$APP = type .\src\version\AppName.txt
$VER = type .\src\version\Version.txt
echo "VERSION=$VER" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "APPNAME=$APP" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Test Unix-like
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test/${{ env.APPNAME }}_TEST

- name: Test Windows
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test/Release/${{ env.APPNAME }}_TEST.exe

- name: Linux Code Coverage
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./scripts/runGcov.sh
- name: Prepare Binaries for upload (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
shell: bash
run: |
mkdir ${{github.workspace}}/artifacts
cp build/src/lib${{ env.APPNAME }}${{ matrix.artifact_staticlib_ext }} ${{github.workspace}}/artifacts
cp build/src/main/${{ env.APPNAME }}_exe ${{github.workspace}}/artifacts
cp -r build/src/main/shaders ${{github.workspace}}/artifacts
pushd ${{github.workspace}}
zip -r ${{ env.APPNAME }}-$(uname -s)-$(uname -m).zip artifacts
popd
- name: Prepare Binaries for upload (windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
[system.io.directory]::CreateDirectory("${{github.workspace}}/artifacts")
Copy-Item "build/src/${{ matrix.artifact_out_dir}}${{ env.APPNAME }}${{ matrix.artifact_staticlib_ext }}" -Destination "${{github.workspace}}/artifacts"
Copy-Item "build/src/main/${{ matrix.artifact_out_dir }}${{ env.APPNAME }}_exe${{ matrix.artifact_exec_ext }}" -Destination "${{github.workspace}}/artifacts"
Compress-Archive -Path ${{github.workspace}}/artifacts/* -DestinationPath ${{ env.APPNAME }}-${{matrix.artifact_os_name}}-${{matrix.artifact_arch}}.zip
- name: 'Upload Pull Request Artifact'
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/pull/')
with:
name: ${{ env.APPNAME }} Pull Request Artifacts
path: ${{ env.APPNAME }}-*.zip
retention-days: 5
- name: Upload binaries to Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/heads/main')
with:
tag_name: ${{ env.APPNAME }}-${{ env.VERSION }}
files: |
${{ env.APPNAME }}-*.zip
Loading

0 comments on commit 9119afb

Please sign in to comment.