github: Migrate from Travis CI to Github Actions
[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   sonarcloud:
13     runs-on: ubuntu-latest
14     env:
15       TEST: sonarcloud
16     steps:
17       - uses: actions/checkout@v2
18         with:
19           fetch-depth: 0
20       - uses: actions/cache@v2
21         with:
22           path: |
23             ~/.ccache
24             ~/.sonar-cache
25           key: ccache-sonarcloud-${{ github.ref }}:${{ github.sha }}
26           restore-keys: |
27             ccache-sonarcloud-${{ github.ref }}:
28             ccache-sonarcloud-
29       - run: |
30           sudo apt-get install -qq ccache
31           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
32           ccache -z
33       # using SonarSource/sonarcloud-github-action is currently not recommended
34       # for C builds, so we follow the "any CI" instructions
35       - name: Install sonar-scanner
36         env:
37           SONAR_SCANNER_VERSION: 4.4.0.2170
38         run: |
39           export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
40           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
41           unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
42           echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
43           curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
44           unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
45           echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
46       - env:
47           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48           BUILD_NUMBER: ${{ github.run_id }}
49           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
50           SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }}
51           SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
52         uses: ./.github/actions/default
53       - run: ccache -s