SonarCloud #158
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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 1" | |
jobs: | |
analyze: | |
name: Code Coverage | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
env: | |
DISPLAY: :0 | |
SONAR_SCANNER_VERSION: 4.4.0.2170 | |
SONAR_SCANNER_OPTS: -server | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
KRITIKA_TOKEN: ${{ secrets.KRITIKA_TOKEN }} | |
TRAVIS_COMMIT: ${{ github.sha }} | |
LC_ALL: en | |
steps: | |
- name: Set SONAR_SCANNER_HOME | |
run: echo "SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux" >> $GITHUB_ENV | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: update | |
run: sudo apt-get update | |
- name: set timezone | |
run: sudo ln -fs /usr/share/zoneinfo/America/Chicago /etc/localtime | |
# - name: install latex dependencies | |
# run: DEBIAN_FRONTEND="noninteractive" sudo apt-get install -q -y --force-yes texlive-luatex texlive-latex-recommended texlive-latex-extra texlive-fonts-extra texlive-fonts-extra-links texlive-bibtex-extra biber | |
- name: install dependencies | |
run: DEBIAN_FRONTEND="noninteractive" sudo apt-get install -q -y --force-yes qtbase5-dev qt5-qmake libzip-dev cmake g++ debhelper dpkg-dev xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libdevel-cover-perl lcov cpanminus zlib1g-dev libminizip-dev libssl-dev | |
- name: start xvfb | |
run: sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 & | |
- name: download libxlsxwriter | |
run: pushd /tmp && wget https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_1.1.5.tar.gz && tar -zxf RELEASE_1.1.5.tar.gz && popd | |
- name: build libxlsxwriter | |
run: pushd /tmp/libxlsxwriter-RELEASE_1.1.5 && echo -e "SET(CPACK_GENERATOR \"DEB\")\nset(CPACK_PACKAGE_NAME \"libxlsxwriter\")\nSET(CPACK_DEBIAN_PACKAGE_MAINTAINER \"[email protected]\")\nset(CPACK_PACKAGE_VERSION \"1.1.5\")\nINCLUDE(CPack)" >> CMakeLists.txt && /usr/bin/cmake ./ && make -j3 && cpack && popd | |
- name: install libxlsxwriter | |
run: sudo dpkg -i /tmp/libxlsxwriter-RELEASE_1.1.5/libxlsxwriter-1.1.5-Linux.deb | |
- name: Download Sonar Scanner | |
run: curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip | |
- name: Unzip Sonar Scanner | |
run: unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | |
- name: Download Sonar Build Wrapper | |
run: curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip | |
- name: Unzip Sonar Build Wrapper | |
run: unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ | |
- name: Add Sonar Build Wrapper to PATH | |
run: echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH | |
- name: Configure STIGQter to build tests | |
run: echo "DEFINES += USE_TESTS" >> STIGQter.pro | |
- name: qmake STIGQter | |
run: qmake STIGQter.pro | |
- name: Configure STIGQter to generate code coverage stats | |
run: sed -i -e 's:-O2:-O0 -fprofile-arcs -ftest-coverage -fno-exceptions -fno-inline:g' -e 's:-Wl,-O1:-Wl,-O1 -lgcov --coverage:g' Makefile | |
- name: Build STIGQter | |
run: build-wrapper-linux-x86-64 --out-dir bw-output make -j3 | |
- name: Run STIGQter tests | |
run: ./STIGQter tests | |
- name: Run gcov | |
run: for x in src/*.cpp; do gcov --branch-probabilities --branch-counts ${x} -o .; done | |
- name: Add Sonar Scanner to PATH | |
run: echo "$SONAR_SCANNER_HOME/bin" >> $GITHUB_PATH | |
- name: Run Sonar Scanner | |
run: rm -rf tests/*.ckl && sonar-scanner -Dsonar.organization=squinky86 -Dsonar.projectKey=squinky86_STIGQter -Dsonar.projectName=STIGQter -Dsonar.projectVersion=1.2.4 -Dsonar.sources=./src/ -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.cfamily.threads=2 -Dsonar.cfamily.gcov.reportsPath=. -Dsonar.host.url=https://sonarcloud.io | |
- name: Run codecov.io | |
run: bash <(curl -s https://codecov.io/bash) | |
- name: Build LCOV files | |
run: mkdir -p coverage && lcov --capture --directory . --output-file coverage/lcov.info | |
- name: Run Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run gcov2perl | |
run: gcov2perl *.gcov |