Skip to content

change max GPU number #3

change max GPU number

change max GPU number #3

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: CI / Codebase Growth Guardrails
# pull_request_target runs in the base repo context, so this policy cannot be
# bypassed by editing workflow files or scripts in the PR. Keep this workflow
# data-only: do not check out or execute PR code. It only reads GitHub's
# file-level diff metadata.
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
permissions:
pull-requests: read
jobs:
codebase-growth-guardrails:
name: codebase-growth-guardrails
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require src/lib/onboard.ts to be net-neutral or smaller
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
TARGET_FILE: src/lib/onboard.ts
EXTRACTION_DIR: src/lib/onboard/
run: |
set -euo pipefail
# Intentionally hard-code TARGET_FILE in the jq expression. gh's jq
# filter does not accept shell variables directly, and missing
# previous_filename values must not match every file.
rows="$(gh api --paginate "/repos/${REPO}/pulls/${PR_NUMBER}/files" \
--jq '.[] | select(.filename == "src/lib/onboard.ts" or .previous_filename == "src/lib/onboard.ts") | [.additions, .deletions, .filename] | @tsv')"
if [ -z "$rows" ]; then
echo "${TARGET_FILE} was not changed. New modules under ${EXTRACTION_DIR} are allowed."
exit 0
fi
additions=0
deletions=0
while IFS=$'\t' read -r file_additions file_deletions _file_path; do
if [ -z "${file_additions:-}" ]; then
continue
fi
additions=$((additions + file_additions))
deletions=$((deletions + file_deletions))
done <<< "$rows"
net=$((additions - deletions))
echo "${TARGET_FILE}: +${additions}/-${deletions} (net ${net})"
echo "Growth under ${EXTRACTION_DIR} is allowed; this budget applies only to ${TARGET_FILE}."
if [ "$additions" -le "$deletions" ]; then
echo "PASS: ${TARGET_FILE} is net-neutral or smaller."
exit 0
fi
cat <<EOF
FAIL: ${TARGET_FILE} grew by ${net} line(s).
${TARGET_FILE} is already about 12k lines. Please move new logic into
focused modules under ${EXTRACTION_DIR}, or reduce ${TARGET_FILE} by at
least as many lines as this PR adds there.
This check allows src/lib/onboard/** to grow. It only blocks net growth
in the top-level onboard entrypoint.
EOF
exit 1
- name: Require Python code to be net-neutral or smaller
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
rows="$(gh api --paginate "/repos/${REPO}/pulls/${PR_NUMBER}/files" \
--jq '.[] | select((.filename | endswith(".py")) or ((.previous_filename // "") | endswith(".py"))) | [.additions, .deletions, .filename] | @tsv')"
if [ -z "$rows" ]; then
echo "No Python files were changed."
exit 0
fi
additions=0
deletions=0
while IFS=$'\t' read -r file_additions file_deletions _file_path; do
if [ -z "${file_additions:-}" ]; then
continue
fi
additions=$((additions + file_additions))
deletions=$((deletions + file_deletions))
done <<< "$rows"
net=$((additions - deletions))
echo "Python files: +${additions}/-${deletions} (net ${net})"
if [ "$additions" -le "$deletions" ]; then
echo "PASS: Python code is net-neutral or smaller."
exit 0
fi
cat <<EOF
FAIL: Python code grew by ${net} line(s).
Python code is under a no-growth budget. Please remove or migrate at
least as many Python lines as this PR adds.
EOF
exit 1
- name: Block added lines in legacy test/e2e suite
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
LEGACY_E2E_DIR: test/e2e/
SCENARIO_E2E_DIR: tests/e2e-scenario/
run: |
set -euo pipefail
rows="$(gh api --paginate "/repos/${REPO}/pulls/${PR_NUMBER}/files" \
--jq '.[] | select(.filename | startswith("test/e2e/")) | [.additions, .deletions, .filename] | @tsv')"
if [ -z "$rows" ]; then
echo "${LEGACY_E2E_DIR} was not changed. New E2E scenarios should go under ${SCENARIO_E2E_DIR}."
exit 0
fi
additions=0
deletions=0
while IFS=$'\t' read -r file_additions file_deletions _file_path; do
if [ -z "${file_additions:-}" ]; then
continue
fi
additions=$((additions + file_additions))
deletions=$((deletions + file_deletions))
done <<< "$rows"
echo "${LEGACY_E2E_DIR}: +${additions}/-${deletions}"
echo "New scenario-based E2E tests belong under ${SCENARIO_E2E_DIR}."
if [ "$additions" -eq 0 ]; then
echo "PASS: ${LEGACY_E2E_DIR} has no added lines. Deletions and moves out of the legacy suite are allowed."
exit 0
fi
cat <<EOF
FAIL: ${LEGACY_E2E_DIR} has ${additions} added line(s).
The legacy E2E suite is being migrated to scenario-based coverage.
Please add new E2E coverage under ${SCENARIO_E2E_DIR} instead.
This check allows ${SCENARIO_E2E_DIR} to grow. It blocks added lines
in the legacy ${LEGACY_E2E_DIR} suite while still allowing deletions.
EOF
exit 1