[ci] Address copilot review feedback on import-time check

- determine-jobs: trigger on changes to requirements_test.txt too; that
  file is hashed into the venv cache key and installed during
  restore-python, so a change there can alter the import environment.
- ci.yml: merge the --check and --har steps so we only run
  importtime-waterfall once per job (was measuring twice: ~7-8s of
  wasted CI time per run). Uses the new script/check_import_time.py
  --check --har <path> combination; the HAR reflects the same
  measurement that produced the pass/fail decision.
- script/check_import_time.py: refactor the CLI so --har is a standalone
  option rather than a mutually-exclusive mode. --check and --update
  each accept an optional --har PATH that writes the HAR from the same
  subprocess invocation. Plain --har is still supported for local use.
- tests: add tests/script/test_check_import_time.py covering HAR parsing,
  root lookup, offender ranking/dedup, budget round-trip, and the three
  --check exit paths (pass, regression, missing budget) plus the new
  --check --har combined write. Add requirements_test.txt case to the
  should_run_import_time parametrized test.
This commit is contained in:
J. Nick Koston
2026-04-23 14:47:03 -05:00
parent b8c6bd69c9
commit 99c80b7dfa
5 changed files with 222 additions and 21 deletions
+3 -7
View File
@@ -123,21 +123,17 @@ jobs:
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Check import time against budget
- name: Check import time against budget and write waterfall HAR
run: |
. venv/bin/activate
script/check_import_time.py --check
- name: Generate waterfall HAR
if: always()
run: |
. venv/bin/activate
script/check_import_time.py --har importtime.har
script/check_import_time.py --check --har importtime.har
- name: Upload waterfall HAR
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: import-time-waterfall
path: importtime.har
if-no-files-found: ignore
retention-days: 14
pytest: