Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ on:

jobs:
pre-commit:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get modified files
id: modified-files
run: echo "modified_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/setup-python@v4
with:
extra_args: --files ${{ steps.modified-files.outputs.modified_files }}
python-version: "3.10"
- name: Install dependencies
run: |
make setup-venv
make setup-mkinit
- uses: pre-commit/action@v3.0.1
with:
extra_args: --files ${{ steps.modified-files.outputs.modified_files }}
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

.PHONY: ruff lint ruff-fix lint-fix format fmt check-format check-fmt \
test coverage clean install docker docker-run first-time-setup \
test-verbose init-files \
test-verbose init-files setup-venv setup-mkinit \
internal-help help


Expand Down Expand Up @@ -134,7 +134,7 @@ clean: #? clean up the pytest and ruff caches, coverage reports, and *.pyc files
find . -type f -name ".coverage" -delete
rm -rf htmlcov/

first-time-setup: #? convenience command to setup the environment for the first time
setup-venv: #? create the virtual environment.
@# Install uv if it is not installed
@export PATH=$(UV_PATH):$(PATH) && \
if ! command -v uv &> /dev/null; then \
Expand All @@ -153,6 +153,12 @@ first-time-setup: #? convenience command to setup the environment for the first
printf "$(bold)$(green)Virtual environment already exists$(reset)\n"; \
fi

setup-mkinit: #? install the mkinit package.
$(activate_venv) && uv pip install mkinit

first-time-setup: #? convenience command to setup the environment for the first time
$(MAKE) setup-venv --no-print-directory

@# Install the project
@printf "$(bold)$(green)Installing project...$(reset)\n"
@PATH=$(UV_PATH):$(PATH) $(MAKE) --no-print-directory install
Expand Down
6 changes: 6 additions & 0 deletions tools/generate_init_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

VENV_PATH="${VENV_PATH:-.venv}"
ACTIVATE_VENV="${VENV_PATH}/bin/activate"
if [ -f "${ACTIVATE_VENV}" ]; then
source "${ACTIVATE_VENV}"
fi

mkinit --write --black --nomods --recursive aiperf
# Ruff check and fix just the __init__.py files, because mkinit sometimes
# doesn't sort the imports correctly, causing infinite error loops.
Expand Down