Skip to content

Add cplint workflow support for minimal lint-only builds #5225

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1fc44c6
Skip PSATernaryTest on Ubuntu 22.04 and add Black formatting (#5209)
AkarshSahlot Apr 4, 2025
f20478b
Ad cplint workflow support for minimal lint-only builds
blackdragoon26 Apr 7, 2025
cb608ab
[Core] Fix namespace mismatch in irutils.h (#5220)
fruffy Apr 6, 2025
b0c2d57
[Tofino] Try to fix the dependency of mksizes in bf-asm CMake. (#5221)
fruffy Apr 7, 2025
89c7c0e
Replace proprietary notice and CC license on two test files with Apac…
jafingerhut Apr 7, 2025
1281422
Remove confidential & proprietary notices from Tofino testgen test pr…
jafingerhut Apr 7, 2025
4064318
Try to make exename portable. Refactor searchForIncludePath. (#5185)
fruffy Apr 8, 2025
c66bcba
Fixed P4C driver utility find_bin to return on first match (#5226)
psivanup Apr 9, 2025
14bfd3e
cpplint, clang,black , isort formatters should work now
blackdragoon26 Apr 10, 2025
33b94ec
setuptools version conflict handling for 61+
blackdragoon26 Apr 10, 2025
d2ec62b
explicitly upgrading setuptools in workflow
blackdragoon26 Apr 10, 2025
5c98f3d
resolving version conflict
blackdragoon26 Apr 11, 2025
3eac1d4
double quotation addition
blackdragoon26 Apr 11, 2025
5f2c9c9
debugging version incompatibility issue
blackdragoon26 Apr 11, 2025
2ac8dba
skip build isolation and ignore warnings from scapy in toml file
blackdragoon26 Apr 11, 2025
57fe1b7
strip_trailing_zero argument error
blackdragoon26 Apr 11, 2025
af5fb31
bash terminal in clang
blackdragoon26 Apr 11, 2025
b4488b6
bash terminal in clang again
blackdragoon26 Apr 11, 2025
89f3e8c
clang Command made it to POSIX safe variant
blackdragoon26 Apr 11, 2025
89fb471
Revert "clang Command made it to POSIX safe variant"
blackdragoon26 Apr 12, 2025
70fdca9
cmake changes
blackdragoon26 Apr 12, 2025
50a1447
improve SideEffects and StrengthReduction (#5229)
ChrisDodd Apr 11, 2025
d8d3c15
bash issue
blackdragoon26 Apr 12, 2025
eb2dae4
bash issue
blackdragoon26 Apr 12, 2025
2736314
bash issue
blackdragoon26 Apr 12, 2025
6d61ac8
changed the broken code in cmake
blackdragoon26 Apr 12, 2025
2bb9a9b
removed unwanted brackets
blackdragoon26 Apr 12, 2025
1a1630c
Merge branch 'main' into troubleshootingLint
blackdragoon26 Apr 12, 2025
3d56868
Merge branch 'main' into troubleshootingLint
blackdragoon26 Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,33 @@ jobs:
submodules: recursive
- uses: actions/setup-python@v5

- name: Upgrade pip + setuptools
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "setuptools>=65.5.0"
python3 -m pip install --upgrade "packaging==23.1"

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: apply-linters-${{ runner.os }}
max-size: 1000M

- name: Build (Ubuntu 22.04)
- name: Minimal Lint Setup
run: |
tools/ci-build.sh
sudo apt-get update
sudo apt-get install -y cmake g++ python3-pip clang-format
pip3 install --no-build-isolation --use-pep517 -r requirements.txt
mkdir -p build && cd build
cmake .. -DCMAKE_LINT_ONLY=ON

- name: Run cpplint on C/C++ files.
run: cmake --build build --target cpplint

- name: Run clang-format on C/C++ files.
run: cmake --build build --target clang-format
shell: bash
run: |
cmake --build build --target clang-format

- name: Run black and isort on Python files.
run: |
Expand Down
52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,58 @@ endif()

project (P4C)

# Minimal lint-only configuration
if (CMAKE_LINT_ONLY)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really what I have been looking for. This just copies what is already there in the Linters file but without all the options.

You should be able to pass linting with with cmake .. -DCMAKE_LINT_ONLY and also use the functions present in
https://github.com/p4lang/p4c/blob/main/cmake/Linters.cmake.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean you should make the changes in the back ends and around the checks that fail in CMake.

message(STATUS "CMAKE_LINT_ONLY=ON: Only configuring lint targets")

# add_custom_target(cpplint
# COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/cpplint.py
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# COMMENT "Running cpplint")
file(GLOB_RECURSE LINT_FILES
"${CMAKE_SOURCE_DIR}/*.cpp"
"${CMAKE_SOURCE_DIR}/*.h")

add_custom_target(cpplint
COMMAND find ${CMAKE_SOURCE_DIR} -name "*.cpp" -o -name "*.h" | xargs python3 ${CMAKE_SOURCE_DIR}/tools/cpplint.py || true
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running cpplint on all C++ source files using xargs")


# add_custom_target(clang-format
# COMMAND find ${CMAKE_SOURCE_DIR} -regex '.*\\(cpp\\|h\\)' -exec clang-format -i {} +
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# COMMENT "Running clang-format")
add_custom_target(clang-format
COMMAND /bin/sh -c find \"${CMAKE_SOURCE_DIR}\" -type f -name '*.cpp' -o -name '*.h' -exec clang-format -i {} + || true
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running clang-format on all C/C++ files")
# add_custom_target(black
# COMMAND black .
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# COMMENT "Running black on Python files")

add_custom_target(black
COMMAND black . || true
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running black on all Python files")

# add_custom_target(isort
# COMMAND isort .
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# COMMENT "Running isort on Python files")

add_custom_target(isort
COMMAND isort . || true
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running isort on Python files")


return()
endif()



# set (CMAKE_CXX_EXTENSIONS OFF) # prefer using -std=c++17 rather than -std=gnu++17
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
Loading