59a0a3844c
PR Test AMD / cancel-on-close (push) Has been skipped
PR Test NVIDIA ARM / scan (push) Has been skipped
PR Test NVIDIA / cancel-on-close (push) Has been skipped
PR Test AMD / scan (push) Has been skipped
PR Test NVIDIA ARM / cancel-on-close (push) Has been skipped
PR Test NVIDIA / scan (push) Has been skipped
Release Docker Images / build (cu129-torch-2.11.0) (push) Has been skipped
Release Docker Images / build (cu130-torch-2.11.0) (push) Has been skipped
Release PyPI / publish (push) Has been skipped
Scheduler Python Test / test (push) Successful in 27m19s
Docs / build (push) Successful in 28m8s
Scheduler C++ Test / test (push) Successful in 28m19s
Scheduler C++ Test / test-flat (push) Successful in 28m18s
Docs / deploy (push) Has been cancelled
PR Test AMD / finish (push) Has been cancelled
PR Test NVIDIA / finish (push) Has been cancelled
PR Test NVIDIA ARM / finish (push) Has been cancelled
PR Test NVIDIA ARM / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test AMD / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test NVIDIA / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
95 lines
3.4 KiB
YAML
95 lines
3.4 KiB
YAML
name: Lint
|
|
|
|
on: [pull_request]
|
|
|
|
concurrency:
|
|
group: lint-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install pre-commit hook
|
|
run: |
|
|
python -m pip install pre-commit ruff "nanobind>=2.13.0" tokenspeed-spdlog==1.15.1
|
|
pre-commit install
|
|
|
|
- name: Linting
|
|
run: pre-commit run --all-files
|
|
|
|
- name: Lint runtime Python with ruff
|
|
run: |
|
|
python -m ruff check \
|
|
--select F401,F841,F821,F823,F811,F541,UP035,UP006,UP007,UP045 \
|
|
python/tokenspeed/runtime
|
|
|
|
- name: Install scheduler C++ lint tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y clang-format clang-tidy cmake ninja-build
|
|
|
|
- name: Configure scheduler compile database
|
|
run: |
|
|
cmake -S tokenspeed-scheduler -B tokenspeed-scheduler/build \
|
|
-G Ninja \
|
|
-DTOKENSPEED_SCHEDULER_BUILD_TESTS=ON \
|
|
-DTOKENSPEED_SCHEDULER_BUILD_PYTHON=ON \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
- name: Lint scheduler Python and file starts
|
|
run: |
|
|
python -m ruff check tokenspeed-scheduler
|
|
python - <<'PY'
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
suffixes = {".py", ".c", ".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx"}
|
|
files = subprocess.check_output(["git", "ls-files", "tokenspeed-scheduler"], text=True).splitlines()
|
|
blank_starts = []
|
|
relative_imports = []
|
|
for name in files:
|
|
path = Path(name)
|
|
if path.suffix in suffixes and path.read_bytes().startswith((b"\n", b"\r\n")):
|
|
blank_starts.append(name)
|
|
if path.suffix == ".py":
|
|
for line_no, line in enumerate(path.read_text().splitlines(), 1):
|
|
if line.startswith(("from .", "import .")):
|
|
relative_imports.append(f"{name}:{line_no}: {line}")
|
|
|
|
errors = []
|
|
if blank_starts:
|
|
errors.append("files must not start with a blank line:\n" + "\n".join(blank_starts))
|
|
if relative_imports:
|
|
errors.append("scheduler Python must use absolute imports:\n" + "\n".join(relative_imports))
|
|
if errors:
|
|
raise SystemExit("\n\n".join(errors))
|
|
PY
|
|
|
|
- name: Lint scheduler C++
|
|
run: |
|
|
cpp_files="$(git ls-files tokenspeed-scheduler | grep -E '\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$')"
|
|
jobs="$(nproc)"
|
|
tidy_files="$(printf '%s\n' "$cpp_files" | grep -E '\.(c|cc|cpp|cxx)$' || true)"
|
|
format_count="$(printf '%s\n' "$cpp_files" | sed '/^$/d' | wc -l)"
|
|
tidy_count="$(printf '%s\n' "$tidy_files" | sed '/^$/d' | wc -l)"
|
|
|
|
echo "Running clang-format on ${format_count} files with ${jobs} workers"
|
|
printf '%s\n' "$cpp_files" | xargs -r -n 16 -P "$jobs" sh -c '
|
|
echo "clang-format: $*"
|
|
clang-format --dry-run --Werror "$@"
|
|
' sh
|
|
|
|
echo "Running clang-tidy on ${tidy_count} translation units with ${jobs} workers"
|
|
printf '%s\n' "$tidy_files" | xargs -r -n 1 -P "$jobs" sh -c '
|
|
echo "clang-tidy: $1"
|
|
clang-tidy -p tokenspeed-scheduler/build "$1"
|
|
' sh
|