Skip to content

Add the Eaton EMA325-10 managed rack PDU #3589

Add the Eaton EMA325-10 managed rack PDU

Add the Eaton EMA325-10 managed rack PDU #3589

Workflow file for this run

# The gates, on every pull request - because the failure that prompted this
# could only appear AFTER a merge.
#
# #100 gave the Dell R740xd its rear face and, with it, two PSU bays. #101 added
# a library-wide test asserting every multi-bay power group states its
# redundancy. Both were correct in isolation, neither branch could see the
# other, and main went red the moment the two landed within minutes of each
# other. Nothing was wrong with either change; the pair had simply never been
# run together, because nothing ran them together until somebody did it by hand.
name: gates
on:
# A DRAFT GETS LINT, NOT THE SUITE. Every push to a draft used to run the full
# build and four shards - 95 runs and about 1,620 runner-minutes in the two days
# after 2026-10-05, a fifth of them cancelled by the next push - for a branch
# nobody could merge. `dist`, `tests` and `build` skip on a draft; `lint` still
# answers in two minutes. `ready_for_review` is listed because it is NOT among
# the default types, and without it marking a draft ready would start nothing:
# the suite would wait for the next push.
#
# `labeled` IS HOW A PULL REQUEST GETS ITS FULL RUN. A push runs the light
# tier (see THE TWO TIERS, below), whose verdict is not the required `build`;
# the `full-gates` label makes this and every later run on the pull request
# the whole suite, and before a merge that is what lands `build`
# (docs/merging.md). It has to be a pull request event: GitHub leaves a
# dispatched run out of a pull request's checks. On #1398 a dispatch passed
# `build` on the head (966146dea) and the pull request stayed blocked on it,
# still "expected", while the commit's own check list showed it green. Any
# other label starts a run too, of the tier the labels make; pull requests
# here carry none (not one on the last hundred), so that costs nothing.
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
push:
branches: [main]
# A FULL RUN ON A BRANCH, ON REQUEST: the merge train's (.github/merge-train.py)
# and, on main, the button for the day somebody wants the whole thing. NOT A
# PULL REQUEST'S: its checks never reach one (`labeled`, above).
workflow_dispatch:
# THE WHOLE SUITE ON MAIN EVERY NIGHT. Every merge had its own full run, but
# not on the tree two merges made together, and a runner image or a
# dependency can move under a tree that did not. Off the hour, as GitHub asks.
schedule:
- cron: '17 8 * * *'
# NO `paths-ignore`, AND THAT IS A DECISION (#183). The obvious saving is to
# skip the run on a docs-only diff, and this repository cannot: four files under
# docs/ are asserted by tests - `lint-rules.md` against the linter's own rule
# table, `modelling-a-device.md`, `optical-paths-design.md` and
# `what-a-configuration-cannot-say.md` - plus DESIGN.md and the changelog
# fragments under changelog.d/. (The component CATALOGUE.md was one of them;
# the build writes it now and it is not committed.)
# A "docs-only" change is one of the ways this suite most easily goes red, so
# filtering it out would turn the cheapest failure into the one nobody catches.
# The saving is bought instead where it helps every run: a pip cache, a lint job
# that fails in half a minute, and one lint per run instead of three.
# READ-ONLY, AND PINNED BY SHA (#456). Neither job writes anything back - no
# comment, no status beyond its own, no push - so the token gets `contents: read`
# and nothing else, whatever the repository default happens to be. (`build` adds
# two more READS for itself, to find the run it compares its test times with.) Once this
# repository is public, a pull request from a fork runs this file; a tag like
# `@v4` is a pointer its owner can move, a commit SHA is not. The comment beside
# each pin says which release it is, so a bump is a deliberate edit.
permissions:
contents: read
# A second push to a PR makes the first run pointless - it is testing a tree
# nobody will merge.
#
# A DRAFT RUN AND A READY RUN NEVER CANCEL EACH OTHER: draft status is part of
# the group. Without it, a push and "ready for review" a second apart started
# two runs on one head, and the push's - whose payload still said draft -
# cancelled the ready one and ran lint alone. Its skipped `build` was then the
# only `build` on the head, and branch protection reads a skipped required check
# as passing: the pull request was mergeable on lint (#867). Keyed by draft, the
# ready run always finishes and lands a real `build`; a later push to the ready
# pull request still cancels it, as before.
#
# THE EVENT IS IN THE GROUP TOO, so the nightly and a dispatch on main are not
# cancelled by the next merge's push to main, which only lints. Two dispatches
# on one branch still share a group: the second is the head that will merge.
concurrency:
group: gates-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-${{ github.event.pull_request.draft == true }}
cancel-in-progress: true
# WHERE THE JOBS RUN IS A REPOSITORY VARIABLE, NOT THIS FILE. While the
# repository is private, `GATES_RUNNER` names the label of a self-hosted pool
# (`portrayal-ci`) with six times the cores of a hosted runner; the suite is the
# long pole of every run and it scales with them. Unset the variable and both
# jobs are back on `ubuntu-latest` with no edit here - which is the step for
# going public, and the fallback if the machine is down.
#
# THE TEST BELOW IS NOT WHAT KEEPS A STRANGER OFF THE POOL (#656). A pull
# request runs the workflow file from ITS OWN tree, so a fork can delete this
# expression and write `runs-on: portrayal-ci` directly. The only protection is
# that no self-hosted runner is registered while the repository is public:
# deregister every runner AND delete GATES_RUNNER before the visibility flip,
# not after it (#457, step 0). What the test does is keep an honest pull request
# from another repository - including one whose fork was deleted, where
# `head.repo` is null and the old `head.repo.fork` test fell through - off the
# pool if a runner is ever registered again.
#
# WHAT A HOSTED RUNNER GAVE FOR FREE, THIS FILE NOW ASKS FOR: the self-hosted
# user has no sudo, so apt installs only what is missing; and several runners
# share one /tmp, so the pytest log lives under the job's own RUNNER_TEMP.
jobs:
# LINT ON ITS OWN. It is the fastest gate and the one whose failure is most
# often the whole story, so it answers in well under a minute instead of
# behind a render log.
#
# `build` NO LONGER WAITS ON IT, and that is a trade. With `needs: lint` a run
# joined the runner queue twice - once for lint, then again for build - and on
# a busy pool of three the second wait was up to fifteen minutes (#573, the
# night of 2026-09-24), longer than the build itself. Now both jobs queue at
# once. What a broken manifest costs is a build run that was going to fail
# anyway; what lint GATING buys is unchanged, because the gate is the merge:
# branch protection requires `lint`, and the merge train (.github/merge-train.py)
# refuses a head with any check-run that did not succeed, lint among them.
lint:
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest') || vars.GATES_RUNNER || 'ubuntu-latest' }}
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
# ONLY WHAT LINT IMPORTS, which is the point of this job existing. The
# suite's extra pulls numpy and pillow - tens of megabytes of wheel for a
# job that reads YAML and validates it against a schema, and on a cold
# cache that is most of the "fast" gone.
#
# `pip install -e .` IS THAT LIST NOW: pyproject's `dependencies` are
# pyyaml and jsonschema and nothing else, so this stays seconds long and
# the two names stop being duplicated in a YAML step (#178). The editable
# install is also what makes `import portrayal` resolve, which every tool
# now needs.
- run: pip install -e .
- name: lint
run: python3 spec/tools/portrayal/lint.py --schemas spec/schemas --library library
# A LOCK THAT MOVED NEEDS A VERSION THAT MOVED, AGAINST THE BASE. The
# `devicelock` step in `dist` compares each lock with the device as it is
# now, and after `devicelock.py --update` the two always agree: a branch
# that re-recorded a lock and left `version:` where the base had it
# passed it. This step puts the base's lock beside the branch's.
#
# THE BASE IS THE CHECKED-OUT COMMIT'S FIRST PARENT, not the event's
# `base.sha`. On a pull request the checkout is the merge of the head
# into the base's tip and holds only that one commit, whose text names
# its parents. The first parent is the base the merged tree was built
# on, so it stays right when the base moves between two pushes; `base.sha`
# is the tip when the event fired, and a pull request that is behind would
# then show the base's own newer locks as its own. The commit alone is
# fetched (one commit, `contents: read`), and a tree diff between two
# commits needs no history.
#
# ONLY A PULL REQUEST HAS A BASE. A push, a dispatch and the nightly say
# so and pass.
- name: devicelock against the base
env:
EVENT: ${{ github.event_name }}
run: |
if [ "$EVENT" != "pull_request" ]; then
echo "devicelock against the base: skipped, a $EVENT has no base to compare with"
exit 0
fi
base=$(git cat-file -p HEAD | sed -n '/^parent /{s///p;q}')
if [ -z "$base" ]; then
echo "devicelock against the base: HEAD is not a merge commit, so the base is unknown"
exit 1
fi
git fetch --no-tags --depth=1 origin "$base"
python3 spec/tools/portrayal/devicelock.py --library library --base "$base"
# THE BUILD IS THREE JOBS NOW, AND `build` IS STILL THE ONE THAT ANSWERS.
# `dist` builds and publishes once; four `tests` jobs each run a quarter of
# the suite against that build; `build` reads all four and is the check that
# branch protection requires, by that exact name. A required check that is
# renamed is one that never reports, and the merge waits for ever.
#
# WHY SPLIT. The suite was the long pole: on a hosted runner 1,103s of a
# 24-minute run, after a 312s build. Merges are serial, so every minute of it
# was a minute of queue for the next pull request. The repository is public
# and hosted minutes cost it nothing, so four runners do it side by side.
#
# NOT ON A PUSH TO MAIN, any of the three. A merge lands a head whose full run
# passed, so `--merge` gives main a tree that was built and tested - and the
# build on the push re-ran twenty minutes of work on a known answer. Lint still
# runs on the push (a minute); the nightly and `workflow_dispatch` run the rest.
#
# THE TWO TIERS. A same-repository pull request push runs the LIGHT tier:
# `-m "not heavy"` on two shards, every test but the few hundred functions a
# full run measured at five seconds or more (`heavy`, spec/tools/dev/
# mark_heavy.py), in about a fifth of the suite's seconds. Its verdict is
# called `light suite`. Everything else - a pull request labelled
# `full-gates`, a fork's pull request, a dispatch, the nightly - is a FULL
# run on four shards, and only its verdict is called `build`. A head
# therefore has the required check only once the whole suite has passed on
# it, and the merge waits for that rather than for anybody remembering to
# ask. Both tiers answer to
# spec/test-budget.json. `dist` decides the tier, once, for the jobs after it.
dist:
if: github.event_name != 'push' && !github.event.pull_request.draft
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest') || vars.GATES_RUNNER || 'ubuntu-latest' }}
timeout-minutes: 20
# STILL NOTHING WRITTEN. The two extra reads find an earlier run: which pull
# requests merged, and the test times the newest of them published - read
# here to balance the shards, and by `build` to compare against.
permissions:
contents: read
actions: read
pull-requests: read
outputs:
tier: ${{ steps.tier.outputs.tier }}
steps:
# FIRST, so the tier is set whatever fails after it. A light verdict can
# never be called `build`; an empty tier reads as light.
- name: tier
id: tier
run: echo "tier=${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository || contains(github.event.pull_request.labels.*.name, 'full-gates')) && 'full' || 'light' }}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
# NODE FOR THE KIT CHECK BELOW. The suite's own node is installed where
# the suite runs, in `tests`.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
# THE `test` EXTRA, which is the same list spec/requirements-ci.txt held and
# in the one place a tool looks for it. Editable, so `import portrayal`
# resolves for the tools the shell scripts run by path.
- run: pip install -e ".[test]"
# BUILD BEFORE PYTEST, AND THIS ORDER IS THE POINT. Four test modules -
# behaviour, config-scope, viewbox, state-css - skip themselves when
# library/dist is missing, and dist is gitignored so a fresh checkout has
# none. A run that tests before building reports 532 passed / 509 skipped
# and looks green. That happened once, on a branch that changed 14
# devices, and none of the rendering was exercised. The shards cannot
# start until this job has handed them its build, below.
#
# publish.sh IS build.sh plus the exports, so this is one build and not
# two, and it leaves library/exports regenerated for the check below.
# --no-images: every rendered PNG under library/exports is gitignored, so
# CI was building 1104 pictures and throwing them away inside the step
# that costs a quarter of the run.
#
# NO_LINT=1 because the `lint` job runs it beside this one, and no head can
# merge unless that job passed. That is the second of the three lints a run
# used to do; the third is inside the suite and is skipped for the same
# reason, in `tests`.
- name: build and publish
run: NO_LINT=1 ./publish.sh --no-images
- name: devicelock
run: python3 spec/tools/portrayal/devicelock.py --library library
# The kit is eleven ES modules that nothing checked. `node --check` is a
# syntax check and not a test suite, which is what the script claims;
# before it, a broken module surfaced only if some python test happened to
# shell out to the one that imports it.
- name: kit
run: cd kit && npm test
# The exports are committed and a DCIM reads them, so a stale one is a
# real defect rather than untidiness. publish.sh above has already
# regenerated them from this tree; anything left in the diff is a change
# somebody made without republishing. #100 merged that way and it went
# unnoticed for two PRs. HERE RATHER THAN AFTER THE SUITE, because nothing
# in the suite writes to library/exports and a stale export now fails the
# run five minutes in instead of twenty.
- name: exports are current
run: |
# `git diff` SEES ONLY TRACKED FILES, so a device whose configurations
# produce a document that has never been committed slipped straight
# past this gate: publish.sh wrote four new Edgecore device types and
# the check reported clean, because an untracked file is not a
# difference to `diff`. A NEW export is exactly the case this step
# exists to catch - it is a document a DCIM would never receive.
if ! git diff --quiet -- library/exports \
|| [ -n "$(git status --porcelain --untracked-files=all -- library/exports)" ]; then
echo "::error::library/exports is stale - run ./publish.sh and commit the result"
git --no-pager diff --stat -- library/exports
git status --porcelain --untracked-files=all -- library/exports
exit 1
fi
# WHAT THE SHARDS NEED, AND WHAT SPLITS THEM. The build writes two
# gitignored trees - library/dist, which the suite reads, and
# library/packages - and the exports, which the step above has just proved
# equal to the committed ones a shard checks out. The weights are the
# newest merged run's per-test times, fetched ONCE here so all four shards
# split by the same numbers: shards.py splits deterministically from them,
# and `build` measures that it did. A fetch that fails writes no weights
# and every test weighs the same, which balances worse and loses nothing.
- name: bundle
env:
GITHUB_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
mkdir -p "$RUNNER_TEMP/bundle"
tar -czf "$RUNNER_TEMP/bundle/build.tgz" library/dist library/packages
python3 spec/tools/portrayal/shards.py fetch-weights "$GITHUB_REPOSITORY" \
--out "$RUNNER_TEMP/bundle/shard-weights.json"
# ONE DAY, because nothing reads it after this run. `overwrite` for a
# re-run of this job, which finds the first attempt's artifact.
# compression-level 0: the tarball is already gzipped.
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build
path: ${{ runner.temp }}/bundle
if-no-files-found: error
overwrite: true
retention-days: 1
compression-level: 0
# FOUR FOR A FULL RUN, TWO FOR A LIGHT ONE, FROM THE NUMBERS. The full suite
# was about 8,400 summed seconds once the xdist groups worked again (pytest
# below 9.2), and its slowest single test - a whole-library lint, around 200s
# - is a floor no split goes under. The light tier is about 1,350 summed
# seconds, so two runners take a few minutes each. The count is the length of
# the list and nothing else: `strategy.job-total` hands it to the split.
tests:
name: tests ${{ matrix.shard }} of ${{ strategy.job-total }}
needs: dist
if: github.event_name != 'push' && !github.event.pull_request.draft
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest') || vars.GATES_RUNNER || 'ubuntu-latest' }}
timeout-minutes: 30
strategy:
# EVERY SHARD FINISHES. A failure in one says nothing about the other
# three, and stopping them would hide their failures until the next push.
fail-fast: false
matrix:
shard: ${{ fromJSON(needs.dist.outputs.tier == 'full' && '[1, 2, 3, 4]' || '[1, 2]') }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
# NODE IS INSTALLED, NOT INHERITED. Fourteen test modules shell out to it
# and each carries `skipif(shutil.which("node") is None)`, so before this
# line the suite depended on the runner image happening to ship it - and
# the day it stopped, fourteen files would have gone quiet rather than red.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
- run: pip install -e ".[test]"
# pdftoppm gates the OCR tests. Without it they SKIP, which is the one
# thing this workflow exists to stop happening quietly. Self-hosted runners
# cannot reach Ubuntu's package hosts. Where the image has Miniconda
# (CONDA is set), poppler comes from conda-forge. A hosted image without
# Miniconda, such as ubuntu-26.04, installs poppler-utils with apt instead.
- name: poppler
run: |
command -v pdftoppm && exit 0
if [ -z "${CONDA:-}" ]; then
sudo -n true || { echo "::error::CONDA is not set and sudo needs a password: cannot install poppler-utils with apt"; exit 1; }
sudo -n apt-get update
sudo -n apt-get install -y poppler-utils
command -v pdftoppm
pdftoppm -v
exit 0
fi
"$CONDA/bin/conda" create -y -p "$RUNNER_TEMP/poppler-env" -c conda-forge poppler
"$RUNNER_TEMP/poppler-env/bin/pdftoppm" -v
echo "$RUNNER_TEMP/poppler-env/bin" >> "$GITHUB_PATH"
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: build
path: ${{ runner.temp }}/bundle
- name: unpack the build
run: tar -xzf "$RUNNER_TEMP/bundle/build.tgz"
# ONE WORKER PER CORE, within each shard. The suite spends most of its wall
# clock waiting on child processes - node for the kit tests, lint.py and
# render.py for the tool tests - so the parent sits idle while a core is
# free. Measured on this suite after the loader fix: 358s serial, 235s at
# -n 2, 177s at -n 4. `auto` and not a number, because the runner decides.
# A self-hosted pool caps it in the runner's own .env
# (PYTEST_XDIST_AUTO_NUM_WORKERS), which xdist reads for `auto`.
#
# `--shard` keeps one share (spec/tools/portrayal/shards.py): whole files,
# and whole xdist groups, balanced by the weights `dist` fetched. The
# others are reported as deselected. `--shard-record` writes what this
# shard collected and kept, for `build` to prove the shares add up.
#
# PORTRAYAL_LINT_ALREADY_RAN retires the third lint of the run.
# `test_lint_green` shells out and lints the whole library at 76s, which
# made it the critical path INSIDE the suite. It is worth its time locally
# and is redundant here, because the `lint` job runs beside this one and a
# merge needs both.
#
# NOTHING HERE SHARES MUTABLE STATE: the only test that writes outside a
# tmp fixture makes its own tempfile.mkdtemp(), and the library the rest
# read is read-only by libdata's own contract.
#
# EVERY TEMPORARY FILE LIVES AND DIES WITH THIS JOB. pytest's default
# basetemp is /tmp/pytest-of-<user>, and it KEEPS the last few runs'
# trees: on the self-hosted pool three runners shared one user and one
# /tmp, a suite leaves gigabytes there, and on 2026-09-26 13 GB of them
# filled the box's /tmp and failed three unrelated PRs with ENOSPC.
# `--basetemp` under RUNNER_TEMP gives each job its own tree, which pytest
# empties at start and the runner deletes after the job - cancelled jobs
# included. TMPDIR does the same for mkdtemp() and for the subprocesses
# the suite shells out to. A hosted runner is unaffected.
#
# THE LIGHT TIER DESELECTS `heavy` and the split comes after it
# (shards.py splits last), so each shard's record is of what it ran.
- name: tests
env:
PORTRAYAL_LINT_ALREADY_RAN: '1'
TIER: ${{ needs.dist.outputs.tier }}
run: |
set -o pipefail
export TMPDIR="$RUNNER_TEMP/tmp"
mkdir -p "$TMPDIR" "$RUNNER_TEMP/out"
select=()
[ "$TIER" = full ] || select=(-m "not heavy")
python3 -m pytest spec/tests -q -rs -n auto "${select[@]}" \
--shard "${{ matrix.shard }}/${{ strategy.job-total }}" \
--shard-weights "$RUNNER_TEMP/bundle/shard-weights.json" \
--shard-record "$RUNNER_TEMP/out/record.json" \
--junitxml "$RUNNER_TEMP/out/junit.xml" \
--basetemp "$RUNNER_TEMP/pytest" | tee "$RUNNER_TEMP/out/pytest.txt"
# WHAT `build` READS, uploaded even when the suite failed - a failing
# shard's log is the one somebody wants. `overwrite` for a re-run.
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: shard-${{ matrix.shard }}
path: ${{ runner.temp }}/out
if-no-files-found: error
overwrite: true
retention-days: 7
# THE CHECK BRANCH PROTECTION REQUIRES, BY NAME. It runs whatever happened
# above (`!cancelled()`: a superseded run reports nothing, and its successor
# will) and fails unless `dist` and every shard succeeded - a skipped or
# failed dependency must not leave a required check green. The guards that
# used to follow the suite run here, over all four shards together.
#
# ON A DRAFT IT SKIPS, and a skipped `build` reads as passing to branch
# protection. That is safe only because a draft cannot be merged: marking it
# ready starts a fresh run on the same head (`ready_for_review` above), whose
# `build` is pending until the suite has run. Merge on that run's conclusion,
# never on a `skipped` one.
#
# ITS NAME IS THE TIER'S. Only a full run's verdict is `build`; a light run's
# is `light suite`, skipped or not, so no pull request push can put a passing
# or a skipped `build` on a head. The job id stays `build` for the tests that
# read this file; the check is what the name evaluates to.
build:
name: ${{ needs.dist.outputs.tier == 'full' && 'build' || 'light suite' }}
needs: [dist, tests]
if: ${{ !cancelled() && github.event_name != 'push' && !github.event.pull_request.draft }}
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest') || vars.GATES_RUNNER || 'ubuntu-latest' }}
timeout-minutes: 10
# The same two reads as `dist`: `test time` finds an earlier run.
permissions:
contents: read
actions: read
pull-requests: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
# Every shard's log, junit and record, each in its own directory.
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: shard-*
path: ${{ runner.temp }}/shards
# The guard for the failure above, and it checks WHICH test stopped running
# rather than how many.
#
# IT CHECKS THAT THE SUITE RAN AT ALL FIRST - IN EVERY SHARD - and that is
# not theoretical: the first run of this workflow had no pytest installed,
# so the file held one line of error text, the skip count parsed as zero,
# and this step reported SUCCESS. A suite that never started looked exactly
# like a suite with nothing skipped - the same shape of blindness the step
# exists to prevent, one level up. A shard that kept no test prints no
# `passed` either, and fails here too.
#
# THE ALLOW-LIST REPLACED A BUDGET OF FIVE. An integer is a global anyone's
# legitimate optional test spends for everyone, and it says nothing about
# what went quiet: `node` vanishing skips fourteen files at once and a
# budget catches that only because fourteen happens to exceed five.
# spec/allowed-skips.txt says which reasons are facts about the world.
# The shards' logs are read TOGETHER, as one run's would be: the check
# refuses an unlisted reason and never asks that a listed one appear, so
# a skip only one shard has fails nobody.
- name: no silent skipping
if: always()
run: |
logs=("$RUNNER_TEMP"/shards/shard-*/pytest.txt)
[ -f "${logs[0]}" ] || { echo "::error::no shard left a pytest log - the suite did not run."; exit 1; }
for log in "${logs[@]}"; do
if ! grep -qE '[0-9]+ (passed|failed|error)' "$log"; then
echo "::error::pytest produced no summary line in $log - that shard did not run."
echo "::error::A missing interpreter or package looks like a clean result here."
tail -20 "$log" || true
exit 1
fi
done
cat "${logs[@]}" > "$RUNNER_TEMP/pytest.txt"
python3 spec/tools/portrayal/check_skips.py "$RUNNER_TEMP/pytest.txt" spec/allowed-skips.txt
# A TEST IN NO SHARD IS A SILENT SKIP with no SKIPPED line to catch it.
# The split is deterministic by construction; this measures it: every
# shard collected the same suite, and their shares cover it exactly once.
- name: every test ran once
if: always()
run: python3 spec/tools/portrayal/shards.py check "$RUNNER_TEMP"/shards/shard-*/record.json
# WHAT THE SUITE COST, AND WHAT THIS CHANGE ADDED TO IT. The suite grew one
# reasonable test at a time and nothing reported it. This writes where the
# time went to the job summary and, against the newest merged pull request's
# run, names a new test over five seconds, a file that slowed and a total
# that grew - with the runner's load divided out, since the same tree
# measures up to twice as slow on a busy machine. The shards' junit files
# are read together, so the record is the whole suite's, as before.
#
# IT FLAGS AND CANNOT FAIL THE RUN. A timing is a question for a reviewer,
# not a reason to refuse a merge, and finding the earlier run talks to an
# API that can be rate-limited - hence `continue-on-error`. When the suite
# wrote no record there is nothing to say; the steps above already failed.
- name: test time
if: always()
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
junits=("$RUNNER_TEMP"/shards/shard-*/junit.xml)
[ -f "${junits[0]}" ] || exit 0
python3 spec/tools/portrayal/suite_times.py "${junits[@]}" \
--out "$RUNNER_TEMP/test-times.json" \
--fetch-base "$GITHUB_REPOSITORY" --summary "$GITHUB_STEP_SUMMARY"
# THE BUDGET, WHICH CAN FAIL THE RUN where the report above cannot. The
# tier's summed seconds against spec/test-budget.json, read in the units
# of the run each number was set from (spec/test-budget-reference.json,
# file by file), so a slow runner is not a bigger suite; on the light
# tier, a new test function of five seconds or more too, judged against
# the newest merged run. Raising a budget, or re-recording its reference,
# is a one-way door. With no base run the ceiling goes unchecked and the
# step says so (a rate limit must not hold a merge). The job installs nothing, and the tool's
# one import is the standard-library suite_times, hence PYTHONPATH.
#
# THE PULL REQUEST'S FILES, so a new slow test fails only the change that
# holds it: the base can predate a test merged since, which would then
# read as new to everybody. Unreadable, nothing counts as touched and a
# new slow test warns: a rate limit must not hold a merge.
- name: test budget
if: always()
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR: ${{ github.event.pull_request.number }}
TIER: ${{ needs.dist.outputs.tier }}
PYTHONPATH: spec/tools
run: |
junits=("$RUNNER_TEMP"/shards/shard-*/junit.xml)
touched=()
if [ -n "$PR" ]; then
gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/files" --paginate \
--jq '.[].filename' > "$RUNNER_TEMP/touched.txt" \
|| : > "$RUNNER_TEMP/touched.txt"
touched=(--touched "$RUNNER_TEMP/touched.txt")
fi
python3 spec/tools/portrayal/suite_budget.py "${junits[@]}" "${touched[@]}" \
--tier "$TIER" --budget spec/test-budget.json \
--reference spec/test-budget-reference.json --fetch-base "$GITHUB_REPOSITORY"
# The record a LATER run compares against, and the weights a later run
# splits by. Only a merged head's is ever read, but the run cannot know
# yet whether it will merge.
#
# `overwrite`, AND IT CANNOT FAIL THE RUN EITHER: a re-run of this job
# finds the first attempt's artifact under the same name, and without
# both lines the upload would refuse it and turn a passing suite red.
- name: publish test times
if: always()
continue-on-error: true
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
# ONLY A FULL RUN'S TIMES ARE `test-times`, the base every later run
# compares against and splits by. A light run's lack the heavy tier.
name: ${{ needs.dist.outputs.tier == 'full' && 'test-times' || 'test-times-light' }}
path: ${{ runner.temp }}/test-times.json
if-no-files-found: ignore
overwrite: true
retention-days: 30
# THE VERDICT, LAST, so the guards above have spoken first. `needs` with
# `!cancelled()` runs this job after a failed build or a failed shard, and
# that is the only way the required check can be red for them.
- name: every job passed
if: always()
env:
DIST: ${{ needs.dist.result }}
TESTS: ${{ needs.tests.result }}
run: |
echo "dist: $DIST, tests: $TESTS"
[ "$DIST" = success ] && [ "$TESTS" = success ] || {
echo "::error::dist was $DIST and the test shards were $TESTS - both must succeed"
exit 1
}