293cbe27d0014519bb71f665a3d4b88c26326228
[strongswan.git] / .github / workflows / sonarcloud.yml
1 name: SonarCloud
2
3 on: [push]
4
5 env:
6   CCACHE_BASEDIR: ${{ github.workspace }}
7   CCACHE_COMPRESS: true
8   CCACHE_MAXSIZE: 200M
9   OS_NAME: linux
10
11 jobs:
12   pre-check:
13     runs-on: ubuntu-latest
14     outputs:
15       should_skip: ${{ steps.skip-check.outputs.should_skip }}
16     steps:
17       - id: skip-check
18         uses: fkirc/skip-duplicate-actions@master
19         with:
20           concurrent_skipping: 'same_content'
21
22   sonarcloud:
23     needs: pre-check
24     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
25     runs-on: ubuntu-latest
26     env:
27       TEST: sonarcloud
28     steps:
29       - uses: actions/checkout@v2
30         with:
31           fetch-depth: 0
32       - uses: actions/cache@v2
33         with:
34           path: |
35             ~/.ccache
36             ~/.sonar-cache
37           key: ccache-sonarcloud-${{ github.ref }}:${{ github.sha }}
38           restore-keys: |
39             ccache-sonarcloud-${{ github.ref }}:
40             ccache-sonarcloud-
41       - run: |
42           sudo apt-get install -qq ccache
43           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
44           ccache -z
45       # using SonarSource/sonarcloud-github-action is currently not recommended
46       # for C builds, so we follow the "any CI" instructions
47       - name: Install sonar-scanner
48         env:
49           SONAR_SCANNER_VERSION: 4.4.0.2170
50         run: |
51           export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
52           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
53           unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
54           echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
55           curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
56           unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
57           echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
58       - env:
59           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60           BUILD_NUMBER: ${{ github.run_id }}
61           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
62           SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }}
63           SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
64         uses: ./.github/actions/default
65       - run: ccache -s