c647579047361881d505719713aa22474a15c2c5
[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.sha }}
38           restore-keys: |
39             ccache-sonarcloud-
40       - run: |
41           sudo apt-get install -qq ccache
42           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
43           ccache -z
44       # using SonarSource/sonarcloud-github-action is currently not recommended
45       # for C builds, so we follow the "any CI" instructions
46       - name: Install sonar-scanner
47         env:
48           SONAR_SCANNER_VERSION: 4.6.2.2472
49         run: |
50           export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
51           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
52           unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
53           echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
54           curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
55           unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
56           echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
57       - env:
58           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59           BUILD_NUMBER: ${{ github.run_id }}
60           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
61           SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }}
62           SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
63         uses: ./.github/actions/default
64       - run: ccache -s