Skip to content

Add comprehensive GitHub Actions CI workflows #1

Add comprehensive GitHub Actions CI workflows

Add comprehensive GitHub Actions CI workflows #1

Workflow file for this run

name: Lint and Format
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
pre-commit:
name: Pre-commit Hooks
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang-format \
cmake \
cppcheck
- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install pre-commit
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
clang-format:
name: C++ Format Check
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check C++ formatting
run: |
# Find all C++ files and check formatting
find cpp/ ros/ -name "*.cpp" -o -name "*.hpp" -o -name "*.cc" -o -name "*.h" \
| grep -v "3rdparty" \
| grep -v "kdtree" \
| grep -v "tsl" \
| xargs clang-format --dry-run --Werror
cmake-format:
name: CMake Format Check
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install cmake-format
run: |
python -m pip install --upgrade pip
python -m pip install cmake-format
- name: Check CMake formatting
run: |
# Find all CMakeLists.txt files and .cmake files
find . -name "CMakeLists.txt" -o -name "*.cmake" \
| grep -v "3rdparty" \
| xargs cmake-format --check
python-lint:
name: Python Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python linting tools
run: |
python -m pip install --upgrade pip
python -m pip install \
black \
isort \
flake8 \
mypy
- name: Check Python formatting with black
run: |
find python/ -name "*.py" | xargs black --check --diff
- name: Check Python import sorting with isort
run: |
find python/ -name "*.py" | xargs isort --check-only --diff
- name: Lint Python code with flake8
run: |
find python/ -name "*.py" \
| grep -v "python/utils/download_datasets" \
| xargs flake8 --ignore=E501
cpp-lint:
name: C++ Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python (for cpplint)
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install cpplint
run: |
python -m pip install --upgrade pip
python -m pip install cpplint
- name: Lint C++ code
run: |
find cpp/ ros/ -name "*.cpp" -o -name "*.hpp" -o -name "*.cc" -o -name "*.h" \
| grep -v "3rdparty" \
| grep -v "kdtree" \
| grep -v "tsl" \
| grep -v "points" \
| xargs cpplint \
--filter=-whitespace/line_length,-legal/copyright,-build/include_order,-runtime/references,-build/c++11,-build/namespaces
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install mdformat
run: |
python -m pip install --upgrade pip
python -m pip install mdformat
- name: Check Markdown formatting
run: |
find . -name "*.md" \
| grep -v "github" \
| grep -v node_modules \
| xargs mdformat --check
yaml-lint:
name: YAML Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install yamllint
run: |
python -m pip install --upgrade pip
python -m pip install yamllint
- name: Lint YAML files
run: |
find . -name "*.yml" -o -name "*.yaml" \
| grep -v node_modules \
| xargs yamllint -d relaxed
# Optional: Check for security issues
security-check:
name: Security Check
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'