build: Add CMake configuration #1349
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
# Copyright (c) Omar Boukli-Hacene. All rights reserved. | |
# Distributed under an MIT-style license that can be | |
# found in the LICENSE file. | |
# SPDX-License-Identifier: MIT | |
name: SonarCloud scan | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: {} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
SONAR_HOST_URL: https://sonarcloud.io | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory | |
COVERAGE_REPORTS_PATH: ${{ github.workspace }}/coverage.xml | |
steps: | |
- name: Update dependency list | |
run: sudo apt-get update | |
- name: Install dependencies | |
run: >- | |
sudo apt-get install | |
--assume-yes | |
--quiet | |
autoconf-archive | |
gcovr | |
lcov | |
libboost-test-dev | |
libsdl2-dev | |
xvfb | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Install sonar-scanner and build-wrapper | |
uses: sonarsource/sonarqube-github-c-cpp@v2 | |
env: | |
SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} | |
- name: Run autogen.sh | |
run: ./autogen.sh | |
- name: Configure build | |
run: >- | |
./configure | |
--enable-code-coverage | |
CPPFLAGS='-DTROMINO_2D_HEADLESS' | |
- name: Run build-wrapper | |
run: >- | |
build-wrapper-linux-x86-64 | |
--out-dir '${{ env.BUILD_WRAPPER_OUT_DIR }}' | |
make clean all check | |
- name: Run tromino | |
run: ./tromino 2> /dev/null || true | |
- name: Run tromino 5 0 0 | |
run: ./tromino 5 0 0 2> /dev/null || true | |
- name: Run tromino 2 0 7 | |
run: ./tromino 2 0 7 2> /dev/null || true | |
- name: Run tromino 2 0 1 | |
run: ./tromino 2 0 1 | |
- name: Run tromino 8 3 5 | |
run: ./tromino 8 3 5 | |
- name: Run tromino2d | |
run: ./tromino2d 2> /dev/null || true | |
- name: Run tromino2d 5 0 0 | |
run: ./tromino2d 5 0 0 2> /dev/null || true | |
- name: Run tromino2d 8192 0 0 | |
run: ./tromino2d 8192 0 0 2> /dev/null || true | |
- name: Run tromino2d 1024 0 0 -f | |
run: ./tromino2d 1024 0 0 -f 2> /dev/null || true | |
- name: Start Xvfb | |
run: Xvfb :99 -screen 0 1024x768x24 & | |
- name: Run tromino2d 2 0 0 -f | |
env: | |
DISPLAY: :99 | |
run: ./tromino2d 2 0 0 -f | |
- name: Run tromino2d 8 2 5 | |
env: | |
DISPLAY: :99 | |
run: ./tromino2d 8 2 5 | |
- name: Run gcovr | |
run: >- | |
gcovr | |
--exclude='./test' | |
--exclude='/usr/include' | |
--keep | |
--root '.' | |
--sonarqube '${{ env.COVERAGE_REPORTS_PATH }}' | |
- name: Run sonar-scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: >- | |
sonar-scanner | |
--define sonar.host.url='${{ env.SONAR_HOST_URL }}' | |
--define sonar.cfamily.compile-commands='${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json' | |
--define sonar.coverageReportPaths='${{ env.COVERAGE_REPORTS_PATH }}' |