From 9334dbda9b5a94cca4a759acacf3ea45f5497315 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Mon, 1 Apr 2024 21:30:27 -0700 Subject: [PATCH] Use LLVM 17 for coverage, clang-tidy, and sanitizers (#480) --- .github/workflows/coverage.yml | 23 +++++++++++------------ .github/workflows/lint-format.yml | 31 +++++++++++++++++++++++++------ .github/workflows/sanitizers.yml | 14 ++++++++++---- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 99f6d8f3..bd7ea410 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,19 +14,18 @@ jobs: steps: - uses: actions/checkout@v4 - # TODO: Remove this once clang 15 is default; clang 14 had a stdlib bug - - name: Install clang 15 + - name: Install LLVM 17 run: | - sudo apt-get update -q - sudo apt-get install -y clang-15 llvm-15-dev - sudo update-alternatives --install \ - /usr/bin/clang clang /usr/bin/clang-15 200 - sudo update-alternatives --install \ - /usr/bin/clang++ clang++ /usr/bin/clang++-15 200 - sudo update-alternatives --install \ - /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-15 200 - sudo update-alternatives --install \ - /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-15 200 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 all + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 200 + sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-17 200 + sudo update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-17 200 + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV - run: ./tools/coverage-generate.sh SleipnirTest diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml index 1e0a474d..6231735f 100644 --- a/.github/workflows/lint-format.yml +++ b/.github/workflows/lint-format.yml @@ -14,28 +14,36 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Fetch all history and metadata run: | git checkout -b pr git branch -f main origin/main + - name: Set up Python 3.8 uses: actions/setup-python@v5 with: python-version: 3.8 + - name: Install wpiformat run: pip3 install wpiformat + - name: Run run: wpiformat==2024.33 + - name: Check output run: git --no-pager diff --exit-code HEAD + - name: Generate diff run: git diff HEAD > wpiformat-fixes.patch if: ${{ failure() }} + - uses: actions/upload-artifact@v4 with: name: wpiformat fixes path: wpiformat-fixes.patch if: ${{ failure() }} + - name: Write to job summary run: | echo '```diff' >> $GITHUB_STEP_SUMMARY @@ -52,26 +60,37 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Fetch all history and metadata run: | git config --global --add safe.directory /__w/Sleipnir/Sleipnir git checkout -b pr git branch -f main origin/main + - name: Set up Python 3.8 uses: actions/setup-python@v5 with: python-version: 3.8 - - name: Install clang-tidy + + - name: Install LLVM 17 (Linux) run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main' >> /etc/apt/sources.list.d/proposed-repositories.list" - sudo apt-get update -q - sudo apt-get install -y clang-tidy-15 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 all + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 200 + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV + - name: Install wpiformat run: pip3 install wpiformat + - name: Create compile_commands.json - run: cmake -B build -S . -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-15 -DCMAKE_EXPORT_COMPILE_COMMANDS=YES + run: cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=YES + - name: List changed files run: wpiformat -list-changed-files + - name: Run clang-tidy run: wpiformat -no-format -tidy-all -compile-commands=build -tidy-extra-args std=c++20 -vv diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index a86b21d0..1286c611 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -29,13 +29,19 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install dependencies + - name: Install LLVM 17 run: | - sudo apt-get update -q - sudo apt-get install -y clang-15 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 all + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 200 + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV - name: Configure - run: cmake -B build -S . -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-15 ${{ matrix.cmake-flags }} -DBUILD_EXAMPLES=ON + run: cmake -B build -S . ${{ matrix.cmake-flags }} -DBUILD_EXAMPLES=ON - name: Build run: cmake --build build --target all --config RelWithDebInfo --parallel $(nproc)