Codecleanup type to kind (#48) #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake Libfuzzer Release | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- '**.cpp' | |
- '**.h' | |
- '**CMakeLists.txt' | |
- .github/workflows/cmake-libfuzzer.yml | |
pull_request: | |
branches: | |
- '**' | |
paths: | |
- '**.cpp' | |
- '**.h' | |
- '**CMakeLists.txt' | |
- .github/workflows/cmake-libfuzzer.yml | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# Note using windows-2019 b\c of weird compile error when vs2022 is installed | |
# https://github.com/llvm/llvm-project/issues/56300 | |
os: [ubuntu-latest, macos-13, windows-2019] | |
include: | |
- os: windows-2019 | |
artifact_exec_ext: .exe | |
artifact_os_name: Windows | |
artifact_arch: x86_64 | |
- os: macos-13 | |
xcode: Xcode_15.0.1 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Dependencies (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt install build-essential cmake \ | |
ca-certificates llvm clang libedit-dev ninja-build | |
- name: Install Dependencies (Mac) | |
if: matrix.os == 'macOS-13' | |
run: | | |
brew install llvm ninja | |
- name: Install Dependencies (Windows) | |
if: matrix.os == 'windows-2019' | |
run: | | |
choco install llvm ninja | |
- 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-libfuzzer-Release-${{ hashFiles('depsCache.json') }} | |
restore-keys: | | |
${{ runner.OS }}-c++-packages-cache-libfuzzer-Release- | |
- name: set Xcode and MacOS sdk Version | |
if: matrix.os == 'macOS-13' | |
run: | | |
sudo xcode-select --switch /Applications/${{ matrix.xcode }}.app/Contents/Developer | |
xcrun --show-sdk-version | |
- name: Configure CMake (Mac) | |
shell: bash | |
working-directory: ${{github.workspace}}/build | |
if: matrix.os == 'macOS-13' | |
# Mac needs brew's llvm to override AppleClang | |
run: | | |
export PATH="/usr/local/opt/llvm/bin:$PATH" | |
cmake -G Ninja $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FUZZER=true | |
- 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 | |
if: matrix.os != 'macOS-13' | |
# 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 -G Ninja $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FUZZER=true | |
- 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-13' | |
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: Set variables (Windows) | |
if: matrix.os == 'windows-2019' | |
run: | | |
$APP = type .\src\lib\Version\appName.txt | |
$VER = type .\src\lib\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: Prepare Binaries for upload (Mac\Linux) | |
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-13' | |
shell: bash | |
run: | | |
mkdir ${{github.workspace}}/artifacts | |
cp build/fuzz/*Fuzzer ${{github.workspace}}/artifacts | |
pushd ${{github.workspace}} | |
zip -r ${{ env.APPNAME }}-$(uname -s)-libfuzzers-$(uname -m).zip artifacts | |
popd | |
- name: Prepare Binaries for upload (windows) | |
if: matrix.os == 'windows--2019' | |
shell: powershell | |
run: | | |
[system.io.directory]::CreateDirectory("${{github.workspace}}/artifacts") | |
Copy-Item "build/fuzz/${{ env.APPNAME }}*Fuzzer${{ matrix.artifact_exec_ext }}" -Destination "${{github.workspace}}/artifacts" | |
Compress-Archive -Path ${{github.workspace}}/artifacts/* -DestinationPath ${{ env.APPNAME }}-${{matrix.artifact_os_name}}-libfuzzers-${{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/master') | |
with: | |
tag_name: ${{ env.APPNAME }}-${{ env.VERSION }} | |
files: | | |
${{ env.APPNAME }}-*.zip |