Update actions/cache action to v3 #22
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 | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
jobs: | |
build: | |
name: OS ${{ matrix.os }} | Compiler ${{ matrix.compiler-name }} | Version ${{ matrix.compiler-version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ macos-10.15, ubuntu-20.04 ] | |
compiler-version: [ '' ] | |
compiler-name: [ '' ] | |
cc: [ '' ] | |
cxx: [ '' ] | |
include: | |
# MacOS CLANG | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 7 | |
cc: /usr/local/opt/llvm@7/bin/clang-7 | |
cxx: /usr/local/opt/llvm@7/bin/clang++ | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 8 | |
cc: /usr/local/opt/llvm@8/bin/clang-8 | |
cxx: /usr/local/opt/llvm@8/bin/clang++ | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 9 | |
cc: /usr/local/opt/llvm@9/bin/clang-9 | |
cxx: /usr/local/opt/llvm@9/bin/clang++ | |
# FOR SOME REASON LLVM10 is not available | |
# - os: macos-10.15 | |
# compiler-name: llvm | |
# compiler-version: 10 | |
# cc: /usr/local/opt/llvm@10/bin/clang-10 | |
# cxx: /usr/local/opt/llvm@10/bin/clang++ | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 11 | |
cc: /usr/local/opt/llvm@11/bin/clang-11 | |
cxx: /usr/local/opt/llvm@11/bin/clang++ | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 12 | |
cc: /usr/local/opt/llvm@12/bin/clang-12 | |
cxx: /usr/local/opt/llvm@12/bin/clang++ | |
- os: macos-10.15 | |
compiler-name: llvm | |
compiler-version: 13 | |
cc: /usr/local/opt/llvm@13/bin/clang-13 | |
cxx: /usr/local/opt/llvm@13/bin/clang++ | |
# MacOS GCC | |
- os: macos-10.15 | |
compiler-name: gcc | |
compiler-version: 7 | |
cc: gcc-7 | |
cxx: g++-7 | |
- os: macos-10.15 | |
compiler-name: gcc | |
compiler-version: 8 | |
cc: gcc-8 | |
cxx: g++-8 | |
- os: macos-10.15 | |
compiler-name: gcc | |
compiler-version: 9 | |
cc: gcc-9 | |
cxx: g++-9 | |
- os: macos-10.15 | |
compiler-name: gcc | |
compiler-version: 10 | |
cc: gcc-10 | |
cxx: g++-10 | |
- os: macos-10.15 | |
compiler-name: gcc | |
compiler-version: 11 | |
cc: gcc-11 | |
cxx: g++-11 | |
# Ubuntu CLANG | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 7 | |
cc: clang-7 | |
cxx: clang++-7 | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 8 | |
cc: clang-8 | |
cxx: clang++-8 | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 9 | |
cc: clang-9 | |
cxx: clang++-9 | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 10 | |
cc: clang-10 | |
cxx: clang++-10 | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 11 | |
cc: clang-11 | |
cxx: clang++-11 | |
- os: ubuntu-20.04 | |
compiler-name: llvm | |
compiler-version: 12 | |
cc: clang-12 | |
cxx: clang++-12 | |
# FOR SOME REASON CLANG-13 is not available | |
# - os: ubuntu-20.04 | |
# compiler-name: llvm | |
# compiler-version: 13 | |
# cc: clang-13 | |
# cxx: clang++-13 | |
# Ubuntu GCC | |
- os: ubuntu-20.04 | |
compiler-name: gcc | |
compiler-version: 7 | |
cc: gcc-7 | |
cxx: g++-7 | |
- os: ubuntu-20.04 | |
compiler-name: gcc | |
compiler-version: 8 | |
cc: gcc-8 | |
cxx: g++-8 | |
- os: ubuntu-20.04 | |
compiler-name: gcc | |
compiler-version: 9 | |
cc: gcc-9 | |
cxx: g++-9 | |
- os: ubuntu-20.04 | |
compiler-name: gcc | |
compiler-version: 10 | |
cc: gcc-10 | |
cxx: g++-10 | |
- os: ubuntu-20.04 | |
compiler-name: gcc | |
compiler-version: 11 | |
cc: gcc-11 | |
cxx: g++-11 | |
# Exclude the "base cases" | |
exclude: | |
- os: macOS-10.15 | |
compiler-version: '' | |
compiler-name: '' | |
cc: '' | |
cxx: '' | |
- os: ubuntu-20.04 | |
compiler-version: '' | |
compiler-name: '' | |
cc: '' | |
cxx: '' | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install LLVM on MacOS | |
if: ${{ matrix.os == 'macos-10.15' && matrix.compiler-name == 'llvm' }} | |
run: brew install llvm@${{ matrix.compiler-version }} | |
- name: Install GCC on MacOS | |
if: ${{ matrix.os == 'macos-10.15' && matrix.compiler-name == 'gcc' }} | |
run: brew install gcc@${{ matrix.compiler-version }} | |
- name: Install LLVM on Ubuntu | |
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.compiler-name == 'llvm' }} | |
run: sudo apt-get install -y clang-${{ matrix.compiler-version }} libomp-${{ matrix.compiler-version }}-dev | |
- name: Install GCC on Ubuntu | |
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.compiler-name == 'gcc' }} | |
run: sudo apt-get install -y g++-${{ matrix.compiler-version }} | |
- name: Configure CMake | |
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | |
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | |
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.extra-cmake-arguments }} | |
- name: Build | |
# Build your program with the given configuration | |
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: ctest -C ${{env.BUILD_TYPE}} -V | |
sonar: | |
name: SonarCloud | |
runs-on: ubuntu-latest | |
env: | |
SONAR_SCANNER_VERSION: 4.6.1.2450 # Find the latest version in the "Linux" link on this page: | |
# https://sonarcloud.io/documentation/analysis/scan/sonarscanner/ | |
SONAR_SERVER_URL: "https://sonarcloud.io" | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Download and set up sonar-scanner | |
env: | |
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip | |
run: | | |
mkdir -p $HOME/.sonar | |
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | |
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | |
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH | |
- name: Download and set up build-wrapper | |
env: | |
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip | |
run: | | |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} | |
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ | |
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH | |
- name: Run build-wrapper | |
run: | | |
mkdir build | |
cmake -S . -B build | |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release | |
- name: Run sonar-scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" |