fun_ci 2.3.0-aarch64-linux → 2.5.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +143 -0
- data/README.md +20 -10
- data/lib/fun_ci/agent/events.rb +15 -7
- data/lib/fun_ci/agent/job_events.rb +12 -5
- data/lib/fun_ci/agent/onward.rb +21 -0
- data/lib/fun_ci/agent/output.rb +7 -0
- data/lib/fun_ci/agent/reports.rb +3 -0
- data/lib/fun_ci/agent/snapshots.rb +25 -7
- data/lib/fun_ci/agent/status_text.rb +9 -5
- data/lib/fun_ci/agent/wait_command.rb +37 -5
- data/lib/fun_ci/cli.rb +2 -0
- data/lib/fun_ci/cli_command_help.rb +51 -0
- data/lib/fun_ci/cli_help.rb +9 -9
- data/lib/fun_ci/console/board_data.rb +50 -10
- data/lib/fun_ci/console/branch_page.rb +9 -0
- data/lib/fun_ci/console/console_state.rb +22 -8
- data/lib/fun_ci/console/cursor.rb +22 -0
- data/lib/fun_ci/console/cursor_rows.rb +37 -0
- data/lib/fun_ci/console/job_message.rb +5 -4
- data/lib/fun_ci/console/job_order.rb +5 -3
- data/lib/fun_ci/console/job_row.rb +17 -0
- data/lib/fun_ci/console/job_rows.rb +14 -3
- data/lib/fun_ci/console/key_handler.rb +88 -51
- data/lib/fun_ci/console/question.rb +63 -0
- data/lib/fun_ci/console/run_message.rb +3 -3
- data/lib/fun_ci/console/trunk_marks.rb +3 -1
- data/lib/fun_ci/console/view.rb +20 -6
- data/lib/fun_ci/evidence/about_stage.rb +1 -1
- data/lib/fun_ci/evidence/collector.rb +6 -3
- data/lib/fun_ci/evidence/outcome.rb +6 -3
- data/lib/fun_ci/jobs/job_run.rb +10 -9
- data/lib/fun_ci/jobs/locks.rb +1 -1
- data/lib/fun_ci/persistence/active_jobs.rb +2 -11
- data/lib/fun_ci/persistence/active_runs.rb +48 -16
- data/lib/fun_ci/persistence/arrival.rb +18 -0
- data/lib/fun_ci/persistence/branch_visibility.rb +40 -0
- data/lib/fun_ci/persistence/database.rb +28 -2
- data/lib/fun_ci/persistence/died.rb +21 -0
- data/lib/fun_ci/persistence/hidden_row_tables.rb +24 -0
- data/lib/fun_ci/persistence/job_recorder.rb +1 -0
- data/lib/fun_ci/persistence/job_runs.rb +17 -7
- data/lib/fun_ci/persistence/job_visibility.rb +43 -0
- data/lib/fun_ci/persistence/null_recorder.rb +4 -0
- data/lib/fun_ci/persistence/pipeline_recorder.rb +23 -3
- data/lib/fun_ci/persistence/pipeline_run.rb +25 -11
- data/lib/fun_ci/persistence/stage_job.rb +25 -0
- data/lib/fun_ci/persistence/trunk_checks.rb +7 -6
- data/lib/fun_ci/pipeline/group_kill.rb +38 -0
- data/lib/fun_ci/pipeline/pipeline_forker.rb +3 -1
- data/lib/fun_ci/pipeline/process_runner.rb +14 -8
- data/lib/fun_ci/pipeline/process_tree.rb +37 -0
- data/lib/fun_ci/pipeline/progress_reporter.rb +2 -1
- data/lib/fun_ci/pipeline/run_canceller.rb +16 -6
- data/lib/fun_ci/pipeline/slot.rb +12 -0
- data/lib/fun_ci/pipeline/slot_run.rb +20 -5
- data/lib/fun_ci/pipeline/slow_turns.rb +74 -0
- data/lib/fun_ci/pipeline/stage_end.rb +2 -1
- data/lib/fun_ci/pipeline/stale_pipeline_canceller.rb +1 -1
- data/lib/fun_ci/pipeline/trigger.rb +9 -1
- data/lib/fun_ci/pipeline/trigger_params.rb +7 -3
- data/lib/fun_ci/pipeline/turn_queue.rb +65 -0
- data/lib/fun_ci/pipeline/waiting_slots.rb +30 -0
- data/lib/fun_ci/pipeline/workspaces.rb +2 -1
- data/lib/fun_ci/pipeline/worktree_pool.rb +27 -7
- data/lib/fun_ci/pipeline/worktree_prune.rb +9 -4
- data/lib/fun_ci/pipeline/worktrees.rb +41 -7
- data/lib/fun_ci/setup/commands.rb +16 -7
- data/lib/fun_ci/setup/eslint_detection.rb +38 -0
- data/lib/fun_ci/setup/init_options.rb +34 -0
- data/lib/fun_ci/setup/installer.rb +41 -7
- data/lib/fun_ci/setup/placeholders.rb +30 -0
- data/lib/fun_ci/setup/project_config.rb +1 -0
- data/lib/fun_ci/setup/settings.rb +21 -1
- data/lib/fun_ci/setup/setup_checker.rb +5 -3
- data/lib/fun_ci/setup/stage_templates/javascript.rb +14 -4
- data/lib/fun_ci/setup/stage_templates/placeholders.rb +21 -0
- data/lib/fun_ci/setup/stage_templates.rb +6 -4
- data/lib/fun_ci/setup/template_writer.rb +3 -5
- data/lib/fun_ci/trunk/check.rb +7 -2
- data/lib/fun_ci/version.rb +1 -1
- data/libexec/fun-ci-renderer +0 -0
- metadata +33 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14466968584a1f5200c34d2aed5dc4cfbdd818562c72dcd555c2ae737b1ff2c2
|
|
4
|
+
data.tar.gz: 05c56ebcc3f4f33db13082cae0c726b60423ca1b565983c7798043f2c990e75e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 735dbd22795afbe7ecf0094f23e7b625f40e852a86c54461cedfbd0cf23c56c52e9f45f34b47c1e88dcbf89c36082100461534f28d0dace5d6f9d1d17c4966eb
|
|
7
|
+
data.tar.gz: abdd0ab1afaf71235e628cb94c9e942302d05c7d4d32746d16c308a69c1f34f596f9849d73979d3271295885bf6a553576a6566b419dbe34ce644a029f8c0055
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,149 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.5.0] - 2026-11-11
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- The console can put a branch or a daily or weekly job out of view. `h` on
|
|
14
|
+
a row asks how: `s` snoozes it until its next run, `i` ignores it until you
|
|
15
|
+
bring it back. The footer says how many rows are hidden, `a` shows them,
|
|
16
|
+
and `h` on a hidden one brings it back. This changes only what the console
|
|
17
|
+
shows on your machine: the branch and the job run as before, and `fun-ci
|
|
18
|
+
jobs`, `status` and `why` report them as before.
|
|
19
|
+
- Every line of `fun-ci events` has `at`, the time it happened in UTC: when a
|
|
20
|
+
run started, a stage finished, a run finished or was superseded, a check
|
|
21
|
+
against the trunk was made, and when a job was scheduled, started and
|
|
22
|
+
finished. It is `null` where fun-ci doesn't know: the end of a job whose
|
|
23
|
+
process died, and the scheduling of a job run kept by an earlier version.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- A newer commit no longer cancels a run whose slow suite has started. The
|
|
27
|
+
slow suite finishes, and the newer run's slow suite waits for it, shown as
|
|
28
|
+
`waiting`; a newer commit still cancels one that is waiting, and when
|
|
29
|
+
several wait, the newest commit's goes next. A waiting slow suite keeps no
|
|
30
|
+
other branch's run from getting a worktree. On a branch that takes commits
|
|
31
|
+
faster than its slow suite runs, slow suites were cancelled nearly every
|
|
32
|
+
time, and a `wait --need all --follow-branch` could wait until the commits
|
|
33
|
+
stopped. Now the newest commit's slow suite waits at most for the one
|
|
34
|
+
already running.
|
|
35
|
+
- A `fun-ci wait` without `--follow-branch` whose run a newer commit cancelled
|
|
36
|
+
runs the commit again, once, and waits on that run. Before, a commit landing
|
|
37
|
+
before the wait first looked at the run left the agent with exit 4 and no
|
|
38
|
+
verdict for the commit it asked about. A commit run again, by `wait` or by
|
|
39
|
+
`fun-ci trigger`, cancels no newer commit's run, and the console's row for
|
|
40
|
+
the branch stays with the newest commit.
|
|
41
|
+
- `fun-ci status` says which level a stage is not needed for, as in `(not
|
|
42
|
+
needed for --need fast)`. Plain `(not needed)` read as wrong while a `wait
|
|
43
|
+
--need all` was waiting on that very stage.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
- The console's header rests on the run that finished last, and its lamp
|
|
47
|
+
shows how that run went. Before, it took the first row on the board, which
|
|
48
|
+
is the one that most needs you, so a branch that failed days ago kept the
|
|
49
|
+
hazard sign and a red lamp up after every later pass. A hidden row shown
|
|
50
|
+
with `a` no longer counts either.
|
|
51
|
+
- The console opens with the cursor on the first row. Before, it had none
|
|
52
|
+
until `j` or `k`, so the keys that act on a row were missing at first
|
|
53
|
+
although the block sat on a row.
|
|
54
|
+
- A tall console with many projects left out every passed project, counted
|
|
55
|
+
beside the keys, when only some would not fit, and left the rest of the
|
|
56
|
+
screen empty. It now keeps as many of their lines as fit.
|
|
57
|
+
- On a terminal too short for every job, the job under the cursor stays on
|
|
58
|
+
screen; the rows furthest from it go first. Before, the rows below the
|
|
59
|
+
screen were cut, the cursor's among them.
|
|
60
|
+
- With more than one project on the board, a job's row cuts its project's
|
|
61
|
+
name to fit, down to its first letter, instead of dropping it, so two projects' jobs of the same name can be told apart. The question to
|
|
62
|
+
cancel a job names its project too.
|
|
63
|
+
- A terminal 20 rows high or less, or one whose job section left no room for
|
|
64
|
+
a branch, showed `No runs yet.` although there were runs. The console now
|
|
65
|
+
always sends the renderer at least one run, which fits what it can of it.
|
|
66
|
+
- `q` and Ctrl-C quit the console while the footer asks a question too.
|
|
67
|
+
Before, they were taken as no answer and did nothing.
|
|
68
|
+
- In the console, the cursor stays on its branch or job when the rows
|
|
69
|
+
reorder. Before, it kept its place on screen, so a row that moved left it on
|
|
70
|
+
another one, and an answer to `Cancel ...?` could cancel a run other than the
|
|
71
|
+
one the footer had named. A question now ends once its row leaves the view or
|
|
72
|
+
its run stops running.
|
|
73
|
+
- A job given a later turn to start is recorded as waiting from the moment a
|
|
74
|
+
commit starts it. Before, it was recorded as running for an instant first,
|
|
75
|
+
and anything reading the database just then, the console or `fun-ci
|
|
76
|
+
events`, took it for a job that had started.
|
|
77
|
+
- `fun-ci runs` no longer dies with "comparison of Integer with nil failed"
|
|
78
|
+
when it lists a run where the slow suite's process died and another stage
|
|
79
|
+
failed or ran over its budget. The died stage is now numbered in the order
|
|
80
|
+
the run's stages finished, and stages that 2.4.0 and earlier kept without
|
|
81
|
+
that number get one the next time fun-ci opens its database.
|
|
82
|
+
|
|
83
|
+
## [2.4.0] - 2026-10-19
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
- `fun-ci COMMAND --help` (or `-h`) prints that command's usage and the
|
|
87
|
+
options it takes. Before, `init`, `check`, `prune` and `console` ignored
|
|
88
|
+
the flag and went ahead, `install-hooks` took it for a hook type, and the
|
|
89
|
+
agent commands called it an invalid option.
|
|
90
|
+
- `fun-ci init --stack NAME` writes the scripts for the stack you name
|
|
91
|
+
(`go`, `node_npm`, ...) instead of the one it detects.
|
|
92
|
+
- In a project whose stack `fun-ci init` doesn't recognise, such as a new
|
|
93
|
+
one with no code yet, it writes four placeholder scripts that pass, instead
|
|
94
|
+
of stopping with nothing written. `fun-ci check` warns about each one still
|
|
95
|
+
in place, since that stage tests nothing.
|
|
96
|
+
- `clean: [public/assets, dist]` in `.fun-ci/config` names build outputs that
|
|
97
|
+
git ignores and that must not carry over from another branch's run. When a
|
|
98
|
+
worktree moves to a commit that doesn't descend from the one it last
|
|
99
|
+
tested, fun-ci removes the ignored files under those paths first, and that
|
|
100
|
+
run's lint and build get the longer budget a new worktree gets. Other
|
|
101
|
+
ignored files, such as `node_modules`, stay. `fun-ci check` names a `clean`
|
|
102
|
+
it can't use.
|
|
103
|
+
- A failed stage's evidence names the stages of the project's other runs
|
|
104
|
+
that ran at the same time, as `other runs alongside: 7ed514c's slow` in
|
|
105
|
+
`fun-ci why`, so a fast suite over its budget beside another commit's slow
|
|
106
|
+
suite says so.
|
|
107
|
+
|
|
108
|
+
### Changed
|
|
109
|
+
- fun-ci's worktrees, the runs' slots and the jobs', move out of `.git/` into
|
|
110
|
+
fun-ci's state directory (`~/.local/state/fun-ci/projects/`). Under
|
|
111
|
+
`.git/`, Vite's default `fs.deny` refused to serve test files, so a Vitest
|
|
112
|
+
suite with a browser-like environment failed in fun-ci and nowhere else.
|
|
113
|
+
The first run after upgrading makes new worktrees, with the longer budget
|
|
114
|
+
a new worktree gets; `fun-ci prune` removes the old ones from `.git/fun-ci/`.
|
|
115
|
+
- For Node, pnpm, Yarn and Bun projects, `fun-ci init` writes a `lint.sh`
|
|
116
|
+
that checks the syntax of the source without the packages (`node --check`
|
|
117
|
+
on `.js`, `.mjs` and `.cjs` files; `bun build --no-bundle`, TypeScript
|
|
118
|
+
included, for Bun), and runs ESLint in `build.sh` after the install, when
|
|
119
|
+
the project configures ESLint. ESLint in `lint.sh` ran beside the install:
|
|
120
|
+
in a new worktree it ran a registry ESLint and failed on a plugin it
|
|
121
|
+
couldn't find, and in a project without ESLint it always failed. A
|
|
122
|
+
TypeScript project on Node gets no check of its `.ts` files in `lint.sh`;
|
|
123
|
+
ESLint or `tsc` in `build.sh` covers them.
|
|
124
|
+
- A worktree slot nobody took for a day counts as cold, as a new one does, so
|
|
125
|
+
lint and build get the longer budget there once. A second slot, used only
|
|
126
|
+
when runs overlap, kept caches days old and ran a build over its budget.
|
|
127
|
+
`fun-ci status` now says `(cold worktree, budget 300s)`, not `new worktree`,
|
|
128
|
+
and a run in the foreground says `a cold worktree (new, just cleaned, or
|
|
129
|
+
unused for a day)`.
|
|
130
|
+
- The console holds at most the twenty branches whose newest run changed
|
|
131
|
+
last, before putting them in order, so a failure on a branch nobody has
|
|
132
|
+
touched since leaves the board once twenty others have moved on, instead
|
|
133
|
+
of staying at the top for good.
|
|
134
|
+
- `fun-ci init` refuses an option or argument it doesn't take (exit 64)
|
|
135
|
+
instead of ignoring it, so a misspelt `--everything` no longer sets up
|
|
136
|
+
only half.
|
|
137
|
+
|
|
138
|
+
### Fixed
|
|
139
|
+
- `fun-ci console` no longer dies with a `TypeError` while a project's first
|
|
140
|
+
fetch of its trunk is under way.
|
|
141
|
+
- A run the post-commit hook starts leads a session of its own, so Ctrl-C in
|
|
142
|
+
the terminal that committed, closing it, or an agent harness ending the
|
|
143
|
+
`git commit` command no longer kills the run's slow suite.
|
|
144
|
+
- A slow suite whose process died is no longer shown as a plain failure:
|
|
145
|
+
`fun-ci why` says its process stopped before it said how the stage ended,
|
|
146
|
+
as it already did for a job.
|
|
147
|
+
- Cancelling a run, or killing a stage over its budget, also stops what the
|
|
148
|
+
stage started that moved to a process group or session of its own, as
|
|
149
|
+
Node's detached children do: a superseded run left Playwright's web server
|
|
150
|
+
holding its port, and the next run failed on it. A child forked just as
|
|
151
|
+
the group was killed is killed too.
|
|
152
|
+
|
|
10
153
|
## [2.3.0] - 2026-10-02
|
|
11
154
|
|
|
12
155
|
### Added
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ fun-ci init --everything
|
|
|
23
23
|
|
|
24
24
|
This detects your project type, writes four stage scripts into `.fun-ci/`, installs a `post-commit` and a `pre-push` git hook, and checks the setup. It also adds a short section to your `AGENTS.md` (or `CLAUDE.md`, if that is the only one) telling coding agents what to do after a commit; run again after an upgrade, it brings that section up to date.
|
|
25
25
|
|
|
26
|
-
`fun-ci init` has templates for Ruby, Gradle, Maven, Rust, Go, Elixir, Dart, Swift, PHP, .NET, Python, Deno, Bun, Node, Perl, and C
|
|
26
|
+
`fun-ci init` has templates for Ruby, Gradle, Maven, Rust, Go, Elixir, Dart, Swift, PHP, .NET, Python, Deno, Bun, Node, Perl, and C and C++ built with CMake or make. [docs/stacks.md](docs/stacks.md) shows how it recognises each one and the commands it writes; `--stack go` picks one by name. In a project it doesn't recognise, such as a new one with no code yet, it writes placeholder scripts that pass, and `fun-ci check` warns about each one until you replace it. Fun-CI works with any project: the stages are shell scripts, so edit them to run whatever your project uses.
|
|
27
27
|
|
|
28
28
|
- `lint.sh`: linter and static analysis
|
|
29
29
|
- `build.sh`: compile or build
|
|
@@ -51,7 +51,7 @@ After each commit, the `post-commit` hook starts the pipeline in the background
|
|
|
51
51
|
|
|
52
52
|
`install-hooks` leaves a hook another tool wrote alone, and `fun-ci check` warns that no commit is tested until that hook calls fun-ci. Git LFS's own hooks are the exception: fun-ci writes its hooks in their place, and they run git-lfs's after fun-ci's, so LFS objects still reach the remote. After that, `git lfs install` says the hooks exist and exits 2, since it accepts no hook but its own; there is nothing for it to do. `git lfs update --force` would put git-lfs's back, leaving fun-ci out, until you run `fun-ci install-hooks` again.
|
|
53
53
|
|
|
54
|
-
Each run happens in a git worktree of its own
|
|
54
|
+
Each run happens in a git worktree of its own in fun-ci's state directory (`~/.local/state/fun-ci/projects/`, outside `.git/`, which tools such as Vite won't serve files from), checked out at the commit it tests, so you can keep editing while it runs. Ignored files such as `vendor/bundle` or `node_modules` stay in a worktree from one run to the next, which keeps builds quick. A worktree fun-ci has just made has none of them yet, and one nobody used for a day has them as they were then, so in such a run lint and build get the slow suite's five minutes rather than 30 seconds, and `fun-ci status` says so on their lines. A run's build outputs that git ignores stay too, and are only as right as the commit that made them, so a worktree that last tested another branch can hand a run outputs its commit wouldn't make. List those outputs in `.fun-ci/config`, such as `clean: [public/assets, dist]`, and fun-ci removes their ignored files when a worktree moves to a commit that doesn't descend from the one it last tested; that run's lint and build get the longer budget too. Two runs can go at once; set `worktree_slots: 3` in `.fun-ci/config` for more, and `fun-ci prune` removes the worktrees when you want the space back. A newer commit on a branch cancels the older run that is still going, unless a `fun-ci wait` without `--follow-branch` is watching it or its slow suite has started. A slow suite that started always finishes, and the newer run's slow suite waits for it (`waiting` in `fun-ci status`), so on a branch that takes commits faster than its slow suite runs, slow verdicts keep coming and the commits in between skip theirs. A `fun-ci wait` without `--follow-branch` whose run was cancelled anyway, because the newer commit landed before the wait first looked, starts that commit again and waits for that run. A commit run again cancels nothing, and its branch's row in the console stays with the newest commit.
|
|
55
55
|
|
|
56
56
|
Results are kept in SQLite under `$XDG_STATE_HOME/fun-ci/` (`~/.local/state/fun-ci/` by default), shared by every project on the machine.
|
|
57
57
|
|
|
@@ -68,7 +68,7 @@ The script's name is the job's name. Like a stage, it gets the commit's hash as
|
|
|
68
68
|
|
|
69
69
|
Commits start jobs. When the `post-commit` hook runs a pipeline, it also starts the project's due jobs on the commit just made: a job is due when it has never run, when its last run was cancelled, or a day (daily) or a week (weekly) after its last run started, so a project nobody commits to runs none. The jobs take turns, spread evenly over the day: with four jobs, the first starts at once and each next one six hours later. `job_spacing: 30m` in `.fun-ci/config` sets the gap instead, and `0` starts them together. A job waiting its turn says when it starts.
|
|
70
70
|
|
|
71
|
-
Each job runs once at a time, in a worktree of its own
|
|
71
|
+
Each job runs once at a time, in a worktree of its own beside them, at a lower priority than the stages, so it takes only the cores they leave idle and never holds up a commit's run. It has 24 hours. A newer commit never cancels a job, and a job's result changes no run, no streak and no exit code. The [design](docs/design.md#daily-and-weekly-jobs) has the rest of the rules.
|
|
72
72
|
|
|
73
73
|
A failed job keeps its evidence as a failed stage does; add entries under `evidence: jobs: <name>:` in `.fun-ci/config` to keep more. `fun-ci check` lists the jobs it found, and says which scripts it can't run.
|
|
74
74
|
|
|
@@ -80,7 +80,7 @@ A failed job keeps its evidence as a failed stage does; add entries under `evide
|
|
|
80
80
|
fun-ci console
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
The console shows where each branch stands, one row per branch under its project's name: a mark for each stage (lint, the build, the fast suite and the slow suite, named in a legend at the top of the table), what happened (`the fast suite failed after 1.4s`) and when. What needs you comes first, in one deep block; passed rows stay pale. Above them is a picture that tells you what is happening without reading a word.
|
|
83
|
+
The console shows where each branch stands, one row per branch under its project's name: a mark for each stage (lint, the build, the fast suite and the slow suite, named in a legend at the top of the table), what happened (`the fast suite failed after 1.4s`) and when. What needs you comes first, in one deep block; passed rows stay pale. It holds the twenty branches whose newest run changed last, so a failure on a branch nobody touches any more leaves it in time. Above them is a picture that tells you what is happening without reading a word.
|
|
84
84
|
|
|
85
85
|

|
|
86
86
|
|
|
@@ -119,12 +119,21 @@ Keys:
|
|
|
119
119
|
|
|
120
120
|
- `j` and `k`, or the arrow keys, move the cursor down and up
|
|
121
121
|
- `c` cancels the run under the cursor: one waiting to start at once, a running one once you answer `y` (`n` or `Esc` keeps it running); the footer offers it only while a run is running or waits to start. The cursor moves on past the last branch into the jobs, and `c` cancels a job too: one waiting its turn at once, a running one the same way; a cancelled job runs again on your next commit
|
|
122
|
+
- `h` hides the branch or job under the cursor, once you answer `s` (snooze) or `i` (ignore); `n` or `Esc` leaves it. `a` shows the hidden rows, and `h` on one of them brings it back (see [Hiding a branch or a job](#hiding-a-branch-or-a-job))
|
|
122
123
|
- `q` quits
|
|
123
124
|
|
|
124
125
|
The console is drawn in 24-bit colour when `COLORTERM` says the terminal has it (`truecolor` or `24bit`), and in 256 colours otherwise. The pictures above are the renderer's output replayed in a terminal emulator, set in Menlo; in your terminal the text is in your terminal's font.
|
|
125
126
|
|
|
126
127
|
The drawing is done by a separate program, `fun-ci-renderer`, written in Rust. The gem for Linux (x86_64, aarch64, musl) and macOS (arm64, x86_64) includes it. On other Unix-like systems you get the plain gem, where every command except `console` works; install the renderer with `cargo install fun-ci-renderer` (Rust 1.88 or newer), or point `FUN_CI_RENDERER` at a copy you built. Windows is not supported, because fun-ci forks its background pipeline, but WSL runs the Linux gem. When something goes wrong between the two, the details are in `.fun-ci/console.log`.
|
|
127
128
|
|
|
129
|
+
### Hiding a branch or a job
|
|
130
|
+
|
|
131
|
+
A branch you gave up on, or a job you already know is failing, can keep the top of the table red for days. Press `h` on its row and say how long it should stay out of view: `s` snoozes it until its next run, so it comes back when there is something new to see, and `i` ignores it until you bring it back. The footer counts the hidden rows. `a` shows them, pale, each saying how it was hidden, and `h` on one brings it back.
|
|
132
|
+
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
Hiding changes only what your console shows. The branch and the job still run, and `fun-ci jobs`, `status` and `why` report them as before, so an agent waiting on a commit sees everything.
|
|
136
|
+
|
|
128
137
|
## Asking: commands for agents and scripts
|
|
129
138
|
|
|
130
139
|
Every commit's output ends with the command that gets its verdict:
|
|
@@ -133,7 +142,7 @@ Every commit's output ends with the command that gets its verdict:
|
|
|
133
142
|
fun-ci: testing 3f9c2ab. Verdict: fun-ci wait 3f9c2ab --need all --follow-branch
|
|
134
143
|
```
|
|
135
144
|
|
|
136
|
-
The section `fun-ci init` writes into `AGENTS.md` tells an agent to run that command in the background after each commit. Agent harnesses wake the agent when a background command exits, so it hears about a failure without having to remember to ask. With `--follow-branch`, a newer commit on the branch cancels the older run, and the wait moves on to the newer run's verdict.
|
|
145
|
+
The section `fun-ci init` writes into `AGENTS.md` tells an agent to run that command in the background after each commit. Agent harnesses wake the agent when a background command exits, so it hears about a failure without having to remember to ask. With `--follow-branch`, a newer commit on the branch cancels the older run, and the wait moves on to the newer run's verdict. A slow suite that started is never cancelled, and the newest commit's waiting one goes next, so that wait ends within about two slow suites' time, however fast the commits come.
|
|
137
146
|
|
|
138
147
|
`status` says where a commit's run stands and `wait` blocks until it is decided. Both exit with the verdict for the stages you need: `--need build` (lint and build), `fast` (the default) or `all` (the slow suite too).
|
|
139
148
|
|
|
@@ -143,7 +152,7 @@ The section `fun-ci init` writes into `AGENTS.md` tells an agent to run that com
|
|
|
143
152
|
| 1 | A needed stage failed |
|
|
144
153
|
| 2 | A needed stage ran over budget |
|
|
145
154
|
| 3 | Still undecided (`wait --within 30s` gives up at your deadline) |
|
|
146
|
-
| 4 | Superseded by a newer commit on the branch (`wait --follow-branch` moves on to it) |
|
|
155
|
+
| 4 | Superseded by a newer commit on the branch (`wait --follow-branch` moves on to it; a plain `wait` first runs the commit again, once) |
|
|
147
156
|
| 5 | No run for the commit |
|
|
148
157
|
| 6 | Passed, but conflicts with the trunk (only with `--trunk`) |
|
|
149
158
|
| 64 | Usage error |
|
|
@@ -156,7 +165,7 @@ fun-ci: 2330979 "Add shipping to the cart total" on main
|
|
|
156
165
|
lint passed 0.6s
|
|
157
166
|
build passed 0.3s
|
|
158
167
|
fast FAILED 0.3s
|
|
159
|
-
slow passed 0.5s (not needed)
|
|
168
|
+
slow passed 0.5s (not needed for --need fast)
|
|
160
169
|
fast failed:
|
|
161
170
|
1) Failure:
|
|
162
171
|
CartTest#test_total_includes_shipping [test/cart_test.rb:16]:
|
|
@@ -189,7 +198,7 @@ The output's last lines, from output-tail:
|
|
|
189
198
|
The whole output: fun-ci why 2330979 fast --raw
|
|
190
199
|
```
|
|
191
200
|
|
|
192
|
-
`fun-ci runs` lists recent runs one line each, and `fun-ci events --follow` prints each run's events as JSON lines as they happen, for a supervising agent or a status bar.
|
|
201
|
+
`fun-ci runs` lists recent runs one line each, and `fun-ci events --follow` prints each run's events as JSON lines as they happen, for a supervising agent or a status bar. Each line has `at`, the time it happened, so the gap between two events can be read off the lines.
|
|
193
202
|
|
|
194
203
|
### Where your commit stands against the trunk
|
|
195
204
|
|
|
@@ -201,7 +210,7 @@ fun-ci: f473fdb "Add shipping to the cart total" on feat/cart
|
|
|
201
210
|
lint passed 0.2s
|
|
202
211
|
build passed 0.3s
|
|
203
212
|
fast passed 0.1s
|
|
204
|
-
slow passed 0.2s (not needed)
|
|
213
|
+
slow passed 0.2s (not needed for --need fast)
|
|
205
214
|
trunk conflicts origin/main 0e15acf, fetched just now, 1 ahead, 1 behind
|
|
206
215
|
lib/cart.rb
|
|
207
216
|
Conflicts with origin/main in 1 file. When the task is done, integrate: git pull origin main (or git pull --rebase origin main if the branch isn't shared)
|
|
@@ -246,6 +255,7 @@ Secrets in the stage's environment are masked before anything is kept: the value
|
|
|
246
255
|
```
|
|
247
256
|
fun-ci init Scaffold .fun-ci/ for the detected project type
|
|
248
257
|
fun-ci init --everything init + install-hooks + check in one step
|
|
258
|
+
fun-ci init --stack NAME Scaffold .fun-ci/ for the stack named, such as go
|
|
249
259
|
fun-ci install-hooks Install post-commit and pre-push hooks
|
|
250
260
|
fun-ci install-hooks post-commit Install a single hook type
|
|
251
261
|
fun-ci check Verify .fun-ci/ setup
|
|
@@ -264,7 +274,7 @@ fun-ci trigger --background <commit> <branch> Start the pipeline in the backgr
|
|
|
264
274
|
fun-ci prune Remove fun-ci's worktrees when no pipeline is running
|
|
265
275
|
```
|
|
266
276
|
|
|
267
|
-
`fun-ci --help` lists every option.
|
|
277
|
+
`fun-ci --help` lists every option, and `fun-ci COMMAND --help` a command's own.
|
|
268
278
|
|
|
269
279
|
## Upgrading to 2.0
|
|
270
280
|
|
data/lib/fun_ci/agent/events.rb
CHANGED
|
@@ -6,11 +6,17 @@ module FunCi
|
|
|
6
6
|
# (acceptance-tests.md, AT-9.16), oldest run first: a run started, each
|
|
7
7
|
# stage that finished in the order it finished, a run that passed or
|
|
8
8
|
# failed, a run a newer commit superseded, a check of its commit against
|
|
9
|
-
# the trunk recorded or made again. The first look is at nothing.
|
|
9
|
+
# the trunk recorded or made again. The first look is at nothing. Each
|
|
10
|
+
# event says when it happened (`at`), as the database kept it.
|
|
10
11
|
module Events
|
|
11
|
-
#
|
|
12
|
+
# When a run started, when its status last changed, and when the latest
|
|
13
|
+
# check of its commit against the trunk was made (nil without one):
|
|
14
|
+
# ISO 8601 times.
|
|
15
|
+
RunTimes = Data.define(:started, :changed, :checked)
|
|
16
|
+
|
|
17
|
+
# finished: [{ stage:, state:, seconds:, at: }, ...] in the order they finished;
|
|
12
18
|
# trunk: the latest check of its commit, as status --json gives it, or nil.
|
|
13
|
-
RunState = Data.define(:id, :sha, :branch, :status, :finished, :superseded_by, :trunk)
|
|
19
|
+
RunState = Data.define(:id, :sha, :branch, :status, :finished, :superseded_by, :trunk, :times)
|
|
14
20
|
|
|
15
21
|
class RunState
|
|
16
22
|
def initialize(trunk: nil, **) = super
|
|
@@ -31,7 +37,7 @@ module FunCi
|
|
|
31
37
|
|
|
32
38
|
def self.of(run, was)
|
|
33
39
|
about = { commit: run.sha, branch: run.branch }
|
|
34
|
-
[*(was ? [] : [{ event: "run_started", **about }]),
|
|
40
|
+
[*(was ? [] : [{ event: "run_started", **about, at: run.times.started }]),
|
|
35
41
|
*newly_finished(run, was).map { |stage| { event: "stage_finished", **about, **stage } },
|
|
36
42
|
*checked(run, was, about), *ended(run, was, about)]
|
|
37
43
|
end
|
|
@@ -46,14 +52,16 @@ module FunCi
|
|
|
46
52
|
trunk = run.trunk
|
|
47
53
|
return [] if trunk.nil? || trunk.values_at(:state, :sha) == was&.trunk&.values_at(:state, :sha)
|
|
48
54
|
|
|
49
|
-
[{ event: "trunk_checked", **about, trunk: trunk }]
|
|
55
|
+
[{ event: "trunk_checked", **about, trunk: trunk, at: run.times.checked }]
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def self.ended(run, was, about)
|
|
53
59
|
return [] if was&.status == run.status
|
|
54
|
-
return [{ event: "run_superseded", **about, by_commit: run.superseded_by }] if run.status == "cancelled"
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
at = run.times.changed
|
|
62
|
+
return [{ event: "run_superseded", **about, by_commit: run.superseded_by, at: at }] if run.status == "cancelled"
|
|
63
|
+
|
|
64
|
+
OUTCOMES.key?(run.status) ? [{ event: "run_finished", **about, state: OUTCOMES.fetch(run.status), at: at }] : []
|
|
57
65
|
end
|
|
58
66
|
private_class_method :of, :newly_finished, :checked, :ended
|
|
59
67
|
end
|
|
@@ -7,11 +7,17 @@ module FunCi
|
|
|
7
7
|
# What happened to a project's daily and weekly job runs between two
|
|
8
8
|
# looks at them (acceptance-tests.md, AT-13.23, AT-13.28), oldest first: a
|
|
9
9
|
# job run was scheduled to start later (Jobs::Schedule), started, and
|
|
10
|
-
# ended with its state and seconds. The first look is at nothing.
|
|
10
|
+
# ended with its state and seconds. The first look is at nothing. Each
|
|
11
|
+
# event says when it happened (`at`), as the database kept it.
|
|
11
12
|
module JobEvents
|
|
13
|
+
# When a commit claimed the run (nil for a run kept before that was
|
|
14
|
+
# recorded), when it started and when it ended (nil until it has, and
|
|
15
|
+
# for a run whose process died): ISO 8601 times.
|
|
16
|
+
JobTimes = Data.define(:claimed, :started, :ended)
|
|
17
|
+
|
|
12
18
|
# state: as Jobs::State says it; seconds: how long it ran, once it ended;
|
|
13
19
|
# starts_at: when a run waiting its turn starts, nil for any other.
|
|
14
|
-
JobState = Data.define(:id, :job, :cadence, :sha, :branch, :state, :seconds, :starts_at)
|
|
20
|
+
JobState = Data.define(:id, :job, :cadence, :sha, :branch, :state, :seconds, :starts_at, :times)
|
|
15
21
|
|
|
16
22
|
# The states of a run that has not ended.
|
|
17
23
|
GOING = %w[running due scheduled].freeze
|
|
@@ -31,9 +37,10 @@ module FunCi
|
|
|
31
37
|
# A run first seen waiting was scheduled; one that started since the
|
|
32
38
|
# last look started.
|
|
33
39
|
def self.begun(run, was, about)
|
|
34
|
-
|
|
40
|
+
scheduled = { event: "job_scheduled", **about, starts_at: run.starts_at, at: run.times.claimed }
|
|
41
|
+
return [scheduled] if run.state == "scheduled" && !was
|
|
35
42
|
|
|
36
|
-
started?(run, was) ? [{ event: "job_started", **about }] : []
|
|
43
|
+
started?(run, was) ? [{ event: "job_started", **about, at: run.times.started }] : []
|
|
37
44
|
end
|
|
38
45
|
|
|
39
46
|
# First seen past waiting, or past it now after it waited; one
|
|
@@ -48,7 +55,7 @@ module FunCi
|
|
|
48
55
|
def self.ended(run, was, about)
|
|
49
56
|
return [] if was&.state == run.state || GOING.include?(run.state)
|
|
50
57
|
|
|
51
|
-
[{ event: "job_finished", **about, state: run.state, seconds: run.seconds }]
|
|
58
|
+
[{ event: "job_finished", **about, state: run.state, seconds: run.seconds, at: run.times.ended }]
|
|
52
59
|
end
|
|
53
60
|
private_class_method :of, :begun, :started?, :ended
|
|
54
61
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module FunCi
|
|
4
|
+
module Agent
|
|
5
|
+
# What a wait does once the run it waited on is decided
|
|
6
|
+
# (acceptance-tests.md, AT-9.12, AT-9.21): `:follow` the branch to the
|
|
7
|
+
# commit that superseded the run, `:run_again` its own commit, once, or
|
|
8
|
+
# `:stop` with the report.
|
|
9
|
+
module Onward
|
|
10
|
+
# report: the decided report, nil when no run turned up; ran_again:
|
|
11
|
+
# whether this wait has run its commit again already.
|
|
12
|
+
def self.decide(report, follow_branch:, ran_again:)
|
|
13
|
+
return :stop unless report&.superseded_by
|
|
14
|
+
return :follow if follow_branch
|
|
15
|
+
return :run_again if report.verdict == :superseded && !ran_again
|
|
16
|
+
|
|
17
|
+
:stop
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/fun_ci/agent/output.rb
CHANGED
|
@@ -83,6 +83,13 @@ module FunCi
|
|
|
83
83
|
@stdout.puts "fun-ci: #{sha[0, 7]} was superseded; following #{report.branch} to #{report.superseded_by[0, 7]}."
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
# Says the wait starts the commit `sha` again, which a newer one superseded; JSON has only the answer.
|
|
87
|
+
def running_again(sha, report)
|
|
88
|
+
return if @json
|
|
89
|
+
|
|
90
|
+
@stdout.puts "fun-ci: #{sha[0, 7]} was superseded by #{report.superseded_by[0, 7]}; running it again."
|
|
91
|
+
end
|
|
92
|
+
|
|
86
93
|
# entries: [[report, age in words], ...], newest first.
|
|
87
94
|
def runs(entries)
|
|
88
95
|
return print_json(entries.map { |report, _| StatusJson.document(report) }) if @json
|
data/lib/fun_ci/agent/reports.rb
CHANGED
|
@@ -26,6 +26,9 @@ module FunCi
|
|
|
26
26
|
run && of(run, need)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# The id of the commit's newest run, or nil.
|
|
30
|
+
def latest_id(sha) = @runs.latest_of_commit(sha)&.fetch(:id)
|
|
31
|
+
|
|
29
32
|
# Checks the commit against where the trunk is now, and keeps the check.
|
|
30
33
|
def recheck_trunk(sha) = @details.recheck_trunk(sha)
|
|
31
34
|
|
|
@@ -38,7 +38,12 @@ module FunCi
|
|
|
38
38
|
JobEvents::JobState.new(id: run[:id], job: run[:job], cadence: run[:cadence], sha: run[:commit_hash],
|
|
39
39
|
branch: run[:branch], state: Jobs::State.of(run),
|
|
40
40
|
seconds: Persistence::StageJob.elapsed_duration(run)&.round(1),
|
|
41
|
-
starts_at: starts_at(run))
|
|
41
|
+
starts_at: starts_at(run), times: job_times(run))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def job_times(run)
|
|
45
|
+
JobEvents::JobTimes.new(claimed: stamp(run[:claimed_at]), started: stamp(run[:started_at]),
|
|
46
|
+
ended: stamp(run[:completed_at]))
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
# When a run waiting its turn starts, as an ISO time; nil for any other.
|
|
@@ -46,23 +51,36 @@ module FunCi
|
|
|
46
51
|
|
|
47
52
|
def state_of(run)
|
|
48
53
|
superseded_by = run[:status] == "cancelled" ? @runs.superseded_by(run) : nil
|
|
54
|
+
shown = recorded_check(run)
|
|
49
55
|
Events::RunState.new(id: run[:id], sha: run[:commit_hash], branch: run[:branch], status: run[:status],
|
|
50
|
-
finished: finished(run), superseded_by: superseded_by,
|
|
56
|
+
finished: finished(run), superseded_by: superseded_by,
|
|
57
|
+
trunk: shown && TrunkJson.document(shown), times: times(run, shown))
|
|
51
58
|
end
|
|
52
59
|
|
|
53
|
-
# The latest check recorded; a check still going has none yet.
|
|
54
|
-
def
|
|
60
|
+
# The latest check recorded, as shown; nil for a check still going, which has none yet.
|
|
61
|
+
def recorded_check(run)
|
|
55
62
|
shown = @trunk.for(run)
|
|
56
|
-
shown&.check ?
|
|
63
|
+
shown&.check ? shown : nil
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def times(run, shown)
|
|
67
|
+
checked = shown&.check&.checked_at
|
|
68
|
+
Events::RunTimes.new(started: stamp(run[:created_at]), changed: stamp(run[:updated_at]),
|
|
69
|
+
checked: checked&.utc&.iso8601)
|
|
57
70
|
end
|
|
58
71
|
|
|
72
|
+
# A time the database kept, as events say it: ISO 8601, UTC, to the second.
|
|
73
|
+
def stamp(kept) = kept && Time.parse(kept).utc.iso8601
|
|
74
|
+
|
|
59
75
|
def finished(run)
|
|
60
76
|
jobs = Persistence::StageJob.for_run(@db, run[:id]).select { |job| job[:finished_order] }
|
|
61
77
|
stages = RunReport.stages(jobs).to_h { |stage| [stage.name, stage] }
|
|
62
|
-
jobs.sort_by { |job| job[:finished_order] }.map { |job| facts(stages.fetch(job[:stage])) }
|
|
78
|
+
jobs.sort_by { |job| job[:finished_order] }.map { |job| facts(stages.fetch(job[:stage]), job) }
|
|
63
79
|
end
|
|
64
80
|
|
|
65
|
-
def facts(stage
|
|
81
|
+
def facts(stage, job)
|
|
82
|
+
{ stage: stage.name, state: stage.state, seconds: stage.seconds, at: stamp(job[:completed_at]) }
|
|
83
|
+
end
|
|
66
84
|
end
|
|
67
85
|
end
|
|
68
86
|
end
|
|
@@ -20,7 +20,8 @@ module FunCi
|
|
|
20
20
|
# about the verdict.
|
|
21
21
|
def self.lines(report, trunk: false, jobs: CommitJobs::NONE)
|
|
22
22
|
needed = Verdict::LEVELS.fetch(report.need)
|
|
23
|
-
[header(report), *report.stages.map { |stage| stage_line(stage,
|
|
23
|
+
[header(report), *report.stages.map { |stage| stage_line(stage, report.need) },
|
|
24
|
+
*Digest.lines(report.stages, needed),
|
|
24
25
|
*job_lines(jobs), *trunk(report, trunk), *footer(report)]
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -48,17 +49,20 @@ module FunCi
|
|
|
48
49
|
|
|
49
50
|
def self.header(report) = %(fun-ci: #{report.sha[0, 7]} "#{report.subject}" on #{report.branch})
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
# need: the level the verdict is decided at. A stage past it says for
|
|
53
|
+
# which level it is not needed, since a wait may be at another.
|
|
54
|
+
def self.stage_line(stage, need)
|
|
52
55
|
seconds = stage.seconds ? format("%6.1fs", stage.seconds) : " " * 7
|
|
53
|
-
|
|
56
|
+
beyond = Verdict::LEVELS.fetch(need).include?(stage.name) ? "" : " (not needed for --need #{need})"
|
|
57
|
+
note = beyond + longer(stage)
|
|
54
58
|
" #{stage.name.ljust(6)} #{WORDS.fetch(stage.state, stage.state).ljust(12)}#{seconds}#{note}".rstrip
|
|
55
59
|
end
|
|
56
60
|
|
|
57
|
-
# Only a worktree
|
|
61
|
+
# Only a cold worktree (WorktreePool) gives a stage more than its usual budget
|
|
58
62
|
# (AT-1.14), which a run in the background says nowhere else.
|
|
59
63
|
def self.longer(stage)
|
|
60
64
|
usual = Pipeline::DEFAULT_BUDGETS[stage.name]
|
|
61
|
-
stage.budget && usual && stage.budget > usual ? " (
|
|
65
|
+
stage.budget && usual && stage.budget > usual ? " (cold worktree, budget #{stage.budget}s)" : ""
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
def self.footer(report)
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
require_relative "command_support"
|
|
4
4
|
require_relative "output"
|
|
5
5
|
require_relative "waiting"
|
|
6
|
+
require_relative "onward"
|
|
6
7
|
|
|
7
8
|
module FunCi
|
|
8
9
|
module Agent
|
|
9
10
|
# `fun-ci wait [REV] [--need LEVEL] [--within DURATION] [--follow-branch] [--json]`
|
|
10
|
-
# (acceptance-tests.md, AT-9.9 to AT-9.12).
|
|
11
|
+
# (acceptance-tests.md, AT-9.9 to AT-9.12, AT-9.21).
|
|
11
12
|
class WaitCommand
|
|
12
13
|
include CommandSupport
|
|
13
14
|
|
|
@@ -16,7 +17,10 @@ module FunCi
|
|
|
16
17
|
# post-commit hook's run for a commit just made turns up well within it.
|
|
17
18
|
GRACE_SECONDS = 5
|
|
18
19
|
# The answer when no run turned up and the project can't start one.
|
|
19
|
-
NOT_SET_UP = Data.define(:verdict).new(verdict: :unknown)
|
|
20
|
+
NOT_SET_UP = Data.define(:verdict, :superseded_by).new(verdict: :unknown, superseded_by: nil)
|
|
21
|
+
# A superseded commit started again: the report on its superseded run,
|
|
22
|
+
# that run's id, and when it was started again.
|
|
23
|
+
Again = Data.define(:report, :run_id, :since)
|
|
20
24
|
|
|
21
25
|
def initialize(context)
|
|
22
26
|
@context = context
|
|
@@ -35,13 +39,32 @@ module FunCi
|
|
|
35
39
|
|
|
36
40
|
def deadline(options) = options.within && (@context.clock.now + options.within)
|
|
37
41
|
|
|
38
|
-
# Follows a superseded run on to the commit that superseded it, when asked to.
|
|
39
42
|
def wait_for(sha, options, deadline, output)
|
|
40
43
|
report = Waiting.new(@context.clock, deadline: deadline) { poll(sha, options) }.until_decided
|
|
41
|
-
|
|
44
|
+
step = Onward.decide(report, follow_branch: options.follow_branch, ran_again: !@again.nil?)
|
|
45
|
+
onward = carry_out(step, sha, report, output)
|
|
46
|
+
onward ? wait_for(onward, options, deadline, output) : report
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The commit to wait on next, having done what `step` says (Onward).
|
|
50
|
+
def carry_out(step, sha, report, output)
|
|
51
|
+
case step
|
|
52
|
+
in :follow then follow(sha, report, output)
|
|
53
|
+
in :run_again then run_again(sha, report, output)
|
|
54
|
+
in :stop then nil
|
|
55
|
+
end
|
|
56
|
+
end
|
|
42
57
|
|
|
58
|
+
def follow(sha, report, output)
|
|
43
59
|
output.following(sha, report)
|
|
44
|
-
|
|
60
|
+
report.superseded_by
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# The commit, once its pipeline is started again; nil when it can't be.
|
|
64
|
+
def run_again(sha, report, output)
|
|
65
|
+
@again = Again.new(report: report, run_id: reports.latest_id(sha), since: @context.clock.now)
|
|
66
|
+
output.running_again(sha, report)
|
|
67
|
+
sha if @context.pipeline.start(sha, report.branch)
|
|
45
68
|
end
|
|
46
69
|
|
|
47
70
|
def answer(sha, report, output)
|
|
@@ -56,9 +79,18 @@ module FunCi
|
|
|
56
79
|
def poll(sha, options)
|
|
57
80
|
@context.pipeline.watch(@context.db)
|
|
58
81
|
reports.mark_waited(sha, @context.clock.now) unless options.follow_branch
|
|
82
|
+
return run_again_report(sha, options) if @again
|
|
83
|
+
|
|
59
84
|
report_for(sha, options) || start_after_grace(sha)
|
|
60
85
|
end
|
|
61
86
|
|
|
87
|
+
# The commit's new run once it turns up; the superseded run's report once it hasn't in time.
|
|
88
|
+
def run_again_report(sha, options)
|
|
89
|
+
return report_for(sha, options) if reports.latest_id(sha) != @again.run_id
|
|
90
|
+
|
|
91
|
+
@again.report if @context.clock.now - @again.since >= GRACE_SECONDS
|
|
92
|
+
end
|
|
93
|
+
|
|
62
94
|
# Nil while waiting for a run; NOT_SET_UP once one can't be started.
|
|
63
95
|
def start_after_grace(sha)
|
|
64
96
|
@missing_since ||= @context.clock.now
|
data/lib/fun_ci/cli.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../fun_ci"
|
|
4
4
|
require_relative "cli_help"
|
|
5
|
+
require_relative "cli_command_help"
|
|
5
6
|
require_relative "pipeline/trigger_params"
|
|
6
7
|
require_relative "persistence/state_dir"
|
|
7
8
|
require_relative "setup/commands"
|
|
@@ -37,6 +38,7 @@ module FunCi
|
|
|
37
38
|
return CliHelp.version(@io.stdout) if subcommand == "--version"
|
|
38
39
|
|
|
39
40
|
return unknown_command(subcommand) unless ROUTES.key?(subcommand) || AGENT_COMMANDS.include?(subcommand)
|
|
41
|
+
return CliCommandHelp.help(@io.stdout, subcommand) if CliCommandHelp.asked?(args.drop(1))
|
|
40
42
|
|
|
41
43
|
dispatch(subcommand, args.drop(1))
|
|
42
44
|
end
|