Skip to content

add nightly workflow #65

add nightly workflow

add nightly workflow #65

Workflow file for this run

name: SonarCloud
on:
push:
branches:
- main
pull_request_target:
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
container: ghcr.io/zephyrproject-rtos/ci:v0.26.12
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
CMAKE_PREFIX_PATH: /opt/toolchains
steps:
- uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
path: thingy91x-oob
- uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
path: thingy91x-oob
- name: Initialize
working-directory: thingy91x-oob
run: |
west init -l .
west config manifest.group-filter +bsec
west update -o=--depth=1 -n
- name: Install dependencies
run: |
pip install -r nrf/scripts/requirements-build.txt
apt-get update
apt install -y curl ruby-full
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Run build-wrapper
working-directory: thingy91x-oob
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} west twister -T app -v --inline-logs --integration
- name: Run unit tests with coverage
working-directory: thingy91x-oob
run: |
west twister -T . -v --inline-logs --platform native_posix -C
gcovr twister-out -v --merge-mode-functions=separate --exclude=twister-out --sonarqube coverage.xml
- name: Run sonar-scanner on main
working-directory: thingy91x-oob
if: github.event_name != 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define project.settings=sonar-project.properties \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.inclusions=**/*.c,**/*.h
- name: Run sonar-scanner on PR
working-directory: thingy91x-oob
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define project.settings=sonar-project.properties \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.inclusions=**/*.c,**/*.h \
--define sonar.scm.revision=${{ env.HEAD_SHA }} \
--define sonar.pullrequest.key=${{ env.PR_NUMBER }} \
--define sonar.pullrequest.branch=${{ env.PR_BRANCH }} \
--define sonar.pullrequest.base=${{ env.BASE_REF }}