diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-11-27 10:17:51 +0100 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-11-27 19:15:53 +0100 |
commit | 0a46049ef26270933ecf6fea7395b03e6aee783e (patch) | |
tree | f57680776ef263a63720e225194cc34556854511 /.github/workflows | |
parent | 1903a8e26893a3f332ba39643aa8da5fdaf1536b (diff) | |
download | libquotient-0a46049ef26270933ecf6fea7395b03e6aee783e.tar.gz libquotient-0a46049ef26270933ecf6fea7395b03e6aee783e.zip |
Add SonarCloud analysis to CI
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/ci.yml | 3 | ||||
-rw-r--r-- | .github/workflows/sonar.yml | 113 |
2 files changed, 115 insertions, 1 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 714473b0..47e55421 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: steps: - uses: actions/checkout@v2 with: + fetch-depth: 0 submodules: ${{ matrix.e2ee != '' }} - name: Cache Qt @@ -126,7 +127,7 @@ jobs: -DGTAD_PATH=$GITHUB_WORKSPACE/../gtad/gtad" \ >>$GITHUB_ENV echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with API files regeneration" >>$GITHUB_ENV - + - name: Initialize CodeQL tools if: env.CODEQL_ANALYSIS uses: github/codeql-action/init@v1 diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 00000000..76db59c9 --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,113 @@ +name: Sonar + +on: + push: + pull_request: + types: [opened, reopened] + +defaults: + run: + shell: bash + +jobs: + SonarCloud: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + qt-version: [ '5.12.10' ] + e2ee: [ '', 'e2ee' ] + update-api: [ '', 'update-api' ] + + env: + SONAR_SCANNER_VERSION: 4.6.2.2472 + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: build/sonar + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: ${{ matrix.e2ee != '' }} + + - name: Cache Qt + id: cache-qt + uses: actions/cache@v2 + with: + path: ${{ runner.workspace }}/Qt + key: ${{ runner.os }}-Qt${{ matrix.qt-version }}-cache + + - name: Install Qt + uses: jurplel/install-qt-action@v2.11.1 + with: + version: ${{ matrix.qt-version }} +# arch: ${{ matrix.qt-arch }} # Only Windows needs that + cached: ${{ steps.cache-qt.outputs.cache-hit }} + + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Setup build environment + run: | + echo "CC=gcc-10" >>$GITHUB_ENV + echo "CXX=g++-10" >>$GITHUB_ENV + mkdir -p $HOME/.sonar + echo "CMAKE_ARGS=-G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=false \ + -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_PREFIX_PATH=~/.local" >>$GITHUB_ENV + cmake -E make_directory ${{ runner.workspace }}/build + + - name: Build and install olm + if: matrix.e2ee + run: | + cd .. + git clone https://gitlab.matrix.org/matrix-org/olm.git + cmake -S olm -B olm/build $CMAKE_ARGS + cmake --build olm/build --target install + + - name: Pull CS API and build GTAD + if: matrix.update-api + run: | + cd .. + git clone https://github.com/quotient-im/matrix-doc.git + git clone --recursive https://github.com/KitsuneRal/gtad.git + cmake -S gtad -B gtad $CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF + cmake --build gtad + echo "CMAKE_ARGS=$CMAKE_ARGS -DMATRIX_DOC_PATH=$GITHUB_WORKSPACE/../matrix-doc \ + -DGTAD_PATH=$GITHUB_WORKSPACE/../gtad/gtad" \ + >>$GITHUB_ENV + + - name: Download and set up Sonar Cloud tools + run: | + pushd $HOME/.sonar + curl -sSLo build-wrapper.zip $SONAR_SERVER_URL/static/cpp/build-wrapper-linux-x86.zip + unzip -o build-wrapper.zip + echo "BUILD_WRAPPER=$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux* --out-dir $BUILD_WRAPPER_OUT_DIR" >>$GITHUB_ENV + curl -sSLo sonar-scanner.zip \ + https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip + unzip -o sonar-scanner.zip + popd + + - name: Configure libQuotient + run: | + if [[ '${{ runner.os }}' == 'Windows' ]]; then + BIN_DIR=. + else + BIN_DIR=bin + fi + echo "BIN_DIR=$BIN_DIR" >>$GITHUB_ENV + cmake -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS -DQuotient_ENABLE_E2EE=${{ matrix.e2ee }} + + - name: Regenerate API code + if: matrix.update-api + run: cmake --build build --target update-api + + - name: Build libQuotient + run: | + $BUILD_WRAPPER cmake --build build --target all + + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + $HOME/.sonar/sonar-scanner*/bin/sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" |