Skip to content

Commit

Permalink
Merge pull request #12 from liwuhen/feat-dev
Browse files Browse the repository at this point in the history
chore: add pre-commit action
  • Loading branch information
liwuhen authored Nov 21, 2024
2 parents 1225620 + 8834cf9 commit 8c952b4
Show file tree
Hide file tree
Showing 82 changed files with 3,261 additions and 3,095 deletions.
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Run the following command to reformat a file:
# clang-format -i -style=Google <file>
# Or use clang-format-diff to only reformat the changed lines:
# https://clang.llvm.org/docs/ClangFormat.html
BasedOnStyle: Google
DerivePointerAlignment: false
ColumnLimit: 100
PointerAlignment: Left
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ int main(int argc, char* argv[]) {
A clear and concise description of what you expected to happen.
### Additional Notes
Add your thoughts about the problem and the code (if you wish)
Add your thoughts about the problem and the code (if you wish)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ The [x] notation can be used to indicate compliance with the selection.
- [ ] I have applied the code style updates using make codestyle.
- [ ] I have authored tests for any new methods and classes.
- [ ] I have documented all utilized methods and classes in Google style docstrings.
- [ ] New and existing unit tests pass locally with my changes
- [ ] New and existing unit tests pass locally with my changes
28 changes: 28 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

name: Format

on:
pull_request:
branches: ["main"]
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read

jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.1
with:
# Slow hooks are marked with manual - slow is okay here, run them too
extra_args: --hook-stage manual --all-file
8 changes: 4 additions & 4 deletions .github/workflows/git_pages.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Generate and publish docs

on:
on:
pull_request:
branches: ["main"]
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v5.0.0 # v5.0.0
with:
enablement: true #
enablement: true #
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4.0.5 # v4.0.5
uses: actions/deploy-pages@v4.0.5 # v4.0.5
54 changes: 54 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

name: Lint

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

permissions: # set top-level default permissions as security best practice
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true

jobs:
optional-lint:
name: Optional Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2 # v4.2.2
- name: misspell # Check spellings as well
uses: reviewdog/action-misspell@v1.23.0 # v1.23.0
with:
github_token: ${{ secrets.github_token }}
locale: "US"
reporter: github-pr-check
level: info
filter_mode: diff_context
exclude: |
./docs/hpcdoc/source/_static/*
- name: shellcheck # Static check shell scripts
uses: reviewdog/action-shellcheck@v1.27.0 # v1.27.0
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
filter_mode: diff_context
- name: cpplint # Static check C++ code
uses: reviewdog/action-cpplint@v1.8.0 # v1.8.0
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
flags: --linelength=120
filter: "-runtime/references,\
-build/include,\
-build/namespaces,\
-build/header_guard,\
-whitespace/line_length,\
-whitespace/indent_namespace,\
-runtime/string" # Ignore runtime checks on string usage.
115 changes: 115 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Pre-commit hook
# See documentation at: https://pre-commit.com/
#
# Pre-commit hook to run the sanity checks from Jenkins locally.
#
# Requirements:
# - How to configure:
# - $ pip install pre-commit
# - $ pre-commit install --hook-type pre-push
# - How to prevent running it:
# - git options: --no-verify or -n
# - $ git commit -n -m "YOUR COMMIT MESSAGE"
# - How to run it as standalone
# - $ pre-commit run
#

ci:
autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: monthly

repos:

# # Clang format the codebase automatically
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: "v14.0.6"
# hooks:
# - id: clang-format
# types_or: [c++, c, cuda]

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.2"
hooks:
- id: mypy
args: []
exclude: ^(tests|docs)/
additional_dependencies:
- markdown-it-py
- nox
- rich
- types-setuptools

# CMake formatting
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$

# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

# Also code format the docs
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.*

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: "v1.5.5"
hooks:
- id: remove-tabs

# Avoid directional quotes
- repo: https://github.com/sirosen/texthooks
rev: "0.6.7"
hooks:
- id: fix-ligatures
- id: fix-smartquotes

# Checking for common mistakes
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Check for spelling
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
- repo: https://github.com/codespell-project/codespell
rev: "v2.1.0"
hooks:
- id: codespell
exclude: "docs/hpcdoc/source/_static"
args: ["-Lccompiler,intstruct"]

# Check schemas on some of our YAML files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
hooks:
- id: check-readthedocs
- id: check-github-workflows
- id: check-dependabot
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
}
],
"version": 4
}
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
// "preLaunchTask": "ReBuild"
}
]
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@
"slist": "cpp",
"*.in": "cpp"
}
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"args": ["-g", "-G", "-o0", "${workspaceFolder}/src/main.cpp", "${file}"]
}
]
}
}
30 changes: 14 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
cmake_minimum_required(VERSION 3.10.2)

option(ENABLE_CROSSCOMPILE "Enable crosscomplile for arm platform" OFF)
option(MODEL_FLAG "Enable crosscomplile model type")
set(MODEL_FLAG
"default"
CACHE STRING "Model configuration flag")

add_definitions("-Wall -g")
add_compile_options(-std=c++11)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR})

include(${CMAKE_CURRENT_LIST_DIR}/cmake/third_library.cmake)

if(${ENABLE_CROSSCOMPILE})
include(${CMAKE_PATH}/platforms/linux/arm-toolchain.cmake)
include(${CMAKE_PATH}/platforms/linux/arm-toolchain.cmake)
endif()

configure_file(
"${CMAKE_CURRENT_LIST_DIR}/modules/common/utils/std_cmake.h.in"
"${CMAKE_CURRENT_LIST_DIR}/modules/common/utils/std_cmake.h"
)

configure_file("${CMAKE_CURRENT_LIST_DIR}/modules/common/utils/std_cmake.h.in"
"${CMAKE_CURRENT_LIST_DIR}/modules/common/utils/std_cmake.h")

include_directories(
${CMAKE_CURRENT_LIST_DIR}/modules
${CMAKE_CURRENT_LIST_DIR}/modules/app_yolo
${CMAKE_CURRENT_LIST_DIR}/modules/common/utils
${CMAKE_CURRENT_LIST_DIR}/modules/common/logging
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_img
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_enum
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_struct
)
${CMAKE_CURRENT_LIST_DIR}/modules
${CMAKE_CURRENT_LIST_DIR}/modules/app_yolo
${CMAKE_CURRENT_LIST_DIR}/modules/common/utils
${CMAKE_CURRENT_LIST_DIR}/modules/common/logging
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_img
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_enum
${CMAKE_CURRENT_LIST_DIR}/modules/common/msg_struct)

add_subdirectory(modules/app_yolo)
add_subdirectory(test/${MODEL_FLAG})
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Contributing
Welcome to participate in this project, the project aims to build a high-performance model inference library, welcome all kinds of contributions, the main ways to contribute are as follows:
Welcome to participate in this project, the project aims to build a high-performance model inference library, welcome all kinds of contributions, the main ways to contribute are as follows:

- **Fix Bug**: If you find any bugs or issues, please report them by opening an issue in the repository.
- **Feature Request**: If you have any suggestions or ideas for new features, please submit them by opening an issue in the repository.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ APPENDIX: How to apply the Apache License to your work
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.
permissions and limitations under the License.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ docker run -it --gpus all --network host --privileged --cap-add=SYS_PTRACE --se
# ![project](https://img.shields.io/badge/How%20to%20build-project-brightgreen) Building Project
## 1. Setup Environment
### Shell Example: X86
```shell
```shell
# Setting up your computer's cuda and tensorrt environment -- x86 version
set(CUDA_TOOLKIT_ROOT_DIR "/usr/local/cuda-11.4/targets/x86_64-linux")
set(TENSORRT_DIR "/home/x86_toolchain/tensorrt")
Expand All @@ -68,12 +68,12 @@ set(TENSORRT_DIR "/home/aarch64_toolchain/tensorrt")
Shell scripts provide optional platforms.

- Available platform parameters are as follows:
|NVIDIA|QNN|
|NVIDIA|QNN|
|:-:|:-:|
- Available model parameters are as follows:
|yolov5|yolox|
- Available model parameters are as follows:
|yolov5|yolox|
|:-:|:-:|
- Available parameters are as follows:
- Available parameters are as follows:
1) **-a | -all | all**. Compile all modules
2) **-clean**. Clear compiled files
3) **-arm**. Enable cross-compilation mode
Expand All @@ -95,8 +95,8 @@ bash ./scripts/build.sh yolov5 nvidia -arm -pack -clean

```shell
#!/bin/bash
- x86
bash ./install_nvidia/run.sh yolov5 nvidia
- x86
bash ./install_nvidia/run.sh yolov5 nvidia

- arm
bash ./install_nvidia/run.sh yolov5 nvidia -arm
Expand All @@ -110,4 +110,4 @@ Welcome users to participate in these projects. Please refer to [CONTRIBUTING.md
- [Yolov5](https://github.com/ultralytics/yolov5)
- [Yolox](https://github.com/Megvii-BaseDetection/YOLOX)

- **Blog**[Setup Environment](https://zhuanlan.zhihu.com/p/818205320)
- **Blog**[Setup Environment](https://zhuanlan.zhihu.com/p/818205320)
Loading

0 comments on commit 8c952b4

Please sign in to comment.