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
14 changes: 8 additions & 6 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tag by commit and file hashes.
| `common/7.2` | fixes any headset on Valve's tree can meet, and this repository's CI (`.github/`) |
| `sm8250/7.2` | the Snapdragon XR2's (SM8250) blocks |
| `phoenix/7.2` | the PICO 4 ([overpressure/phoenix](https://github.com/overpressure/phoenix)): its drivers, device tree, `arch/arm64/configs/pico4.config` and driver tests; the default branch |
| `hollywood/7.2` | the Meta Quest 2 ([overpressure/hollywood](https://github.com/overpressure/hollywood)): its drivers, device tree and configuration, on `sm8250/7.2`; built once overpressure/hollywood has its `kernel/build-tree.sh`, until then its pushes and pull requests build nothing and pass |

[`.github/layers`](layers) lists each branch and the branch it takes its changes from. A headset's branch is named
after its repository, `overpressure/<headset>`, whose `kernel/build-tree.sh` builds it; the PICO 4's layers are
Expand All @@ -28,7 +29,7 @@ by such pull requests with a passing `ci` check, `valve/7.2` only move forward,
| Workflow | When | What |
| --- | --- | --- |
| [Valve](workflows/valve.yml) | Mondays 05:23 UTC, and by hand | moves `valve/7.2` forward to Valve's newest commit ([scripts/valve.sh](scripts/valve.sh)) and starts Layers for it; a rewritten Valve branch fails the run. A schedule runs only from the default branch's copy |
| [Layers](workflows/layers.yml) | a push to a layer, and by hand | opens a pull request from the branch into every layer built on it that lacks its commits, unless one is open, and starts its Build ([scripts/layers.sh](scripts/layers.sh)) |
| [Layers](workflows/layers.yml) | a push to a layer, and by hand | opens a pull request from the branch into every layer built on it that lacks its commits, unless one is open, and starts one Build for them ([scripts/layers.sh](scripts/layers.sh)) |
| [Build](workflows/build.yml) | pull requests, pushes to a headset's branch, tags, and the Layers workflow's runs for its pull requests | builds each headset's kernel; for a pull request into a layer without a headset, every headset's branch built on it with the pull request merged in; lints the scripts and workflows; releases tags. Its `ci` job is the required check |

Each week, after the Valve workflow: review and merge its pull request into `common/7.2`, then the pull requests that
Expand Down Expand Up @@ -63,11 +64,12 @@ tag, its own release checklist verifies it on the hardware (phoenix's
## The layers' pull requests

Layers opens its pull requests with the workflow's own token, and a pull request opened with it starts no workflow.
So Layers starts each one's Build itself: a run on the pull request's base branch with `head` set to the branch
that moves up (`valve/7.2` among them, whose tree has no workflows). It builds every headset's branch on that base
with `head` merged in, and sets the status `ci` on `head`'s commit, the check the pull request waits for. Its own
gate job is named `verdict for <head>`: that run belongs to the base's commit, which another pull request may have
as its head.
So Layers starts their Build itself: one run with `head` set to the branch that moves up, on that branch, or on its
one layer for `valve/7.2`, whose tree has no workflows. It builds every headset's branch built on it with `head`
merged in, and sets the status `ci` on `head`'s commit, the check its pull requests wait for. All of a branch's
pull requests (`sm8250/7.2` into `phoenix/7.2` and into `hollywood/7.2`) have that commit as their head and share
its status, so one run judges them all; a run per pull request would let the quickest one's verdict stand for the
others. Its own gate job is named `verdict for <head>`, so that the run's own check never stands for the status.

Each content is built once. A check of a change is keyed by the kernel's sources (the tree without `.github/`, so a
change to the CI alone builds nothing new), so the layers' pull requests find the build of the pull request that
Expand Down
1 change: 1 addition & 0 deletions .github/layers
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
valve/7.2 common/7.2
common/7.2 sm8250/7.2
sm8250/7.2 phoenix/7.2
sm8250/7.2 hollywood/7.2
11 changes: 10 additions & 1 deletion .github/scripts/headsets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# headsets.sh [--self] REF
#
# REF is a branch or tag of this repository. When its first part names a headset (a repository
# <owner>/<headset> with kernel/build-tree.sh), that headset is built from the run's own commit.
# <owner>/<headset> with kernel/build-tree.sh), that headset is built from the run's own commit; a
# headset's branch whose repository has no kernel/build-tree.sh yet builds nothing (an empty list).
# Otherwise REF is a layer: every headset's branch built on it (.github/layers, followed upward) is
# built with the run's commit merged in. --self refuses a layer: a push builds only a headset's own
# branch or tag. Prints a JSON list of {device, branch, merge, recipe}, recipe being the commit of the
Expand Down Expand Up @@ -34,6 +35,14 @@ if [ -n "$sha" ]; then
entry "${ref%%/*}" "$ref" false "$sha" | jq -cs .
exit 0
fi
# A headset's branch (no layer takes its changes from it) whose repository has no kernel/build-tree.sh
# yet: nothing to build, which is no failure; build.yml's gate passes an empty list.
if ! grep -v '^#' "$layers" | awk '{print $1}' | grep -qxF "$ref" \
&& gh api "repos/$owner/${ref%%/*}" --silent 2>/dev/null; then
echo "$ref: $owner/${ref%%/*} has no kernel/build-tree.sh yet: nothing to build" >&2
echo '[]'
exit 0
fi
if $self; then
echo "$ref is a layer without a headset: a push to it builds nothing (build.yml's push branches leave it out)" >&2
exit 1
Expand Down
33 changes: 22 additions & 11 deletions .github/scripts/layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
#
# For every layer that takes its changes from FROM (.github/layers) and lacks some of FROM's commits,
# a pull request from FROM into it, unless one is open. A pull request opened with the workflow's own
# token (GH_TOKEN) starts no workflow, so this starts its Build: a run on the layer with head=FROM, which
# builds every headset whose branch is the layer or built on it with FROM merged in and sets the status ci
# on FROM's commit (.github/workflows/build.yml). It is merged with a merge commit, and its merge moves the
# token (GH_TOKEN) starts no workflow, so this starts their Build: one run with head=FROM, which builds
# every headset whose branch is built on FROM with FROM merged in and sets the status ci on FROM's commit
# (.github/workflows/build.yml). All of FROM's pull requests have that commit as their head and share its
# status, so one run judges them all: a run per pull request would let the quickest one's verdict stand for
# the others. It runs on FROM itself, except for valve/7.2, whose tree has no workflows: that one runs on its
# layer (it has one, common/7.2). Each pull request is merged with a merge commit, and its merge moves the
# change on. An open pull request's Build starts again: FROM may have moved. GitHub also gives such a pull
# request a run of its own that waits for a maintainer's approval (its author, the workflow's bot, counts as a
# first-time contributor); that run would only build what the started one builds, so it is deleted.
Expand All @@ -31,18 +34,18 @@ drop_waiting() {
done
}

grep -v '^#' "$layers" | while read -r source into; do
pending=() # the layers with a pull request from FROM, which its Build judges
while read -r source into; do
[ "$source" = "$from" ] || continue
ahead=$(gh api "repos/$repo/compare/$into...$from" --jq .ahead_by)
if [ "$ahead" = 0 ]; then
say "$into has every commit of $from."
continue
fi
pending+=("$into")
open=$(gh pr list --repo "$repo" --head "$from" --base "$into" --state open --json number --jq '.[0].number // empty')
if [ -n "$open" ]; then
gh workflow run build.yml --repo "$repo" --ref "$into" -f head="$from"
say "$from into $into: #$open is open ($ahead commits); its Build started."
drop_waiting "$from"
say "$from into $into: #$open is open ($ahead commits)."
continue
fi
head=$(gh api "repos/$repo/branches/$from" --jq .commit.sha)
Expand All @@ -66,7 +69,15 @@ grep -v '^#' "$layers" | while read -r source into; do
echo "A conflict is resolved here. Nothing is released until a headset's tag."
} > "$body"
gh pr create --repo "$repo" --head "$from" --base "$into" --title "$title" --body-file "$body" >/dev/null
gh workflow run build.yml --repo "$repo" --ref "$into" -f head="$from"
say "$from into $into: pull request opened ($ahead commits), its Build started."
drop_waiting "$from"
done
say "$from into $into: pull request opened ($ahead commits)."
done < <(grep -v '^#' "$layers")

[ ${#pending[@]} -gt 0 ] || exit 0
# One Build for all of FROM's pull requests (see the top): on FROM, or on valve/7.2's one layer.
ref=$from
if [ "$from" = valve/7.2 ]; then
ref=${pending[0]}
fi
gh workflow run build.yml --repo "$repo" --ref "$ref" -f head="$from"
say "$from into ${pending[*]}: their Build started, on $ref."
drop_waiting "$from"
20 changes: 13 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
# - a pull request into a headset's branch builds its merge;
# - a pull request into a layer without a headset (common/, sm8250/) builds every headset's branch built
# on that layer (.github/layers) with the pull request's merge merged in, in the runner, not pushed;
# - a layer's pull request, which the Layers workflow opens with the workflow's own token (one that starts
# no workflow), is built by a run the Layers workflow starts on the pull request's base branch with
# `head` (the branch that moves up, valve/7.2 among them, whose tree has no workflows): every headset's
# branch on that base is built with `head` merged in, and the run sets the status `ci` on `head`'s commit;
# - a layer's pull requests, which the Layers workflow opens with the workflow's own token (one that starts
# no workflow), are built by one run the Layers workflow starts with `head` (the branch that moves up), on
# that branch itself, or on its one layer for valve/7.2, whose tree has no workflows: every headset's
# branch built on it is built with `head` merged in, and the run sets the status `ci` on `head`'s commit,
# the head of each of those pull requests, once for all of them;
# - a headset's branch whose repository has no kernel/build-tree.sh yet builds nothing, and passes;
# - a push to a headset's branch builds it; a tag (<headset>/<version>-<n>) is released with the kernel the
# push build of its commit made, and builds only when that commit has no successful push build.
#
Expand Down Expand Up @@ -41,7 +43,7 @@ on:
workflow_dispatch:
inputs:
head:
description: "a layer pull request's head (a branch): built merged into each headset branch on this base"
description: "the head of a layer's pull requests (a branch): built merged into each headset branch on this ref"
required: false
type: string

Expand Down Expand Up @@ -118,6 +120,8 @@ jobs:

kernel:
needs: plan
# Nothing to build: a headset's branch whose repository has no kernel/build-tree.sh yet.
if: needs.plan.outputs.headsets != '[]'
name: kernel ${{ matrix.headset.device }} (${{ matrix.build }})
runs-on: ubuntu-24.04
timeout-minutes: 180
Expand Down Expand Up @@ -439,10 +443,12 @@ jobs:
env:
NEEDS: ${{ toJSON(needs) }}
RELEASE: ${{ github.ref_type == 'tag' && 'success' || 'skipped' }}
# The kernel job is skipped only when there is nothing to build (see it): then that passes.
KERNEL: ${{ needs.plan.outputs.headsets == '[]' && 'skipped' || 'success' }}
run: |
echo "$NEEDS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
if echo "$NEEDS" | jq -e --arg release "$RELEASE" \
'all(to_entries[]; .value.result == (if .key == "release" then $release else "success" end))' > /dev/null; then
if echo "$NEEDS" | jq -e --arg release "$RELEASE" --arg kernel "$KERNEL" \
'all(to_entries[]; .value.result == (if .key == "release" then $release elif .key == "kernel" then $kernel else "success" end))' > /dev/null; then
echo "state=success" >> "$GITHUB_OUTPUT"
else
echo "state=failure" >> "$GITHUB_OUTPUT"
Expand Down
Loading