Enable SonarCloud (#347)

* Create sonarcloud.yml

* Create sonar-project.properties

* Combine github actions files

* Fix syntax error with GitHub Actions

* Update clang-tools for GitHub Actions

* Simplify test matrix naming
This commit is contained in:
Lucas Ramage 2023-04-15 20:25:00 -04:00 committed by GitHub
parent c8401b1f6d
commit 1ced0101ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 41 deletions

58
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: build
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: "${{ matrix.SECCOMP == '1' && 'seccomp' || 'no-seccomp' }}"
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: tmp
strategy:
fail-fast: false
matrix:
SECCOMP: [ 0, 1 ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install sonar-scanner and build-wrapper
uses: sonarsource/sonarcloud-github-c-cpp@v1
- name: Install build dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq clang-tools-12 curl gdb lcov libarchive-dev libtalloc-dev sloccount strace swig uthash-dev python3-dev lzop
- name: Gather analytics
run: sloccount --details .
- name: Build elf loader, proot, and care
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -C src loader.elf loader-m32.elf build.h
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} env CFLAGS=--coverage LDFLAGS=--coverage make -C src proot care V=1
- name: Execute test suite
continue-on-error: true
timeout-minutes: 10
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} env ${{ matrix.SECCOMP == '0' && 'PROOT_NO_SECCOMP=1' || '' }} PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PWD/src make -C test -j $(nproc) QUIET_LOG=$PWD/test.log
- name: Output test log
if: always()
continue-on-error: true
run: ([ -f test.log ] && cat test.log) || true
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"

View File

@ -1,41 +0,0 @@
name: Ubuntu
on:
workflow_dispatch:
push:
pull_request:
branches: [ master ]
jobs:
build:
name: "Test ${{ matrix.SECCOMP == '1' && 'with seccomp' || 'no seccomp' }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
SECCOMP: [ 0, 1 ]
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq clang-tools-6.0 curl gdb lcov libarchive-dev libtalloc-dev sloccount strace swig uthash-dev python3-dev lzop
- name: Info
run: sloccount --details .
- name: Build
run: |
make -C src loader.elf loader-m32.elf build.h
env CFLAGS=--coverage LDFLAGS=--coverage make -C src proot care V=1
- name: Test
run: |
env ${{ matrix.SECCOMP == '0' && 'PROOT_NO_SECCOMP=1' || '' }} PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PWD/src make -C test -j $(nproc) QUIET_LOG=$PWD/test.log
- name: Log
if: always()
run: ([ -f test.log ] && cat test.log) || true

12
sonar-project.properties Normal file
View File

@ -0,0 +1,12 @@
sonar.projectKey=proot-me_proot
sonar.organization=proot-me
# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=proot
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8