Add c++20 badge to readme #93
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: C++ CI | |
on: [ push, pull_request ] | |
jobs: | |
precommit_checks: | |
runs-on: 'ubuntu-latest' | |
name: Pre-Commit Checks | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Update pip | |
run: | | |
python -m pip install --upgrade pip | |
- name: Install and run pre-commit | |
uses: pre-commit/[email protected] | |
with: | |
extra_args: --all-files | |
matrix-strategy-setup: | |
needs: precommit_checks | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-matrix | |
run: | | |
TASKS=$(echo $(cat .github/workflows/build-matrix.json) | sed 's/ //g' ) | |
echo "matrix=$TASKS" >> $GITHUB_OUTPUT | |
build-test-install: | |
needs: matrix-strategy-setup | |
name: ${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: ${{ fromJson(needs.matrix-strategy-setup.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Set up Ninja | |
uses: seanmiddleditch/gha-setup-ninja@master | |
- name: Cache LLVM Download | |
id: cache-llvm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-llvm-files | |
with: | |
path: ./llvm-${{ matrix.config.compiler_version }} | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }}-${{ hashFiles('**/workflows/cpp.yml') }} | |
- name: Install LLVM and Clang | |
if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.config.cc == 'clang' }} | |
uses: KyleMayes/install-llvm-action@v2 | |
with: | |
version: ${{ matrix.config.compiler_version }} | |
directory: ./llvm-${{ matrix.config.compiler_version }} | |
env: 'true' | |
- name: Append LLVM To Path | |
if: ${{ runner.os == 'Linux' && matrix.config.cc == 'clang' }} | |
shell: bash | |
run: | | |
llvmdir=$(pwd)/llvm-${{ matrix.config.compiler_version }} | |
echo "$llvmdir" | |
echo "LLVM_DIR=$llvmdir" >> $GITHUB_OUTPUT | |
echo "$llvmdir/bin" >> $GITHUB_PATH | |
- name: Print Clang version | |
if: ${{ runner.os == 'Linux' && matrix.config.cc == 'clang' }} | |
shell: bash | |
run: | | |
echo $PATH | |
ls -l ./llvm-${{ matrix.config.compiler_version }} | |
ls -l ./llvm-${{ matrix.config.compiler_version }}/bin | |
echo "$PATH" | |
clang --version | |
llvm-config --version | |
- name: Set up GCC | |
if: ${{ runner.os == 'Linux' && matrix.config.cc == 'gcc' }} | |
uses: egor-tensin/setup-gcc@v1 | |
with: | |
version: ${{ matrix.config.compiler_version }} | |
platform: x64 | |
- name: Install conan & numpy | |
id: conan | |
shell: bash | |
run: | | |
python3 -m pip install --upgrade pip setuptools | |
python3 -m pip install conan numpy | |
echo "CONAN_HOME=$HOME/.conan2-${{ runner.os }}-${{ matrix.config.build_type }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }}" >> $GITHUB_OUTPUT | |
- name: Source profile | |
if: ${{ runner.os == 'Linux' }} | |
shell: bash | |
run: source $HOME/.profile | |
- name: Setup cmake | |
uses: jwlawson/[email protected] | |
with: | |
cmake-version: '3.26' | |
- name: Configure Windows compile environment | |
uses: ilammy/msvc-dev-cmd@v1 | |
if: runner.os == 'Windows' && matrix.config.cxx == 'cl' | |
with: | |
arch: amd64 | |
- name: Cache Conan Dependencies Install | |
id: cache-conan-deps | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-conan-deps | |
with: | |
path: ${{ steps.conan.outputs.CONAN_HOME }} | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.config.build_type }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }}-${{ hashFiles('**/conandata.yml') }}-${{ hashFiles('**/conanfile.py') }} | |
- name: Configure CMake | |
shell: bash | |
env: | |
CC: ${{ matrix.config.cc }} | |
CXX: ${{ matrix.config.cxx }} | |
run: > | |
export CONAN_HOME=${{ steps.conan.outputs.CONAN_HOME }} && | |
cmake | |
-S . | |
-B ./build | |
-G Ninja | |
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" | |
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | |
-DWARNINGS_AS_ERRORS:BOOL=OFF | |
-DUSE_PYBIND11_FINDPYTHON:BOOL=ON | |
-DENABLE_CACHE:BOOL=OFF | |
-DENABLE_BUILD_SANDBOX:BOOL=OFF | |
-DENABLE_PCH:BOOL=OFF | |
-DENABLE_TESTING:BOOL=ON | |
- name: Build REINFORCE Library | |
shell: bash | |
run: | | |
cmake --build ./build --config ${{ matrix.config.build_type }} --target reinforce_tests_all | |
- name: Run REINFORCE Tests | |
shell: bash | |
run: > | |
GTEST_OUTPUT=xml:gtest-report-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }}.xml | |
GTEST_COLOR=1 | |
ctest -R Test_reinforce_tests_all | |
--test-dir ./build | |
--verbose | |
-C ${{ matrix.config.build_type }} | |
- name: Upload lib test result artifacts | |
uses: actions/upload-artifact@v3 | |
if: success() | |
with: | |
name: gtest-results | |
path: ./build/**/gtest-report-${{ matrix.config.os }}-${{ matrix.config.cc }}-${{ matrix.config.compiler_version }}.xml | |
retention-days: 1 | |
publish-gtest-results: | |
name: "Publish GTest Results" | |
needs: build-test-install | |
runs-on: ubuntu-latest | |
if: always() | |
permissions: | |
checks: write | |
pull-requests: write | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: gtest-results | |
path: ./artifacts/gtest-results_downloaded | |
- name: Display structure of downloaded files | |
run: ls | |
working-directory: ./artifacts/gtest-results_downloaded | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
files: ./artifacts/**/*.xml |