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
75 changes: 59 additions & 16 deletions .github/workflows/darkbloom-route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ name: Darkbloom Route
# DARKBLOOM_ROUTING variable is exactly `on`; the plane can never fail this job.
# DARKBLOOM_MACOS_LANES, when set, caps the macOS jobs one run asks for: lanes
# are kept in the caller's order while they fit, and the others keep their
# fallback without asking.
# fallback without asking. A macOS lane can name a size. Sizes are sent only
# when the DARKBLOOM_JOB_SHAPES variable is exactly `on`; otherwise the request
# is the one without sizes, and a `required` lane keeps its fallback without
# asking.
on:
workflow_call:
inputs:
lanes:
description: >-
One lane per line: `<lane> <profile> <fallback-label> [count]`.
Profiles are linux_arm64 and macos_arm64. Count is the number of jobs
that will run (default 1); 0 keeps the fallback without asking.
One lane per line: `<lane> <profile> <fallback-label> [count [size
[required]]]`. Profiles are linux_arm64 and macos_arm64. Count is the
number of jobs that will run (default 1); 0 keeps the fallback
without asking. Size, macOS only, is `<vCPUs>x<GiB>`, such as 4x24.
While sizes are off, a `required` lane keeps its fallback without
asking, and any other lane asks without its size.
type: string
required: true
outputs:
Expand All @@ -40,6 +46,7 @@ jobs:
LANES: ${{ inputs.lanes }}
ROUTING: ${{ vars.DARKBLOOM_ROUTING }}
MACOS_LANES: ${{ vars.DARKBLOOM_MACOS_LANES }}
JOB_SHAPES: ${{ vars.DARKBLOOM_JOB_SHAPES }}
PLANE_URL: ${{ vars.DARKBLOOM_SANDBOX_URL }}
REPOSITORY: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
Expand All @@ -51,6 +58,8 @@ jobs:

# The only labels a lane can receive besides its fallback. A plane
# decision is used only when it repeats its profile's array exactly.
# For a lane sent with a size, the size qualifies the last label
# (darkbloom-macos-arm64-4x24).
profiles='{"linux_arm64":["self-hosted","linux","ARM64","darkbloom-linux-arm64"],"macos_arm64":["self-hosted","macOS","ARM64","darkbloom-macos-arm64"]}'
# Plane text is untrusted: keep it short, on one line, and free of
# Markdown, HTML and workflow-command syntax before printing it.
Expand All @@ -63,23 +72,48 @@ jobs:

configured='[]'
seen=' '
while read -r lane profile fallback count extra; do
while read -r lane profile fallback count shape required extra; do
[ -n "$lane" ] || continue
count=${count:-1}
[ -z "$extra" ] || configuration_error "lane $lane has more than four fields"
[ -z "$extra" ] || configuration_error "lane $lane has more than six fields"
[[ $lane =~ ^[A-Za-z0-9_-]+$ ]] || configuration_error "invalid lane name: $lane"
jq -e --arg profile "$profile" 'has($profile)' <<<"$profiles" >/dev/null \
|| configuration_error "lane $lane has unknown profile: $profile"
[[ $fallback =~ ^[A-Za-z0-9._-]+$ ]] \
|| configuration_error "lane $lane has invalid fallback label: $fallback"
[[ $count =~ ^(0|[1-9][0-9]?)$ ]] || configuration_error "lane $lane has invalid count: $count"
# The plane's size grammar: <vCPUs>x<GiB>, lowercase decimal, no leading zeros.
if [ -n "$shape" ]; then
[[ $shape =~ ^[1-9][0-9]*x[1-9][0-9]*$ ]] \
|| configuration_error "lane $lane has invalid size: $shape (use <vCPUs>x<GiB>, such as 4x24)"
[ "$profile" = macos_arm64 ] || configuration_error "lane $lane has a size, but sizes are macOS only"
fi
[ -z "$required" ] || [ "$required" = required ] \
|| configuration_error "lane $lane has an unknown sixth field: $required"
case $seen in *" $lane "*) configuration_error "lane $lane is listed twice" ;; esac
seen="$seen$lane "
configured=$(jq -c --arg lane "$lane" --arg profile "$profile" --arg fallback "$fallback" \
--argjson count "$count" '. + [{$lane, $profile, $fallback, $count}]' <<<"$configured")
--argjson count "$count" --arg shape "$shape" --arg required "$required" \
'. + [{$lane, $profile, $fallback, $count,
shape: (if $shape == "" then null else $shape end), required: ($required != ""), held: false}]' \
<<<"$configured")
done <<<"${LANES:-}"
[ "$configured" != '[]' ] || configuration_error "no lanes are configured"

# Job sizes are a repository setting, off unless exactly `on`. While
# they are off, no size is sent, so the request is the request of a
# lane table without sizes. A `required` lane is then held: it keeps
# its fallback without asking and takes no place under the macOS cap.
shapes_note=""
if jq -e 'any(.[]; .shape != null)' <<<"$configured" >/dev/null; then
if [ "${JOB_SHAPES:-}" = on ]; then
shapes_note=" Job sizes are on: DARKBLOOM_JOB_SHAPES is 'on'."
else
shapes_note=" Job sizes are off: DARKBLOOM_JOB_SHAPES is not 'on'. No size was requested."
configured=$(jq -c 'map(.held = .required | .shape = null)' <<<"$configured")
fi
fi

# The macOS cap is a repository setting, not caller configuration: a
# value other than 0 to 99 asks for no macOS lane rather than failing.
macos_cap=${MACOS_LANES:-}
Expand All @@ -90,13 +124,16 @@ jobs:
fi
configured=$(jq -c --arg cap "$macos_cap" '
reduce .[] as $entry ({used: 0, lanes: []};
if $cap != "" and $entry.profile == "macos_arm64" and $entry.count > 0
if $entry.held then .lanes += [$entry + {capped: false}]
elif $cap != "" and $entry.profile == "macos_arm64" and $entry.count > 0
and .used + $entry.count > ($cap | tonumber)
then .lanes += [$entry + {capped: true}]
else .used += (if $entry.profile == "macos_arm64" then $entry.count else 0 end)
| .lanes += [$entry + {capped: false}]
end) | .lanes' <<<"$configured")
requested=$(jq -c '[.[] | select(.count > 0 and (.capped | not)) | {lane, profile, count}]' <<<"$configured")
# A lane without a size is exactly {lane, profile, count}.
requested=$(jq -c '[.[] | select(.count > 0 and (.capped | not) and (.held | not))
| {lane, profile, count} + (if .shape != null then {shape} else {} end)]' <<<"$configured")

plane_url=${PLANE_URL:-https://api-sandbox.darkbloom.dev}
body=$(mktemp)
Expand All @@ -121,6 +158,8 @@ jobs:
request=$(jq -n -c --arg repository "$REPOSITORY" --argjson run_id "$RUN_ID" \
--argjson run_attempt "$RUN_ATTEMPT" --argjson lanes "$requested" \
'{$repository, $run_id, $run_attempt, $lanes}')
# The request names only the repository, the run and the lanes.
echo "Request: $request"
# One attempt plus at most one retry after a transport failure,
# timeout or transient status; each attempt is bounded to 5 seconds.
for attempt in 1 2; do
Expand Down Expand Up @@ -157,28 +196,32 @@ jobs:
($reply[0].lanes // {}) as $plane_decisions
| [ $configured[]
| ($plane_decisions[.lane] | if type == "object" then . else {} end) as $decision
| (.shape as $shape | $profiles[.profile]
| if $shape == null then . else .[:-1] + [.[-1] + "-" + $shape] end) as $labels
| if .count == 0 then .target = "fallback" | .reason = "not requested"
elif $fallback_reason != "" then .target = "fallback" | .reason = $fallback_reason
elif .held then .target = "fallback" | .reason = "needs its size, and job sizes are off (DARKBLOOM_JOB_SHAPES)"
elif .capped then .target = "fallback" | .reason = "over the macOS lane cap (DARKBLOOM_MACOS_LANES)"
elif $decision.target == "darkbloom" and $decision.runs_on == $profiles[.profile]
elif $decision.target == "darkbloom" and $decision.runs_on == $labels
then .target = "darkbloom" | .reason = "granted"
elif $decision.target == "fallback"
then .target = "fallback" | .reason = "plane: " + ($decision.reason // "no reason" | clean)
else .target = "fallback" | .reason = "plane decision is missing or invalid"
end
| .runs_on = (if .target == "darkbloom" then $profiles[.profile] else .fallback end) ]')
| .runs_on = (if .target == "darkbloom" then $decision.runs_on else .fallback end) ]')
routes=$(jq -c 'map({key: .lane, value: .runs_on}) | from_entries' <<<"$decisions")
echo "routes=$routes" >> "$GITHUB_OUTPUT"

note="$note$cap_note"
note="$note$cap_note$shapes_note"
echo "$note"
jq -r '.[] | "\(.lane): \(.runs_on | if type == "array" then join(",") else . end) (\(.reason))"' <<<"$decisions"
jq -r '.[] | (if .shape == null then "" else "; size \(.shape)" end) as $size
| "\(.lane): \(.runs_on | if type == "array" then join(",") else . end) (\(.reason)\($size))"' <<<"$decisions"
{
echo "### Darkbloom runner routing"
echo
echo "$note"
echo
echo "| Lane | Profile | Jobs | Runner | Decision |"
echo "| --- | --- | --- | --- | --- |"
jq -r '.[] | "| `\(.lane)` | \(.profile) | \(.count) | `\(.runs_on | if type == "array" then join(", ") else . end)` | \(.target): \(.reason) |"' <<<"$decisions"
echo "| Lane | Profile | Jobs | Size | Runner | Decision |"
echo "| --- | --- | --- | --- | --- | --- |"
jq -r '.[] | "| `\(.lane)` | \(.profile) | \(.count) | \(.shape // "-") | `\(.runs_on | if type == "array" then join(", ") else . end)` | \(.target): \(.reason) |"' <<<"$decisions"
} >> "$GITHUB_STEP_SUMMARY"
42 changes: 26 additions & 16 deletions .github/workflows/provider-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,36 @@ jobs:
echo "mimo_audio=$MIMO_AUDIO"
} >> "$GITHUB_OUTPUT"

# Chooses a Darkbloom Sandbox or the Blacksmith fallback for each blocking
# test lane. A lane is granted whole or falls back whole, so each job (each
# shard) has a lane of its own and falls back alone, except the two
# Cluster Focused Checks shards: they share the lane the approval names,
# test-cluster-focused, with a count of 2. The approval gives every routed
# lane one small macOS size (4 vCPU, 16 GiB), so only these 7 jobs ask: the
# build jobs and the Cluster GPU Tests stay on Blacksmith
# (provider-tests.yml). The lanes are listed in the order the
# DARKBLOOM_MACOS_LANES cap keeps them: the critical-path shards first.
# Chooses a Darkbloom Sandbox or the Blacksmith fallback for every macOS job
# of provider-tests.yml. This table is the one place that names each job's
# lane and size. A lane is granted whole or falls back whole, so each job
# (each shard) has a lane of its own and falls back alone, except the two
# Cluster Focused Checks shards and the two Cluster GPU Tests shards: each
# pair shares one lane with a count of 2. A lane asks for a job only when
# the job runs.
#
# Sizes (<vCPUs>x<GiB>) are sent only while DARKBLOOM_JOB_SHAPES is `on`
# (darkbloom-route.yml). The 7 blocking test jobs peak at 21.5 GiB and ask
# for 4x24; while sizes are off they ask without a size, as before. The
# build jobs, Cluster Release Build Checks and Cluster GPU Tests ask for
# 12x32 and are `required`: while sizes are off they keep Blacksmith without
# asking. The lanes are in the order the DARKBLOOM_MACOS_LANES cap keeps
# them: the critical-path test shards first, then the 12x32 jobs.
route:
needs: components
needs: [tested, components]
if: ${{ !cancelled() }}
uses: ./.github/workflows/darkbloom-route.yml
permissions: {}
with:
lanes: |
${{ inputs.linux_lanes }}
test-cluster-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }}
test-cluster-3 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }}
test-cluster-focused macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 2 || 0 }}
test-provider-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.provider == 'true' && 1 || 0 }}
test-cluster-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }}
test-provider-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.provider == 'true' && 1 || 0 }}
test-cluster-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }} 4x24
test-cluster-3 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }} 4x24
test-cluster-focused macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 2 || 0 }} 4x24
test-provider-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.provider == 'true' && 1 || 0 }} 4x24
test-cluster-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }} 4x24
test-provider-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.provider == 'true' && 1 || 0 }} 4x24
build-cluster macos_arm64 blacksmith-12vcpu-macos-27 ${{ (needs.components.outputs.cluster == 'true' || (github.event_name == 'push' && needs.tested.outputs.skip == 'true' && needs.components.outputs.changed_cluster == 'true')) && 1 || 0 }} 12x32 required
build-provider macos_arm64 blacksmith-12vcpu-macos-27 ${{ (needs.components.outputs.provider == 'true' || (github.event_name == 'push' && needs.tested.outputs.skip == 'true' && needs.components.outputs.changed_provider == 'true')) && 1 || 0 }} 12x32 required
cluster-release-checks macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 1 || 0 }} 12x32 required
test-cluster-gpu macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.components.outputs.cluster == 'true' && 2 || 0 }} 12x32 required
26 changes: 14 additions & 12 deletions .github/workflows/provider-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Provider Tests
# The provider and cluster build and test jobs and the Provider Tests gate,
# shared by CI (dev) (.github/workflows/ci-dev.yml) and CI (master)
# (.github/workflows/ci-master.yml). Their plan (provider-plan.yml) chooses
# the components and the runners of the test lanes; pull requests and pushes
# run the same jobs. Each lane builds once, on a large Blacksmith runner, and
# its test jobs run those products. Only pushes save caches.
# the components and the runner of every macOS job; pull requests and pushes
# run the same jobs. Each lane builds once, on a large runner, and its test
# jobs run those products. Only pushes save caches.
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -52,11 +52,11 @@ jobs:
# soon as their products are up. A push whose tree a pull request run
# already tested runs no test job; the build job then builds only the
# components the push changed, to refresh the branch's caches. The build
# jobs stay on Blacksmith: the Darkbloom approval gives every routed lane
# one small size.
# jobs need a large Mac: their lanes ask for 12x32 and only while job
# sizes are on; otherwise they run on Blacksmith (provider-plan.yml).
name: Build cluster test products
if: ${{ inputs.cluster == 'true' || (github.event_name == 'push' && inputs.skip == 'true' && inputs.changed_cluster == 'true') }}
runs-on: blacksmith-12vcpu-macos-27
runs-on: ${{ fromJSON(inputs.routes)['build-cluster'] }}
timeout-minutes: 60
steps:
# SwiftPM's products hold absolute paths, and Blacksmith and Darkbloom
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
build-provider:
name: Build provider test products
if: ${{ inputs.provider == 'true' || (github.event_name == 'push' && inputs.skip == 'true' && inputs.changed_provider == 'true') }}
runs-on: blacksmith-12vcpu-macos-27
runs-on: ${{ fromJSON(inputs.routes)['build-provider'] }}
timeout-minutes: 60
steps:
# The fixed build path, as in build-cluster (scripts/ci-test-products.py).
Expand Down Expand Up @@ -733,12 +733,13 @@ jobs:
# The switched cluster runtime tests these runners cannot pass, the long
# ones and the benchmarks (scripts/cluster-test-plan.py). They run and
# report whenever the cluster jobs run; a failure does not fail the
# workflow. They peak at 18.5 to 24.7 GiB, more than the routed size, so
# they stay on Blacksmith.
# workflow. They peak at 18.5 to 32.8 GiB, so both shards share one lane,
# test-cluster-gpu, which asks for 12x32 only while job sizes are on;
# otherwise they run on Blacksmith (provider-plan.yml).
name: Cluster GPU Tests (non-blocking, shard ${{ matrix.shard }})
needs: build-cluster
if: ${{ inputs.cluster == 'true' }}
runs-on: blacksmith-12vcpu-macos-27
runs-on: ${{ fromJSON(inputs.routes)['test-cluster-gpu'] }}
timeout-minutes: 60
strategy:
fail-fast: false
Expand Down Expand Up @@ -823,10 +824,11 @@ jobs:
# runner, in a job of their own: no test job waits for them. The build is
# reused across runs: SwiftPM rebuilds what changed, and source
# timestamps are restored only for files whose contents match the cached
# build's (scripts/provider-release-cache.py).
# build's (scripts/provider-release-cache.py). Its lane asks for 12x32,
# as the build jobs' do (provider-plan.yml).
name: Cluster Release Build Checks
if: ${{ inputs.cluster == 'true' }}
runs-on: blacksmith-12vcpu-macos-27
runs-on: ${{ fromJSON(inputs.routes)['cluster-release-checks'] }}
timeout-minutes: 60
steps:
- name: Select today's .git cache
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/ci-macos-job-sizes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Provider CI: per-job macOS sizes for Darkbloom Sandboxes

- Each macOS CI lane can ask the Darkbloom plane for a size, `<vCPUs>x<GiB>`. The route job checks each size against this grammar and fails on a bad value before it sends a request.
- Sizes are sent only when the repository variable `DARKBLOOM_JOB_SHAPES` is exactly `on`. While it is off, the route request is byte for byte the request without sizes, and every job keeps the runner it has today.
- While sizes are on, the 7 blocking test jobs ask for 4x24. The build jobs, Cluster Release Build Checks and the 2 Cluster GPU Tests shards also ask, for 12x32, on the lanes `build-cluster`, `build-provider`, `cluster-release-checks` and `test-cluster-gpu` (count 2). A run that tests every component then asks for 12 macOS jobs. While sizes are off, these jobs use `blacksmith-12vcpu-macos-27` without asking.
- A sized lane uses a grant only when its labels end in the qualified label, such as `darkbloom-macos-arm64-4x24`. Otherwise it keeps `blacksmith-12vcpu-macos-27`.
- For each lane, the route job's log and summary show the size asked, the runner, and the decision with its reason, such as `shape_not_signed`, `unavailable`, `unsupported_runner_class`, `image_not_available` or `lane_not_enabled`.
- The `DARKBLOOM_MACOS_LANES` cap still keeps the critical-path test lanes first. The 12x32 lanes come after them.
Loading
Loading