| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you 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. | |
| name: C++ Linter | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '.asf.yaml' | |
| - '.devcontainer/**' | |
| - '.github/**' | |
| - '**/*.md' | |
| - 'ci/**' | |
| - 'cmake_modules/**' | |
| - 'dev/**' | |
| - 'mkdocs/**' | |
| concurrency: | |
| group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
| cancel-in-progress: true | |
| jobs: | |
| cpp-linter: | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} | |
| runs-on: ubuntu-26.04 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| CPP_LINTER_VERSION: "1.13.0" | |
| # clang-format is handled by the pre-commit workflow; cpp-linter runs | |
| # clang-tidy only. | |
| CLANG_TIDY_VERSION: "22.1.8" | |
| steps: | |
| - name: Checkout iceberg-cpp | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libcurl4-openssl-dev libssl-dev libsqlite3-dev libpq-dev default-libmysqlclient-dev | |
| - name: Set up sccache | |
| uses: ./.github/actions/setup-sccache | |
| with: | |
| key-prefix: sccache-cpp-linter-ubuntu | |
| - name: Run build | |
| env: | |
| CC: gcc-14 | |
| CXX: g++-14 | |
| run: | | |
| mkdir build && cd build | |
| cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=sccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ | |
| -DICEBERG_BUILD_SQL_CATALOG=ON \ | |
| -DICEBERG_BUILD_BENCHMARKS=ON \ | |
| -DICEBERG_SQL_SQLITE=ON \ | |
| -DICEBERG_SQL_POSTGRESQL=ON \ | |
| -DICEBERG_SQL_MYSQL=ON \ | |
| -DICEBERG_BUILD_HIVE=ON | |
| cmake --build . | |
| - name: Save sccache | |
| if: always() | |
| uses: ./.github/actions/save-sccache | |
| with: | |
| key-prefix: sccache-cpp-linter-ubuntu | |
| job-status: ${{ job.status }} | |
| - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| python-version: '3.13' | |
| - name: Install cpp-linter and clang tools | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install "cpp-linter==${CPP_LINTER_VERSION}" "clang-tidy==${CLANG_TIDY_VERSION}" | |
| - name: Run cpp-linter | |
| id: linter | |
| if: github.event_name == 'pull_request' | |
| continue-on-error: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # need '-fno-builtin-std-forward_like', see https://github.com/llvm/llvm-project/issues/101614 | |
| # cpp20_compatibility_test.cc is ignored: it asserts it is compiled as C++20, | |
| # which the global '-std=c++23' below would override. The build enforces it. | |
| run: | | |
| cpp-linter \ | |
| --style='' \ | |
| --tidy-checks='' \ | |
| --version="${pythonLocation}/bin" \ | |
| --files-changed-only=true \ | |
| --lines-changed-only=true \ | |
| --thread-comments=true \ | |
| --ignore='build|cmake_modules|ci|src/iceberg/catalog/hive/gen-cpp|src/iceberg/test/cpp20_compatibility_test.cc' \ | |
| --database=build \ | |
| --verbosity=debug \ | |
| --extra-arg='-std=c++23' \ | |
| --extra-arg="-I${PWD}/src" \ | |
| --extra-arg="-I${PWD}/build/src" \ | |
| --extra-arg="-I${PWD}/build/_deps/sqlpp23-src/include" \ | |
| --extra-arg='-I/usr/include/postgresql' \ | |
| --extra-arg='-I/usr/include/mysql' \ | |
| --extra-arg='-fno-builtin-std-forward_like' | |
| - name: Fail fast?! | |
| if: github.event_name == 'pull_request' && steps.linter.outputs.checks-failed != 0 | |
| run: | | |
| echo "some linter checks failed. ${STEPS_LINTER_OUTPUTS_CHECKS_FAILED}" | |
| exit 1 | |
| env: | |
| STEPS_LINTER_OUTPUTS_CHECKS_FAILED: ${{ steps.linter.outputs.checks-failed }} |