build: use CPM for dependencies #860
This file contains hidden or 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: Static Analysis | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.ref }}-${{ github.workflow }} | |
| cancel-in-progress: true | |
| env: | |
| CCACHE_BASEDIR: ${{ github.workspace }} | |
| CCACHE_DIR: ${{ github.workspace }}/.ccache | |
| CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm | |
| jobs: | |
| sonar: | |
| name: SonarCloud | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/philips-software/amp-devcontainer-cpp:7.2.0@sha256:1afa82f415104fd36c8af65740872fd01685275c2e1620f8133c35b3fbff0590 | |
| env: | |
| SONAR_SERVER_URL: "https://sonarcloud.io" | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 # Disable shallow clone to enable blame information | |
| persist-credentials: false | |
| - name: Restore CPM packages cache | |
| uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ env.CPM_SOURCE_CACHE }} | |
| key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} | |
| - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 | |
| with: | |
| key: ccache-${{ github.job }}- | |
| max-size: 2G | |
| save: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| - name: Build for coverage | |
| uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 | |
| with: | |
| configurePreset: "Coverage" | |
| buildPreset: "Coverage" | |
| testPreset: "Coverage" | |
| env: | |
| GTEST_OUTPUT: "xml:${{ github.workspace }}/testresults/" | |
| - name: Save CPM packages cache | |
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ env.CPM_SOURCE_CACHE }} | |
| key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} | |
| - name: Run acceptance tests | |
| run: | | |
| bats --formatter junit cucumber_cpp/acceptance_test/test.bats | tee test-report.xml | |
| - name: Collect coverage | |
| run: | | |
| gcovr --sonarqube=coverage.xml --exclude-lines-by-pattern '.*assert\(.*\);|.*really_assert\(.*\);|.*std::abort();' --exclude-unreachable-branches --exclude-throw-branches -j "$(nproc)" --exclude=.*/example/.* --exclude=.*/external/.* --exclude=.*/test/.* | |
| - uses: philips-software/sonarqube-issue-conversion@9e9958764ba5fd1d302b039779dc902bedfa4d01 # v1.2.0 | |
| with: | |
| input: ${{ github.workspace }}/testresults/*.xml | |
| output: execution.xml | |
| transformation: gtest-to-generic-execution | |
| - name: Convert results | |
| run: | | |
| cp .build/Coverage/compile_commands.json compile_commands.json | |
| - uses: sonarsource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| codeql: | |
| name: CodeQL | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/philips-software/amp-devcontainer-cpp:7.2.0@sha256:1afa82f415104fd36c8af65740872fd01685275c2e1620f8133c35b3fbff0590 | |
| permissions: | |
| security-events: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Restore CPM packages cache | |
| uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ env.CPM_SOURCE_CACHE }} | |
| key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} | |
| - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 | |
| with: | |
| key: ccache-${{ github.job }}- | |
| max-size: 2G | |
| save: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| - uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 | |
| with: | |
| languages: cpp | |
| - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 | |
| with: | |
| configurePreset: "Host" | |
| buildPreset: "Host-Debug" | |
| - name: Save CPM packages cache | |
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ env.CPM_SOURCE_CACHE }} | |
| key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} | |
| - uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 |