2023-11-01 12:41:24 +00:00
|
|
|
name: C++ Tests; Full Static Analysis
|
2022-11-18 13:58:26 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2022-11-22 15:42:02 +00:00
|
|
|
push:
|
2023-11-01 12:41:24 +00:00
|
|
|
branches:
|
|
|
|
- 'develop'
|
|
|
|
- 'main'
|
2023-09-02 23:36:45 +00:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'cpp/**'
|
2023-11-01 12:41:24 +00:00
|
|
|
- 'python/**'
|
2023-09-02 23:36:45 +00:00
|
|
|
- '.github/workflows/cpp.yml'
|
|
|
|
types:
|
|
|
|
- assigned
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
- reopened
|
2022-11-18 13:58:26 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
APT_PACKAGES: libspdlog-dev libpcap-dev libevdev2 libev-dev protobuf-compiler libgtest-dev libgmock-dev
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
unit_tests:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: cpp
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: sudo apt-get install ${{ env.APT_PACKAGES }}
|
|
|
|
|
|
|
|
- name: Build unit tests
|
|
|
|
run: make -j $(nproc) test
|
|
|
|
|
|
|
|
- name: Run unit tests
|
2022-12-05 17:58:23 +00:00
|
|
|
run: (set -o pipefail && bin/fullspec/piscsi_test | tee piscsi_test_log.txt)
|
2022-11-18 13:58:26 +00:00
|
|
|
|
|
|
|
- name: Upload logs
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2022-12-05 17:58:23 +00:00
|
|
|
name: piscsi_test_log.txt
|
|
|
|
path: cpp/piscsi_test_log.txt
|
2022-11-18 13:58:26 +00:00
|
|
|
|
|
|
|
sonarcloud:
|
|
|
|
runs-on: ubuntu-22.04
|
2022-12-05 17:58:23 +00:00
|
|
|
if: github.repository == 'PiSCSI/piscsi'
|
2022-11-18 13:58:26 +00:00
|
|
|
env:
|
|
|
|
SOURCES: cpp
|
|
|
|
BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out" # Directory where build-wrapper output will be placed
|
2023-10-01 21:41:53 +00:00
|
|
|
SONAR_SCANNER_VERSION: 5.0.1.3006
|
2022-11-18 13:58:26 +00:00
|
|
|
SONAR_SERVER_URL: "https://sonarcloud.io"
|
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
2023-10-02 07:06:51 +00:00
|
|
|
SONAR_PROJECT_KEY: "akuker-PISCSI"
|
2022-12-05 17:58:23 +00:00
|
|
|
SONAR_ORGANIZATION: "piscsi"
|
2022-11-18 13:58:26 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: sudo apt-get install ${{ env.APT_PACKAGES }}
|
|
|
|
|
|
|
|
- name: Set up JDK 17
|
|
|
|
uses: actions/setup-java@v1
|
|
|
|
with:
|
|
|
|
java-version: 17
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
name: Cache SonarCloud setup
|
|
|
|
id: sonar-install-cache
|
|
|
|
with:
|
|
|
|
path: ~/.sonar
|
|
|
|
key: sonar-with-build-wrapper-${{ env.SONAR_SCANNER_VERSION }}
|
|
|
|
|
|
|
|
- name: Set up SonarCloud scanner
|
|
|
|
if: steps.sonar-install-cache.outputs.cache-hit != 'true'
|
|
|
|
env:
|
|
|
|
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
|
|
|
|
run: |
|
|
|
|
mkdir -p $HOME/.sonar
|
|
|
|
curl -sSLo /tmp/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
|
|
|
|
unzip -o /tmp/sonar-scanner.zip -d $HOME/.sonar/
|
|
|
|
|
|
|
|
- name: Set up SonarCloud build wrapper
|
|
|
|
if: steps.sonar-install-cache.outputs.cache-hit != 'true'
|
|
|
|
env:
|
|
|
|
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
|
|
|
|
run: |
|
|
|
|
curl -sSLo /tmp/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
|
|
|
|
unzip -o /tmp/build-wrapper-linux-x86.zip -d $HOME/.sonar/
|
|
|
|
|
|
|
|
- name: Generate coverage
|
|
|
|
run: >-
|
|
|
|
(mkdir -p ${{ env.BUILD_WRAPPER_OUT_DIR }} || true) &&
|
|
|
|
$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64
|
|
|
|
--out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }}
|
|
|
|
make -j $(nproc) -C $SOURCES coverage
|
|
|
|
|
|
|
|
- name: Run gcov
|
|
|
|
working-directory: cpp
|
|
|
|
run: gcov --preserve-paths $(find -name '*.gcno')
|
|
|
|
|
|
|
|
- name: Run sonar-scanner
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: >-
|
|
|
|
$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin/sonar-scanner
|
|
|
|
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}"
|
|
|
|
--define sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}
|
|
|
|
--define sonar.organization=${{ env.SONAR_ORGANIZATION }}
|
|
|
|
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
|
|
|
|
--define sonar.cfamily.gcov.reportsPath=.
|
|
|
|
--define sonar.coverage.exclusions="cpp/**/test/**"
|
|
|
|
--define sonar.cpd.exclusions="cpp/**/test/**"
|
|
|
|
--define sonar.inclusions="cpp/**,python/**"
|
2023-11-01 12:41:24 +00:00
|
|
|
--define sonar.python.version=3.9,3.11
|