.gitbay/wiki/CI.org

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

111 lines · 5495 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 an instance admin's runner), and
 25an untrusted build only by one started with =-untrusted=. A repository
 26with no runner attached queues builds nothing claims. See the Users
 27page.
 28
 29Scheduled jobs run on their cron against the default branch, never on
 30push; a default-branch push registers or updates them. Tag jobs run on
 31a matching tag push and nothing else.
 32
 33* The table
 34
 35One =ci.yml= with five jobs, each isolating one rule:
 36
 37#+begin_src yaml
 38jobs:
 39  plain:
 40    steps: [echo plain]
 41  onapp:
 42    paths: [app/**]
 43    steps: [echo onapp]
 44  notapp:
 45    paths-ignore: [app/**]
 46    steps: [echo notapp]
 47  nightly:
 48    schedule: "0 3 * * *"
 49    steps: [echo nightly]
 50  release:
 51    tags: "v*"
 52    steps: [echo release]
 53#+end_src
 54
 55Every push below changes =app/x= and nothing else, so a push whose
 56filters are evaluated queues =onapp= and skips =notapp=, and a push
 57whose filters cannot be evaluated queues both. Each cell is what the
 58push produced for that job; the commit's =ci/<job>= status follows:
 59
 60- =queued=: a build, and a =pending= status until the runner reports.
 61  =queued, untrusted= is a build without the repository's secrets.
 62- =skipped=: no build, and a =skipped= status naming the filter.
 63- =reused=: no build, and a =success= status naming the earlier build
 64  with the same tree.
 65- =registered=: no build; the job's schedule is (re)registered.
 66- =abandoned=: the build failed and the status reads =build abandoned=.
 67- =—=: nothing new. A status the commit already had stands.
 68
 69| push | plain | onapp | notapp | nightly | release | ci/config |
 70|---+---+---+---+---+---+---|
 71| first push of the default branch | queued | queued | queued | registered | — | — |
 72| push to the default branch | queued | queued | skipped | registered | — | — |
 73| push to another branch | queued | queued | skipped | — | — | — |
 74| a new branch, no old sha | queued | queued | skipped | — | — | — |
 75| rebase onto a moved default branch, old not an ancestor | queued | queued | skipped | — | — | — |
 76| rewritten commit, same tree as a passed build | reused | reused | skipped | — | — | — |
 77| fast-forward of a commit built on another branch | — | — | — | registered | — | — |
 78| a commit whose earlier build failed, on a new branch | queued | queued | — | — | — | — |
 79| merge request head from a fork | queued, untrusted | queued, untrusted | queued, untrusted | — | — | — |
 80| tag push | — | — | — | — | queued | — |
 81| schedule tick on the default branch | — | — | — | queued | — | — |
 82| claimed builds whose runner vanished | abandoned | abandoned | — | — | — | — |
 83| push to the default branch with an old sha that cannot be diffed | queued | queued | queued | registered | — | — |
 84| push with a broken ci.yml | — | — | — | — | — | failure |
 85| push with no ci.yml | — | — | — | — | — | — |
 86
 87Rows worth a second look:
 88
 89- The first push of the default branch has no diff base at all: the
 90  merge base of the tip with itself is the tip. Every filtered job
 91  runs. The same holds when the old sha cannot be diffed on the default
 92  branch; on any other branch the merge base takes over and the filters
 93  apply.
 94- A rewritten commit with the same tree reuses =plain= and =onapp=
 95  because the tree check comes before the filter. =notapp= never had a
 96  passed build to reuse, and the push changed nothing, so the filter
 97  skips it again.
 98- A fast-forward of a commit built elsewhere queues nothing: the
 99  builds belong to the commit, not the branch. The default-branch push
100  still registers the schedule.
101- A failed build does not stand for its commit. The same commit pushed
102  to another branch runs again; =notapp= keeps its skipped status.
103- A merge request head from a fork has no diff base and, unlike a
104  branch push, no merge-base fallback: every job runs, without secrets.
105  Filtering a head down to no jobs would make it unmergeable under
106  =require-checks= (#172).
107
108=TestPushShapes= in =internal/hookd= runs every row against real git
109and the store, and =TestPushShapesTableOnWiki= checks that this page
110carries each row as the code has it. A row that changes fails there
111first.