Skip to content

Codecleanup type to kind (#48) #35

Codecleanup type to kind (#48)

Codecleanup type to kind (#48) #35

name: Deploy Coverage to GitHub pages
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
on:
push:
branches: [ master]
paths:
- '**.cpp'
- '**.h'
- '**CMakeLists.txt'
- .github/workflows/coverage-report.yml
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt install llvm-dev python3 libedit-dev
- name: Install dependencies (MacOS)
if: matrix.os == 'macOS-latest'
run: |
brew install llvm python3
- 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: Configure CMake (Mac)
if: matrix.os == 'macOS-latest'
# 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="-fprofile-instr-generate -fcoverage-mapping" \
-DBuildTest=TRUE \
-DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang \
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++
- name: Configure CMake (Linux)
if: matrix.os == 'ubuntu-22.04'
# 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="-fprofile-instr-generate -fcoverage-mapping" \
-DBuildTest=TRUE \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
- 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-22.04' || matrix.os == 'macOS-latest'
run: |
APP=$(cat $GITHUB_WORKSPACE/src/lib/Version/appName.txt)
VER=$(cat $GITHUB_WORKSPACE/src/lib/Version/version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
echo "APPNAME=$APP" >> $GITHUB_ENV
- name: Run Unit Test(s) on MacOS & Linux and Generate Profraw, Profdata, & html Coverage report
working-directory: ${{github.workspace}}
run: |
LLVM_PROFILE_FILE="${{ env.APPNAME }}Lang.profraw" ./build/test/${{ env.APPNAME }}Lang_TEST
- name: Run CLI Test(s) on MacoOS & Linux and Generate Profraw from cli input
working-directory: ${{github.workspace}}
run: |
LLVM_PROFILE_FILE="${{ env.APPNAME }}" python3 scripts/run_cli.py TestConfigJsonMethods
- name: On Mac Generate Profdata, & html Coverage report
if: matrix.os == 'macOS-latest'
working-directory: ${{github.workspace}}
run: |
$(brew --prefix llvm)/bin/llvm-profdata merge -sparse ${{ env.APPNAME }}*.profraw ${{ env.APPNAME }}Lang.profraw -o ${{ env.APPNAME }}.profdata
$(brew --prefix llvm)/bin/llvm-cov show -output-dir=build/out/report -format=html -instr-profile=${{ env.APPNAME }}.profdata -object=build/test/${{ env.APPNAME }}Lang_TEST build/src/cli/${{ env.APPNAME }} ${{github.workspace}}/src
- name: On Linux Generate Profdata, & html Coverage report
if: matrix.os == 'ubuntu-22.04'
working-directory: ${{github.workspace}}
run: |
llvm-profdata merge -sparse ${{ env.APPNAME }}*.profraw ${{ env.APPNAME }}Lang.profraw -o ${{ env.APPNAME }}.profdata
llvm-cov show -output-dir=build/out/report -format=html -instr-profile=${{ env.APPNAME }}.profdata -object=build/test/${{ env.APPNAME }}Lang_TEST build/src/cli/${{ env.APPNAME }} ${{github.workspace}}/src
- name: Init new repo in dist folder and commit generated files
working-directory: ${{github.workspace}}/build/out/report
run: |
git init
git add -A
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m 'deploy'
- name: Force push to destination branch
if: matrix.os == 'ubuntu-22.04'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages-coverage
force: true
directory: ${{github.workspace}}/build/out/report