Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify minor/patch version for clang-format #292

Open
Alexolut opened this issue Mar 5, 2025 · 4 comments
Open

Allow to specify minor/patch version for clang-format #292

Alexolut opened this issue Mar 5, 2025 · 4 comments

Comments

@Alexolut
Copy link

Alexolut commented Mar 5, 2025

Is your idea related to an existing feature?

version

Describe the behavior you would like

First of all I'm not sure that my request can be solved from cpp-linter side, but I hope it may.

When I use Github runner ubuntu-22.04 and set version: '18' for cpp-linter, then during linter run version 18.1.8 is installed because there is no installed clang-format-18 on that image.

E: Unable to locate package clang-format-18
...
++ PRETTY_NAME='Ubuntu 22.04.5 LTS'
...
Get:1 https://apt.llvm.org/jammy llvm-toolchain-jammy-18/main amd64 clang-format-18 amd64 1:18.1.8~... 

At the same time if I use ubuntu-24.04 (currently -latest) I got preinstalled clang-format 18.1.3.

clang-format-18 is already the newest version (1:18.1.3-1ubuntu1).
...
Found a installed version of clang-format: 18.1.3 at /usr/lib/llvm-18/bin/clang-format

Is there a way to use 18.1.8 for ubuntu-24.04 runner as well using only cpp-linter-action settings?

It looks weird that we have old clang-format version for new ubuntu, and new clang-format for old ubuntu.

Describe alternatives you have considered

No response

Additional context

No response

@2bndy5
Copy link
Collaborator

2bndy5 commented Mar 5, 2025

If you install the version that you want to use before running cpp-linter, then it should use that version as long as the major version number matches the version input to cpp-linter.

I'm not sure if we can support this request. On Linux runners, we use the official installer script from LLVM which uses apt to install clang tools from their PPA repo. If you can specify a minor version when installing clang tools via apt, then it should be possible, but this has not been my experience.

@2bndy5
Copy link
Collaborator

2bndy5 commented Mar 5, 2025

I think your problem might be solved by simply running

sudo apt-get update
sudo apt-get install clang-format-18

before running cpp-linter.

@Alexolut
Copy link
Author

Alexolut commented Mar 6, 2025

update and install pair didn't help. See linked thread I started for github-runners

@2bndy5
Copy link
Collaborator

2bndy5 commented Mar 6, 2025

It seems a regression (specific to building bpftrace) was discovered using LLVM v18.1.8 (see tickets 2097317 and 2081848) which prompted the build to be removed from the Ubuntu PPA repo containing the LLVM v18 toolchain.

I doubt GitHub actions will update their image for the same reason. I sincerely hope I'm wrong though.


Alternatively, you can install the latest v18 using the same LLVM install script we use.

VERSION=18
wget https://apt.llvm.org/llvm.sh -O ${{ runner.temp }}/llvm_install.sh
chmod +x ${{ runner.temp }}/llvm_install.sh
if sudo ${{ runner.temp }}/llvm_install.sh $VERSION; then
  sudo apt-get install -y clang-format-$VERSION clang-tidy-$VERSION
  # for compatibility with cpp-linter-action, we must remove the added PPA
  sudo rm /etc/apt/sources.list.d/*llvm*.list
fi

And then run cpp-linter-action after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants