cmake: add definitions override before any add_subdirectory command #495
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: Build and test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| - feature* | |
| pull_request_target: | |
| types: | |
| - edited | |
| - opened | |
| - reopened | |
| - synchronize | |
| branches: | |
| - main | |
| - develop | |
| - feature* | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| permissions: read-all | |
| container: | |
| image: ghcr.io/aosedge/aos-core-build:latest | |
| options: "--entrypoint /usr/bin/bash" | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| env: | |
| BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{github.event.pull_request.head.ref}} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| fetch-depth: 0 | |
| submodules: "recursive" | |
| - name: Install Build Wrapper | |
| uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4 | |
| - name: Build using SonarQube Build Wrapper | |
| run: | | |
| mkdir build | |
| conan profile detect --force | |
| conan install ./conan/ --output-folder build --settings=build_type=Debug --options=with_poco=True --build=missing | |
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DWITH_TEST=ON -DWITH_COVERAGE=ON -G "Unix Makefiles" \ | |
| -DCMAKE_TOOLCHAIN_FILE=./conan_toolchain.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
| build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ./build/ --config Debug --parallel | |
| - name: Run Tests | |
| run: | | |
| (cd build && make coverage) | |
| - name: Static analysis | |
| run: | | |
| cppcheck --enable=all --inline-suppr --std=c++17 --error-exitcode=1 \ | |
| --suppressions-list=./suppressions.txt -I src -I external/aos_core_common_cpp/include \ | |
| -I external/aos_core_common_cpp/external/aos_core_lib_cpp/include/ src | |
| - name: Upload codecov report | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./build/coverage.total | |
| - name: SonarCloud Scan on push | |
| if: github.event_name == 'push' | |
| uses: SonarSource/sonarqube-scan-action@v4 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| with: | |
| args: > | |
| --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" | |
| --define sonar.coverageReportPaths=build/coverage_sonarqube.xml | |
| - name: SonarCloud Scan on pull request | |
| if: github.event_name == 'pull_request_target' | |
| uses: SonarSource/sonarqube-scan-action@v4 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| projectBaseDir: "." | |
| args: > | |
| --define sonar.scm.revision=${{ github.event.pull_request.head.sha }} | |
| --define sonar.pullrequest.key=${{ github.event.pull_request.number }} | |
| --define sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} | |
| --define sonar.pullrequest.base=${{ github.event.pull_request.base.ref }} | |
| --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" | |
| --define sonar.coverageReportPaths=build/coverage_sonarqube.xml |