|
| 1 | +name: CI Linux |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + name: |
| 10 | + description: "Manual trigger" |
| 11 | + schedule: |
| 12 | + - cron: '35 17 * * 6' |
| 13 | + |
| 14 | +permissions: |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-test-style-cover: |
| 19 | + name: Build, Tests, and Coverage |
| 20 | + runs-on: ubuntu-22.04 |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v5 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + ref: ${{ github.ref }} |
| 28 | + |
| 29 | + - name: Install CMake and prerequisites |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install -y build-essential curl python3-pip git uncrustify valgrind |
| 34 | + python3 -m pip install --upgrade pip |
| 35 | + python3 -m pip install gcovr |
| 36 | +
|
| 37 | + # CMake 3.31.8 |
| 38 | + CMAKE_VER=3.31.8 |
| 39 | + curl -L "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-x86_64.tar.gz" -o cmake-old.tgz |
| 40 | + sudo tar -C /opt -xzf cmake-old.tgz |
| 41 | + echo "/opt/cmake-${CMAKE_VER}-linux-x86_64/bin" >> "$GITHUB_PATH" |
| 42 | +
|
| 43 | + - name: Show cmake version |
| 44 | + run: | |
| 45 | + cmake --version |
| 46 | + ctest --version |
| 47 | +
|
| 48 | + - name: Configure |
| 49 | + run: | |
| 50 | + mkdir -p build |
| 51 | + cd build |
| 52 | + cmake ../ci/linux -DCMAKE_BUILD_TYPE=Release |
| 53 | +
|
| 54 | + - name: Build |
| 55 | + run: | |
| 56 | + cd build |
| 57 | + make -j"$(nproc)" |
| 58 | +
|
| 59 | + # --- Run tests with newer CTest to produce JUnit --- |
| 60 | + - name: Run tests and export JUnit |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + ctest --test-dir build/microcdr-build \ |
| 64 | + --output-on-failure \ |
| 65 | + --no-tests=error \ |
| 66 | + --output-junit "$GITHUB_WORKSPACE/build/CTestResults.xml" |
| 67 | +
|
| 68 | + - name: Generate coverage (gcovr Cobertura XML + HTML) |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + EXCLUDES=( |
| 72 | + '--exclude-unreachable-branches' |
| 73 | + '--exclude' 'ci/' |
| 74 | + '--exclude' 'test/' |
| 75 | + '--exclude' 'build/' |
| 76 | + ) |
| 77 | + gcovr -x -r . "${EXCLUDES[@]}" -o build/coverage.xml |
| 78 | + gcovr --html-details -r . "${EXCLUDES[@]}" -o build/coverage.html |
| 79 | +
|
| 80 | + - name: Upload artifacts (CTest & Coverage) |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: test-and-coverage |
| 84 | + path: | |
| 85 | + build/CTestResults.xml |
| 86 | + build/coverage.xml |
| 87 | + build/coverage.html |
| 88 | + if-no-files-found: warn |
| 89 | + |
| 90 | + - name: Publish unit test results (JUnit) |
| 91 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 92 | + if: (!cancelled()) |
| 93 | + with: |
| 94 | + files: build/CTestResults.xml |
| 95 | + check_run: false |
| 96 | + comment_mode: failures |
| 97 | + comment_title: "Linux Tests Results" |
| 98 | + |
| 99 | + - name: Coverage (human-readable summary) |
| 100 | + if: success() |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + gcovr -r . \ |
| 104 | + --exclude-unreachable-branches \ |
| 105 | + --exclude ci/ \ |
| 106 | + --exclude test/ \ |
| 107 | + --exclude build/ |
| 108 | +
|
| 109 | + uncrustify: |
| 110 | + name: Uncrustify check |
| 111 | + runs-on: ubuntu-22.04 |
| 112 | + if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'conflicts') }} |
| 113 | + steps: |
| 114 | + - name: Run Uncrustify Linter |
| 115 | + uses: eProsima/eProsima-CI/ubuntu/uncrustify@v0 |
0 commit comments