Skip to content

Commit

Permalink
Use LLVM 17 for coverage, clang-tidy, and sanitizers (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Apr 2, 2024
1 parent cf07da2 commit 9334dbd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
14 changes: 10 additions & 4 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9334dbd

Please sign in to comment.