.gitbay/wiki/CI.org

v1.25.0
gitbay/.gitbay/wiki/CI.org rendered · source · history · blame · raw

120 lines · 6153 bytes

  1#+title: CI: what a push queues
  2
  3Three mechanisms decide what a push does to CI, and they interact:
  4
  5- *Dedupe.* A job's result is a property of the commit's tree. A commit
  6  that already has a passed, queued or running build for a job is not
  7  queued again; a commit whose tree already passed a job gets that
  8  result as its status, naming the build it came from (#177). A failed,
  9  cancelled or abandoned build does not count: that commit runs again.
 10- *Path filters.* =paths= and =paths-ignore= on a job are evaluated
 11  against the files the push changed. The diff base is the old tip when
 12  it is an ancestor of the new one, and the merge base with the default
 13  branch otherwise: a new branch, or a force push after a rebase (#176).
 14  A filter that cannot be evaluated, because there is no diff base or
 15  the diff fails, runs the job rather than skipping it. A filter that
 16  excludes the push records a =skipped= status, which =require-checks=
 17  accepts (#172).
 18- *The reaper.* A build a runner claimed and never reported is failed by
 19  the scheduler's tick: two minutes after its log stream ended, or at
 20  the build deadline if no stream was ever seen (#179). Its status reads
 21  =build abandoned=.
 22
 23Which runner takes a build is the fourth: a build is claimed only by a
 24runner attached to its repository (or one polling with a full-scope
 25admin key), and an untrusted build only by one started with
 26=-untrusted=. A repository with no runner attached queues builds
 27nothing claims. See the Users page. Among what a runner may claim it
 28takes the oldest pending build, across every repository it serves;
 29a repository that must never wait on another gets a runner of its own
 30(decided in krz/gitbay#207). There is no cap on how many
 31builds an account queues or how often a schedule fires, and none is
 32planned (krz/gitbay#206): a tick queues nothing while the job's last
 33build is pending or running, so a repository with no runner holds one
 34row per scheduled job, and a schedule with a runner attached spends
 35its owner's compute, not the instance's.
 36
 37Scheduled jobs run on their cron against the default branch, never on
 38push; a default-branch push registers or updates them. Tag jobs run on
 39a matching tag push and nothing else.
 40
 41* The table
 42
 43One =ci.yml= with five jobs, each isolating one rule:
 44
 45#+begin_src yaml
 46jobs:
 47  plain:
 48    steps: [echo plain]
 49  onapp:
 50    paths: [app/**]
 51    steps: [echo onapp]
 52  notapp:
 53    paths-ignore: [app/**]
 54    steps: [echo notapp]
 55  nightly:
 56    schedule: "0 3 * * *"
 57    steps: [echo nightly]
 58  release:
 59    tags: "v*"
 60    steps: [echo release]
 61#+end_src
 62
 63Every push below changes =app/x= and nothing else, so a push whose
 64filters are evaluated queues =onapp= and skips =notapp=, and a push
 65whose filters cannot be evaluated queues both. Each cell is what the
 66push produced for that job; the commit's =ci/<job>= status follows:
 67
 68- =queued=: a build, and a =pending= status until the runner reports.
 69  =queued, untrusted= is a build without the repository's secrets.
 70- =skipped=: no build, and a =skipped= status naming the filter.
 71- =reused=: no build, and a =success= status naming the earlier build
 72  with the same tree.
 73- =registered=: no build; the job's schedule is (re)registered.
 74- =abandoned=: the build failed and the status reads =build abandoned=.
 75- =—=: nothing new. A status the commit already had stands.
 76
 77| push | plain | onapp | notapp | nightly | release | ci/config |
 78|---+---+---+---+---+---+---|
 79| first push of the default branch | queued | queued | queued | registered | — | — |
 80| push to the default branch | queued | queued | skipped | registered | — | — |
 81| push to another branch | queued | queued | skipped | — | — | — |
 82| a new branch, no old sha | queued | queued | skipped | — | — | — |
 83| rebase onto a moved default branch, old not an ancestor | queued | queued | skipped | — | — | — |
 84| rewritten commit, same tree as a passed build | reused | reused | skipped | — | — | — |
 85| fast-forward of a commit built on another branch | — | — | — | registered | — | — |
 86| a commit whose earlier build failed, on a new branch | queued | queued | — | — | — | — |
 87| merge request head from a fork | queued, untrusted | queued, untrusted | queued, untrusted | — | — | — |
 88| tag push | — | — | — | — | queued | — |
 89| schedule tick on the default branch | — | — | — | queued | — | — |
 90| schedule tick while the last scheduled build is still pending | — | — | — | — | — | — |
 91| claimed builds whose runner vanished | abandoned | abandoned | — | — | — | — |
 92| push to the default branch with an old sha that cannot be diffed | queued | queued | queued | registered | — | — |
 93| push with a broken ci.yml | — | — | — | — | — | failure |
 94| push with no ci.yml | — | — | — | — | — | — |
 95
 96Rows worth a second look:
 97
 98- The first push of the default branch has no diff base at all: the
 99  merge base of the tip with itself is the tip. Every filtered job
100  runs. The same holds when the old sha cannot be diffed on the default
101  branch; on any other branch the merge base takes over and the filters
102  apply.
103- A rewritten commit with the same tree reuses =plain= and =onapp=
104  because the tree check comes before the filter. =notapp= never had a
105  passed build to reuse, and the push changed nothing, so the filter
106  skips it again.
107- A fast-forward of a commit built elsewhere queues nothing: the
108  builds belong to the commit, not the branch. The default-branch push
109  still registers the schedule.
110- A failed build does not stand for its commit. The same commit pushed
111  to another branch runs again; =notapp= keeps its skipped status.
112- A merge request head from a fork has no diff base and, unlike a
113  branch push, no merge-base fallback: every job runs, without secrets.
114  Filtering a head down to no jobs would make it unmergeable under
115  =require-checks= (#172).
116
117=TestPushShapes= in =internal/hookd= runs every row against real git
118and the store, and =TestPushShapesTableOnWiki= checks that this page
119carries each row as the code has it. A row that changes fails there
120first.