* ci: test only changes that can affect code (#639) Each gating workflow starts with a change class job that sorts the pull request, merge group or push by the files it touches (tools/ci/change_class.py): inert (nothing reads them), docs (a Python test reads them) or code (anything else and every case of doubt). - inert: only the classifier and the two gates do work. The required py3.12 leg starts and skips its steps, because a skipped matrix job would never report that context. - docs: the Python 3.12 suite runs as well; it holds the README tests. - code: everything runs, as before. The gates require the classifier to succeed and every job to do what the class asks; an unknown class fails them. bandit has no gate, so it runs unless the class is docs or inert. The required contexts are unchanged. The pre-push hook skips the suite for an inert push. * test(ci): keep the classifier tests out of a git hook's repository (#639) Inside the pre-push hook git exports GIT_DIR and GIT_INDEX_FILE for the repository being pushed. The test's own git calls inherited them and so ran git init, add and commit against that repository instead of their temp one. They now drop every GIT_ variable, and the tests run with those variables pointing at another repository that must stay absent. * test(ci): import unittest.mock one way * fix(ci): find the pre-push command through PATH before running it The pre-push wrapper ran its command with subprocess and a bare name. On Windows the frontend hook's npm is npm.cmd, which subprocess does not find without a PATH and PATHEXT lookup, so every non-inert push failed with FileNotFoundError (Codex review). The wrapper now resolves the program with shutil.which first, and says so when it is missing. Reproduced and verified on Windows 11: before, FileNotFoundError; after, npm --version runs. * test(inspect): keep trying until a video is seen still starting at loadstart (#641) A busy WebKit fired the viewer video's loadstart after it already had HAVE_ENOUGH_DATA (merge-queue run 43732282629, readyState 4), so the per-attempt readyState === 0 assertion failed although the settled path behaved correctly. The three #483 tests now count the attempts that saw the video still starting, run up to twice as many pages until one does, and fail only if none did.
72 lines
2.9 KiB
YAML
72 lines
2.9 KiB
YAML
name: Code Quality
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
merge_group:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
# Superseded PR pushes cancel their older run. Every main push gets its own
|
|
# group (run_id), so no main commit's run is ever cancelled or dropped as pending.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
# Sorts the change by the files it touches (tools/ci/change_class.py, #639): "inert" (nothing reads
|
|
# them), "docs" (a Python test reads them) or "code" (anything else, and every case of doubt). The
|
|
# jobs below skip what the class cannot affect. A job skipped by its condition reports Success, so
|
|
# the required context still reports. This workflow has no gate job, so the scan runs whenever the
|
|
# class is not "docs" or "inert": a classifier that fails or prints nothing means a full scan. The clone has every commit but no file contents (blob:none): the
|
|
# script only compares file names between the base and the head.
|
|
changes:
|
|
name: change class
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
class: ${{ steps.classify.outputs.class }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
filter: blob:none
|
|
persist-credentials: false
|
|
- name: Classify the changed files
|
|
id: classify
|
|
env:
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
|
|
run: python3 tools/ci/change_class.py | tee -a "$GITHUB_OUTPUT"
|
|
|
|
security:
|
|
name: bandit (high severity)
|
|
needs: changes
|
|
if: ${{ !cancelled() && needs.changes.outputs.class != 'docs' && needs.changes.outputs.class != 'inert' }}
|
|
runs-on: ubuntu-latest
|
|
# ceil(1.5 x slowest of three green main runs) + 3, never under 5 (test.yml): runs 40257217665,
|
|
# 40254137380, 40240706583 took 23s / 16s / 23s -> 5 min. change class (#639): 5 min, the floor.
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v7
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install bandit
|
|
run: pip install bandit[toml]
|
|
|
|
# Medium findings are reported without failing until they are triaged.
|
|
# High severity is a hard gate.
|
|
- name: Security report (medium and above, informational)
|
|
run: bandit -r . -ll -q --exclude ./tests,./reference,./venv,./tools/vendor/node_modules --exit-zero
|
|
- name: Security scan (high severity gate)
|
|
run: bandit -r . -lll -q --exclude ./tests,./reference,./venv,./tools/vendor/node_modules
|