|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: IWYU |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + paths-ignore: |
| 25 | + - 'ci/**' |
| 26 | + - 'docs/**' |
| 27 | + - 'mkdocs/**' |
| 28 | + pull_request: |
| 29 | + types: [opened, synchronize, reopened, ready_for_review] |
| 30 | + branches: |
| 31 | + - main |
| 32 | + paths-ignore: |
| 33 | + - 'ci/**' |
| 34 | + - 'docs/**' |
| 35 | + - 'mkdocs/**' |
| 36 | + |
| 37 | +concurrency: |
| 38 | + group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} |
| 39 | + cancel-in-progress: true |
| 40 | + |
| 41 | +permissions: |
| 42 | + contents: read |
| 43 | + |
| 44 | +jobs: |
| 45 | + iwyu: |
| 46 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} |
| 47 | + name: Include-What-You-Use (Advisory) |
| 48 | + runs-on: ubuntu-26.04 |
| 49 | + timeout-minutes: 30 |
| 50 | + env: |
| 51 | + SCCACHE_DIR: ${{ github.workspace }}/.sccache |
| 52 | + SCCACHE_CACHE_SIZE: "2G" |
| 53 | + steps: |
| 54 | + - name: Checkout iceberg-cpp |
| 55 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 56 | + with: |
| 57 | + persist-credentials: false |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: | |
| 61 | + sudo apt-get update |
| 62 | + sudo apt-get install -y \ |
| 63 | + libcurl4-openssl-dev \ |
| 64 | + clang-20 \ |
| 65 | + iwyu \ |
| 66 | + ninja-build |
| 67 | +
|
| 68 | + - name: Restore sccache cache |
| 69 | + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 70 | + with: |
| 71 | + path: ${{ github.workspace }}/.sccache |
| 72 | + key: sccache-iwyu-${{ github.run_id }} |
| 73 | + restore-keys: | |
| 74 | + sccache-iwyu- |
| 75 | +
|
| 76 | + - name: Setup sccache |
| 77 | + uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 |
| 78 | + |
| 79 | + - name: Configure (Clang + compile_commands.json) |
| 80 | + run: | |
| 81 | + mkdir build && cd build |
| 82 | + cmake .. -G Ninja \ |
| 83 | + -DCMAKE_C_COMPILER=clang-20 \ |
| 84 | + -DCMAKE_CXX_COMPILER=clang++-20 \ |
| 85 | + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ |
| 86 | + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ |
| 87 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
| 88 | + -DCMAKE_BUILD_TYPE=Debug \ |
| 89 | + -DICEBERG_BUILD_STATIC=ON \ |
| 90 | + -DICEBERG_BUILD_SHARED=OFF |
| 91 | +
|
| 92 | + - name: Build |
| 93 | + run: cmake --build build |
| 94 | + |
| 95 | + - name: Show sccache stats |
| 96 | + run: sccache --show-stats |
| 97 | + |
| 98 | + - name: Save sccache cache |
| 99 | + if: github.ref == 'refs/heads/main' |
| 100 | + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 101 | + with: |
| 102 | + path: ${{ github.workspace }}/.sccache |
| 103 | + key: sccache-iwyu-${{ github.run_id }} |
| 104 | + |
| 105 | + - name: Run IWYU (advisory) |
| 106 | + run: | |
| 107 | + # iwyu_tool may be named iwyu_tool.py or iwyu_tool depending on distro |
| 108 | + IWYU_TOOL=$(command -v iwyu_tool.py || command -v iwyu_tool) |
| 109 | + echo "Using: $IWYU_TOOL" |
| 110 | +
|
| 111 | + $IWYU_TOOL -p build \ |
| 112 | + -j $(nproc) \ |
| 113 | + -- \ |
| 114 | + -Xiwyu --mapping_file=${{ github.workspace }}/iwyu.imp \ |
| 115 | + -Xiwyu --no_fwd_decls \ |
| 116 | + -Xiwyu --max_line_length=100 \ |
| 117 | + 2>&1 | tee iwyu-full-report.txt || true |
| 118 | +
|
| 119 | + # Filter to only project sources (exclude build/_deps and tests) |
| 120 | + grep "src/iceberg/" iwyu-full-report.txt \ |
| 121 | + > iwyu-filtered.txt || true |
| 122 | +
|
| 123 | + echo "::notice::IWYU report generated (advisory only, not blocking)" |
| 124 | +
|
| 125 | + if [ -s iwyu-filtered.txt ]; then |
| 126 | + echo "## IWYU Findings (advisory — not blocking)" >> "$GITHUB_STEP_SUMMARY" |
| 127 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 128 | + head -200 iwyu-filtered.txt >> "$GITHUB_STEP_SUMMARY" |
| 129 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 130 | + else |
| 131 | + echo "## IWYU: No issues found ✓" >> "$GITHUB_STEP_SUMMARY" |
| 132 | + fi |
| 133 | +
|
| 134 | + - name: Upload IWYU report |
| 135 | + if: always() |
| 136 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 137 | + with: |
| 138 | + name: iwyu-report |
| 139 | + path: | |
| 140 | + iwyu-full-report.txt |
| 141 | + iwyu-filtered.txt |
0 commit comments