port PS 4000A to graph-prototype (#125) #149
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: [ dev-prototype ] | |
pull_request: | |
branches: [ dev-prototype ] | |
release: | |
types: [ created ] | |
env: | |
REFERENCE_CONFIG: 'Ubuntu gcc13' # configuration used for coverage etc | |
jobs: | |
build: | |
name: "${{ matrix.configurations.name }} | ${{ matrix.cmake-build-type }}" | |
environment: configure coverage | |
runs-on: ${{ matrix.configurations.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
configurations: | |
- name: Ubuntu gcc13 | |
os: ubuntu-22.04 | |
compiler: gcc13 | |
- name: Ubuntu Latest clang17 | |
os: ubuntu-22.04 | |
compiler: clang17 | |
- name: Ubuntu Latest emscripten | |
os: ubuntu-22.04 | |
compiler: emscripten | |
cmake-build-type: [ Release, Debug ] | |
env: | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Cache | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-fetchContent-cache | |
with: | |
path: ${{runner.workspace}}/build/_deps | |
key: ${{ runner.os }}-${{ matrix.configurations.compiler }}-${{ matrix.cmake-build-type }}-${{ hashFiles('CMakeLists.txt') }} | |
- name: Install gcovr | |
# packaged gcovr is too old for gcc13 | |
shell: bash | |
if: matrix.configurations.name == env.REFERENCE_CONFIG && matrix.cmake-build-type == 'Debug' | |
run: | | |
python3 -m pip install gcovr --user --no-warn-script-location | |
gcovr --version | |
- name: Install gcc-13 | |
if: matrix.configurations.compiler == 'gcc13' | |
run: | | |
sudo apt-get install -y gcc-13 g++-13 # gcovr # packaged gcovr is too old for gcc13 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 110 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13 | |
- name: Install clang-17 | |
if: matrix.configurations.compiler == 'clang17' | |
run: | | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - | |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main' | |
sudo apt update | |
sudo apt upgrade -y # update clang14 to fix packaging conflicts | |
sudo apt install -y clang-17 libc++-17-dev libc++abi-17-dev | |
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-17 110 | |
- name: Install emscripten | |
if: matrix.configurations.compiler == 'emscripten' | |
shell: bash | |
run: | | |
cd | |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
# Download and install the latest SDK tools. | |
./emsdk install releases-bf3c159888633d232c0507f4c76cc156a43c32dc-64bit | |
# Make the "latest" SDK "active" for the current user. (writes .emscripten file) | |
./emsdk activate releases-bf3c159888633d232c0507f4c76cc156a43c32dc-64bit | |
- name: Install sonar-scanner and build-wrapper | |
if: matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug' | |
uses: SonarSource/sonarcloud-github-c-cpp@v1 | |
- name: Install picoscope libraries | |
run: | | |
# https://www.picotech.com/downloads/linux | |
wget -O - https://labs.picotech.com/Release.gpg.key|sudo apt-key add - | |
sudo add-apt-repository 'deb https://labs.picotech.com/rc/picoscope7/debian/ picoscope main' | |
sudo apt update | |
sudo apt install -y udev libusb-1.0-0-dev libps3000a libps4000a libps5000a libps6000 libps6000a || true # ignore udev errors in post install because of udev in container | |
- name: Configure CMake | |
if: matrix.configurations.compiler != 'emscripten' | |
shell: bash | |
run: | | |
cmake -S . -B ../build -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=${{ matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug'}} | |
- name: Configure CMake Emscripten | |
if: matrix.configurations.compiler == 'emscripten' | |
shell: bash | |
run: | | |
source ~/emsdk/emsdk_env.sh | |
emcmake cmake -S . -B ../build -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=OFF | |
- name: Build | |
if: matrix.configurations.compiler != 'gcc13' || matrix.cmake-build-type != 'Debug' | |
shell: bash | |
run: | | |
test -f ~/emsdk/emsdk_env.sh && source ~/emsdk/emsdk_env.sh | |
cmake --build ../build | |
- name: Build with Coverage and SonarCube | |
if: matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug' | |
shell: bash | |
run: build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ../build | |
- name: execute tests | |
if: matrix.configurations.compiler != 'gcc13' || matrix.cmake-build-type != 'Debug' | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
run: ctest --output-on-failure | |
- name: execute tests with coverage | |
if: matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug' | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
run: cmake --build . --target coverage | |
- name: Run sonar-scanner | |
if: matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug' | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
test -f ~/emsdk/emsdk_env.sh && source ~/emsdk/emsdk_env.sh | |
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" | |
# Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options |