SonarCloud Test #1
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: SonarCloud Run | ||
on: | ||
workflow_run: | ||
workflows: [SonarCloud Build] | ||
types: [completed] | ||
jobs: | ||
build: | ||
name: sonar_cloud_run | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
permissions: | ||
actions: read # required to download artifacts | ||
env: | ||
BUILD_WRAPPER_OUT_DIR: build_wrapper | ||
steps: | ||
- name: echo event | ||
run: cat $GITHUB_EVENT_PATH | ||
- name: Download PR number artifact | ||
uses: dawidd6/action-download-artifact@v3 | ||
with: | ||
workflow: Build | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: PR_NUMBER | ||
- name: Read PR_NUMBER.txt | ||
id: pr_number | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./PR_NUMBER.txt | ||
- name: Request GitHub API for PR data | ||
uses: octokit/[email protected] | ||
id: get_pr_data | ||
with: | ||
route: GET /repos/{full_name}/pulls/{number} | ||
number: ${{ steps.pr_number.outputs.content }} | ||
full_name: ${{ github.event.repository.full_name }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.workflow_run.head_repository.full_name }} | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
fetch-depth: 0 | ||
- name: Checkout base branch | ||
run: | | ||
git remote add upstream ${{ github.event.repository.clone_url }} | ||
git fetch upstream | ||
git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} | ||
git checkout ${{ github.event.workflow_run.head_branch }} | ||
git clean -ffdx && git reset --hard HEAD | ||
- name: Install sonar-scanner and build-wrapper | ||
uses: SonarSource/sonarcloud-github-c-cpp@v2 | ||
- name: Set up Java 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 8 | ||
- name: Install dependencies | ||
run: sudo apt-get install cmake doxygen graphviz | ||
- name: Build Zserio compiler with C++ extension | ||
run: | | ||
scripts/build.sh core cpp zserio | ||
scripts/release.sh -p zserio | ||
- name: Build C++ runtime and C++ tests under build-wrapper | ||
run: | | ||
cat > build_and_test.sh << EOF | ||
#!/bin/bash | ||
scripts/build.sh cpp_rt-linux64-gcc && scripts/release.sh -p runtime_libs && \ | ||
scripts/test.sh cpp-linux64-gcc | ||
EOF | ||
chmod a+x build_and_test.sh | ||
build-wrapper-linux-x86-64 --out-dir ${{env.BUILD_WRAPPER_OUT_DIR}} ./build_and_test.sh | ||
env: | ||
CMAKE_EXTRA_ARGS: "-DCMAKE_BUILD_TYPE=Release" | ||
CMAKE_BUILD_OPTIONS: "-j4" | ||
- name: Run sonar-scanner | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: | | ||
sonar-scanner \ | ||
--define sonar.projectKey="ndsev_zserio" \ | ||
--define sonar.organization="ndsev" \ | ||
--define sonar.sourceEncoding="UTF-8" \ | ||
--define sonar.sources="compiler/extensions/cpp/runtime/src,build/test/cpp/linux64-gcc/release" \ | ||
--define sonar.inclusions="**/*.h,**/*.cpp" \ | ||
--define sonar.exclusions="**/CMakeFiles/**/*" \ | ||
--define sonar.tests="compiler/extensions/cpp/runtime/test,test" \ | ||
--define sonar.test.inclusions="compiler/**/test/**/*.h,compiler/**/test/**/.cpp,test/**/*.h,test/**/*.cpp" \ | ||
--define sonar.scm.exclusions.disabled="true" \ | ||
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" |