Add CLang to CI unit tests #563
Workflow file for this run
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
| ## | |
| ## Copyright (c) 2025 The Johns Hopkins University Applied Physics | |
| ## Laboratory LLC. | |
| ## | |
| ## This file is part of the Bundle Protocol Security Library (BSL). | |
| ## | |
| ## Licensed under the Apache License, Version 2.0 (the "License"); | |
| ## you may not use this file except in compliance with the License. | |
| ## You may obtain a copy of the License at | |
| ## http://www.apache.org/licenses/LICENSE-2.0 | |
| ## Unless required by applicable law or agreed to in writing, software | |
| ## distributed under the License is distributed on an "AS IS" BASIS, | |
| ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| ## See the License for the specific language governing permissions and | |
| ## limitations under the License. | |
| ## | |
| ## This work was performed for the Jet Propulsion Laboratory, California | |
| ## Institute of Technology, sponsored by the United States Government under | |
| ## the prime contract 80NM0018D0004 between the Caltech and NASA under | |
| ## subcontract 1700763. | |
| ## | |
| name: Build and run tests | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' | |
| push: | |
| branches: | |
| - main | |
| - 'apl-fy[0-9][0-9]' | |
| pull_request: {} # any target | |
| jobs: | |
| unit-test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-24.04', 'centos-9'] | |
| compiler: ['gcc', 'clang'] | |
| name: Unit Test (${{matrix.os}} ${{matrix.compiler}}) | |
| runs-on: ${{ matrix.os == 'centos-9' && 'ubuntu-24.04' || matrix.os }} | |
| container: ${{ matrix.os == 'centos-9' && 'quay.io/centos/centos:stream9' || null }} | |
| permissions: | |
| contents: read | |
| actions: write | |
| env: | |
| CC: ${{matrix.compiler=='clang' && 'clang' || 'gcc'}} | |
| CXX: ${{matrix.compiler=='clang' && 'clang++' || 'g++'}} | |
| steps: | |
| - name: Set up OS | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo rm /var/lib/man-db/auto-update | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake ninja-build \ | |
| ruby pkg-config ccache patch \ | |
| ${{matrix.compiler=='clang' && 'clang llvm' || 'gcc g++'}} \ | |
| libssl-dev libjansson-dev \ | |
| valgrind xmlstarlet \ | |
| python3 python3-pip python3-wheel | |
| pip3 install gcovr | |
| - name: Set up OS | |
| if: startsWith(matrix.os, 'centos') | |
| run: | | |
| dnf install -y epel-release | |
| crb enable | |
| dnf install -y \ | |
| git rsync \ | |
| cmake ninja-build \ | |
| ruby pkg-config ccache patch \ | |
| ${{matrix.compiler=='clang' && 'clang llvm' || 'gcc gcc-c++'}} \ | |
| openssl-devel jansson-devel \ | |
| valgrind-devel xmlstarlet \ | |
| python3 python3-pip python3-wheel | |
| pip3 install gcovr | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| create-symlink: true | |
| - name: Dependencies | |
| run: ./build.sh deps | |
| - name: Prep | |
| run: > | |
| ./build.sh prep | |
| -DBUILD_DOCS_API=OFF -DBUILD_DOCS_MAN=OFF | |
| -DBUILD_UNITTEST=ON -DBUILD_COVERAGE=ON | |
| - name: Build | |
| run: ./build.sh | |
| - name: Install | |
| run: ./build.sh install | |
| - name: Check symbols | |
| run: | | |
| ./check_symbols.py bsl_front bsl_dynamic --prefix bsl_ | |
| ./check_symbols.py bsl_crypto --prefix bsl_ bslb_ | |
| ./check_symbols.py bsl_default_sc --prefix bslx_ | |
| ./check_symbols.py bsl_sample_pp --prefix bslp_ | |
| ./check_symbols.py bsl_mock_bpa --prefix MockBPA_ bsl_eidpat_ bsl_mock_ mock_bpa_ | |
| - name: Test | |
| run: ./build.sh check | |
| - name: Collect coverage | |
| run: | | |
| ./build.sh coverage | |
| ./build.sh coverage-summary >> $GITHUB_STEP_SUMMARY | |
| - name: Archive coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{github.job}}-${{matrix.os}}-${{matrix.compiler}}-coverage | |
| path: build/default/coverage* | |
| mock-bpa-test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-24.04', 'centos-9'] | |
| name: Mock BPA Test (${{matrix.os}} gcc) | |
| runs-on: ${{ matrix.os == 'centos-9' && 'ubuntu-24.04' || matrix.os }} | |
| container: ${{ matrix.os == 'centos-9' && 'quay.io/centos/centos:stream9' || null }} | |
| permissions: | |
| contents: read | |
| actions: write | |
| steps: | |
| - name: Set up OS | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo rm /var/lib/man-db/auto-update | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake ninja-build ruby gcc g++ ccache patch \ | |
| libssl-dev libjansson-dev \ | |
| valgrind xmlstarlet \ | |
| python3 python3-pip python3-wheel | |
| pip3 install gcovr | |
| - name: Set up OS | |
| if: startsWith(matrix.os, 'centos') | |
| run: | | |
| dnf config-manager --set-enabled crb | |
| dnf install -y epel-release | |
| dnf install -y \ | |
| git rsync \ | |
| cmake ninja-build \ | |
| ruby pkg-config gcc gcc-c++ ccache patch \ | |
| openssl-devel jansson-devel \ | |
| valgrind-devel xmlstarlet \ | |
| python3 python3-pip python3-wheel | |
| pip3 install gcovr | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| create-symlink: true | |
| - name: Dependencies | |
| run: ./build.sh deps | |
| - name: Prep | |
| run: > | |
| ./build.sh prep | |
| -DBUILD_DOCS_API=OFF -DBUILD_DOCS_MAN=OFF | |
| -DBUILD_UNITTEST=OFF -DBUILD_COVERAGE=ON | |
| - name: Build | |
| run: ./build.sh | |
| - name: Install | |
| run: ./build.sh install | |
| - name: Test Prep | |
| run: | | |
| pip3 install --upgrade pip | |
| pip3 install -r mock-bpa-test/requirements.txt | |
| - name: Test | |
| env: | |
| TEST_MEMCHECK: '1' | |
| run: python3 -m pytest mock-bpa-test | |
| - name: Collect coverage | |
| run: | | |
| ./build.sh coverage | |
| ./build.sh coverage-summary >> $GITHUB_STEP_SUMMARY | |
| - name: Archive coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{github.job}}-${{matrix.os}}-gcc-coverage | |
| path: build/default/coverage* |