ruby_raider 4.0.0 → 4.1.0
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/.github/ffmpeg/build.sh +208 -0
- data/.github/ffmpeg/check.sh +72 -0
- data/.github/ffmpeg/frames.rb +34 -0
- data/.github/ffmpeg/probe.sh +17 -0
- data/.github/workflows/ffmpeg.yml +160 -0
- data/README.md +226 -33
- data/RELEASE.md +19 -0
- data/lib/commands/flow_commands.rb +104 -0
- data/lib/generators/templates/common/read_me.tt +6 -7
- data/lib/generators/templates/flows/flow_helper.tt +42 -0
- data/lib/generators/templates/flows/run.tt +332 -0
- data/lib/generators/templates/helpers/video_helper.tt +1 -2
- data/lib/ruby_raider/ffmpeg.rb +38 -11
- data/lib/ruby_raider.rb +16 -0
- data/lib/utilities/flows/next_run.rb +61 -0
- data/lib/utilities/flows/notifier.rb +76 -0
- data/lib/utilities/flows/os/command_runner.rb +73 -0
- data/lib/utilities/flows/os/cron.rb +137 -0
- data/lib/utilities/flows/os/launchd.rb +164 -0
- data/lib/utilities/flows/os/linux.rb +63 -0
- data/lib/utilities/flows/os/systemd.rb +178 -0
- data/lib/utilities/flows/os/task_scheduler.rb +179 -0
- data/lib/utilities/flows/project.rb +170 -0
- data/lib/utilities/flows/run_log.rb +61 -0
- data/lib/utilities/flows/runner.rb +206 -0
- data/lib/utilities/flows/schedule.rb +221 -0
- data/lib/utilities/flows/schedule_store.rb +135 -0
- data/lib/utilities/flows/scheduler.rb +187 -0
- data/lib/version +1 -1
- data/sig/commands/flow_commands.rbs +13 -0
- data/sig/ruby_raider/ffmpeg.rbs +1 -0
- data/sig/ruby_raider.rbs +2 -0
- data/sig/utilities/flows/next_run.rbs +15 -0
- data/sig/utilities/flows/notifier.rbs +29 -0
- data/sig/utilities/flows/os/command_runner.rbs +27 -0
- data/sig/utilities/flows/os/cron.rbs +34 -0
- data/sig/utilities/flows/os/launchd.rbs +45 -0
- data/sig/utilities/flows/os/linux.rbs +27 -0
- data/sig/utilities/flows/os/systemd.rbs +43 -0
- data/sig/utilities/flows/os/task_scheduler.rbs +53 -0
- data/sig/utilities/flows/project.rbs +46 -0
- data/sig/utilities/flows/run_log.rbs +22 -0
- data/sig/utilities/flows/runner.rbs +35 -0
- data/sig/utilities/flows/schedule.rbs +61 -0
- data/sig/utilities/flows/schedule_store.rbs +34 -0
- data/sig/utilities/flows/scheduler.rbs +42 -0
- data/spec/commands/flow_commands_spec.rb +128 -0
- data/spec/generators/flow_helper_spec.rb +40 -0
- data/spec/generators/video_helper_spec.rb +21 -4
- data/spec/integration/content/gemfile_content_spec.rb +2 -2
- data/spec/integration/content/readme_content_spec.rb +7 -2
- data/spec/integration/end_to_end_spec.rb +83 -8
- data/spec/integration/flows/flow_project.rb +62 -0
- data/spec/integration/flows/run_command_spec.rb +91 -0
- data/spec/integration/flows/run_lifecycle_spec.rb +383 -0
- data/spec/utilities/ffmpeg_spec.rb +80 -7
- data/spec/utilities/flows/next_run_spec.rb +119 -0
- data/spec/utilities/flows/notifier_spec.rb +121 -0
- data/spec/utilities/flows/os/command_runner_spec.rb +56 -0
- data/spec/utilities/flows/os/cron_spec.rb +287 -0
- data/spec/utilities/flows/os/launchd_spec.rb +293 -0
- data/spec/utilities/flows/os/linux_spec.rb +149 -0
- data/spec/utilities/flows/os/systemd_spec.rb +329 -0
- data/spec/utilities/flows/os/task_scheduler_spec.rb +505 -0
- data/spec/utilities/flows/project_spec.rb +178 -0
- data/spec/utilities/flows/run_log_spec.rb +47 -0
- data/spec/utilities/flows/runner_spec.rb +313 -0
- data/spec/utilities/flows/schedule_spec.rb +233 -0
- data/spec/utilities/flows/schedule_store_spec.rb +137 -0
- data/spec/utilities/flows/scheduler_spec.rb +329 -0
- data/spec/utilities/video_command_spec.rb +13 -0
- metadata +58 -7
- data/docs/superpowers/plans/2026-10-25-failure-video-replay.md +0 -400
- data/docs/superpowers/plans/2026-10-26-parity-cleanup.md +0 -233
- data/docs/superpowers/plans/2026-10-28-failure-card.md +0 -295
- data/docs/superpowers/specs/2026-10-25-failure-video-replay-design.md +0 -214
- data/docs/superpowers/specs/2026-10-28-failure-card-design.md +0 -210
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
module Os
|
|
4
|
+
class Launchd
|
|
5
|
+
LAUNCHCTL: String
|
|
6
|
+
PLUTIL: String
|
|
7
|
+
NOFOLLOW: Integer
|
|
8
|
+
ESCAPES: Hash[String, String]
|
|
9
|
+
HEADER: String
|
|
10
|
+
OS_ID: Regexp
|
|
11
|
+
|
|
12
|
+
@runner: CommandRunner
|
|
13
|
+
@home: String
|
|
14
|
+
@uid: Integer
|
|
15
|
+
|
|
16
|
+
def initialize: (?runner: CommandRunner, ?home: String, ?uid: Integer) -> void
|
|
17
|
+
def label: () -> String
|
|
18
|
+
def plist: (Schedule schedule) -> String
|
|
19
|
+
def plist_path: (String os_id) -> String
|
|
20
|
+
def install: (Schedule schedule) -> true
|
|
21
|
+
def remove: (String os_id) -> bool
|
|
22
|
+
def present?: (String os_id) -> bool
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def launchctl: (*String args) -> CommandRunner::Result
|
|
27
|
+
def domain: () -> String
|
|
28
|
+
def service: (String os_id) -> String
|
|
29
|
+
def unlink: (String path) -> bool
|
|
30
|
+
def agents_dir: () -> String
|
|
31
|
+
def checked_os_id: (untyped os_id) -> String
|
|
32
|
+
def escape: (untyped text) -> String
|
|
33
|
+
def string: (untyped text) -> Array[String]
|
|
34
|
+
def integer: (Integer number) -> Array[String]
|
|
35
|
+
def array: (Array[Array[String]] items) -> Array[String]
|
|
36
|
+
def dict: (Array[[String, Array[String]]] pairs) -> Array[String]
|
|
37
|
+
def indent: (Array[String] lines) -> Array[String]
|
|
38
|
+
def calendar: (Schedule schedule) -> Array[String]
|
|
39
|
+
def weekday: (String day) -> Integer
|
|
40
|
+
def discard: (String path) -> String
|
|
41
|
+
def write: (String path, String text) -> void
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
module Os
|
|
4
|
+
class Linux
|
|
5
|
+
@primary: Systemd | Cron
|
|
6
|
+
@other: Cron?
|
|
7
|
+
@systemd: Systemd
|
|
8
|
+
|
|
9
|
+
def self.pick: (?CommandRunner runner) -> Linux
|
|
10
|
+
|
|
11
|
+
def initialize: (?runner: CommandRunner, ?systemd: Systemd, ?cron: Cron) -> void
|
|
12
|
+
def label: () -> String
|
|
13
|
+
def missed_runs_note: () -> String?
|
|
14
|
+
def install: (Schedule schedule) -> true
|
|
15
|
+
def remove: (String os_id) -> bool
|
|
16
|
+
def present?: (String os_id) -> bool
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def stranded?: (String os_id) -> bool
|
|
21
|
+
def refuse_stranded: (String os_id) -> void
|
|
22
|
+
|
|
23
|
+
def other_present?: (String os_id) -> bool
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
module Os
|
|
4
|
+
class Systemd
|
|
5
|
+
SYSTEMCTL: String
|
|
6
|
+
NOFOLLOW: Integer
|
|
7
|
+
QUOTED: Hash[String, String]
|
|
8
|
+
CALENDAR: Hash[String, String]
|
|
9
|
+
OS_ID: Regexp
|
|
10
|
+
UNSAFE_PATH: Regexp
|
|
11
|
+
|
|
12
|
+
@runner: CommandRunner
|
|
13
|
+
@home: String
|
|
14
|
+
@config_home: String?
|
|
15
|
+
|
|
16
|
+
def initialize: (?runner: CommandRunner, ?home: String, ?config_home: String?) -> void
|
|
17
|
+
def label: () -> String
|
|
18
|
+
def missed_runs_note: () -> nil
|
|
19
|
+
def service: (Schedule schedule) -> String
|
|
20
|
+
def timer: (Schedule schedule) -> String
|
|
21
|
+
def unit_path: (String os_id, String kind) -> String
|
|
22
|
+
def install: (Schedule schedule) -> true
|
|
23
|
+
def remove: (String os_id) -> bool
|
|
24
|
+
def present?: (String os_id) -> bool
|
|
25
|
+
def usable?: () -> bool
|
|
26
|
+
def unit_files?: (String os_id) -> bool
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def systemctl: (*String args) -> CommandRunner::Result
|
|
31
|
+
def units_dir: () -> String
|
|
32
|
+
def checked_os_id: (untyped os_id) -> String
|
|
33
|
+
def checked_path: (String path) -> void
|
|
34
|
+
def quote: (String text) -> String
|
|
35
|
+
def specifiers: (String text) -> String
|
|
36
|
+
def unlink: (String path) -> bool
|
|
37
|
+
def discard: (String os_id) -> String
|
|
38
|
+
def write: (Hash[String, String] texts) -> void
|
|
39
|
+
def temp_file: (String path, String text) -> String
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
module Os
|
|
4
|
+
class TaskScheduler
|
|
5
|
+
interface _Clock
|
|
6
|
+
def now: () -> Time
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
FOLDER: String
|
|
10
|
+
ESCAPES: Hash[String, String]
|
|
11
|
+
NAMESPACE: String
|
|
12
|
+
OS_ID: Regexp
|
|
13
|
+
NEEDS_QUOTES: Regexp
|
|
14
|
+
GLOB: Regexp
|
|
15
|
+
EXPANDS: Regexp
|
|
16
|
+
DAY_NAMES: Array[String]
|
|
17
|
+
|
|
18
|
+
@runner: CommandRunner
|
|
19
|
+
@clock: _Clock
|
|
20
|
+
@schtasks: String
|
|
21
|
+
|
|
22
|
+
def self.quote: (String arg) -> String
|
|
23
|
+
def self.glob_quote: (String arg) -> String
|
|
24
|
+
def self.odd_doubled: (String slashes) -> String
|
|
25
|
+
def self.join: (Array[String] args) -> String
|
|
26
|
+
|
|
27
|
+
def initialize: (?runner: CommandRunner, ?clock: _Clock, ?schtasks: String) -> void
|
|
28
|
+
def label: () -> String
|
|
29
|
+
def task_name: (untyped os_id) -> String
|
|
30
|
+
def task_xml: (Schedule schedule) -> String
|
|
31
|
+
def install: (Schedule schedule) -> true
|
|
32
|
+
def remove: (String os_id) -> bool
|
|
33
|
+
def present?: (String os_id) -> bool
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def schtasks: (*String args) -> CommandRunner::Result
|
|
38
|
+
def list: () -> CommandRunner::Result
|
|
39
|
+
def listed?: (CommandRunner::Result listing, String name) -> bool
|
|
40
|
+
def refuse_expansion: (Schedule schedule) -> void
|
|
41
|
+
def checked_os_id: (untyped os_id) -> String
|
|
42
|
+
def escape: (untyped value) -> String
|
|
43
|
+
def text: (String name, untyped value) -> Array[String]
|
|
44
|
+
def element: (String tag, Array[untyped] children) -> Array[String]
|
|
45
|
+
def indent: (Array[String] lines) -> Array[String]
|
|
46
|
+
def trigger: (Schedule schedule) -> Array[untyped]
|
|
47
|
+
def calendar: (Schedule schedule, String every) -> Array[String]
|
|
48
|
+
def settings: () -> Array[Array[String]]
|
|
49
|
+
def action: (Schedule schedule) -> Array[Array[String]]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
NAME: Regexp
|
|
4
|
+
RESERVED: Array[String]
|
|
5
|
+
|
|
6
|
+
def self.valid_name?: (untyped name) -> bool
|
|
7
|
+
def self.printable: (untyped text) -> String
|
|
8
|
+
|
|
9
|
+
class Error < StandardError
|
|
10
|
+
attr_reader exit_code: Integer
|
|
11
|
+
|
|
12
|
+
def initialize: (String message, ?exit_code: Integer) -> void
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Project
|
|
16
|
+
UNSUPPORTED: String
|
|
17
|
+
GITIGNORE_LINES: Array[String]
|
|
18
|
+
TEMPLATES: Hash[String, String]
|
|
19
|
+
PIN: Regexp
|
|
20
|
+
FLOWS_PIN: Array[Integer]
|
|
21
|
+
|
|
22
|
+
attr_reader root: String
|
|
23
|
+
|
|
24
|
+
def initialize: (String path) -> void
|
|
25
|
+
def path: (String relative) -> String
|
|
26
|
+
def flow_file: (String name) -> String
|
|
27
|
+
def flow_names: () -> Array[String]
|
|
28
|
+
def set_up?: () -> bool
|
|
29
|
+
def unsupported_reason: () -> String?
|
|
30
|
+
def init: (?out: IO | StringIO, ?err: IO | StringIO) -> Integer
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def template_dir: () -> String
|
|
35
|
+
def read: (String relative) -> String?
|
|
36
|
+
def selenium?: (String gemfile) -> bool
|
|
37
|
+
def runtime?: () -> bool
|
|
38
|
+
def old_pin?: (String gemfile) -> bool
|
|
39
|
+
def write_templates: () -> Array[String]
|
|
40
|
+
def add_gitignore_lines: () -> Array[String]
|
|
41
|
+
def pin_gem: () -> bool
|
|
42
|
+
def warn_unknown_pin: (IO | StringIO err) -> void
|
|
43
|
+
def report: (IO | StringIO out, Array[String] created, Array[String] updated, bool pinned) -> void
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
class RunLog
|
|
4
|
+
MAX_BYTES: Integer
|
|
5
|
+
NOFOLLOW: Integer
|
|
6
|
+
NONBLOCK: Integer
|
|
7
|
+
SUMMARY: Array[String]
|
|
8
|
+
|
|
9
|
+
def self.summaries: (Project project) -> Array[Hash[String, untyped]]
|
|
10
|
+
|
|
11
|
+
def initialize: (Project project, String name) -> void
|
|
12
|
+
def lines: () -> Array[Hash[String, untyped]]
|
|
13
|
+
def last: () -> Hash[String, untyped]?
|
|
14
|
+
def last_result: () -> Hash[String, untyped]?
|
|
15
|
+
def find: (String run_id) -> Hash[String, untyped]?
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def tail: () -> String
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
class Runner
|
|
4
|
+
EXIT_CODES: Hash[String, Integer]
|
|
5
|
+
INPUT: Regexp
|
|
6
|
+
INPUT_RULE: String
|
|
7
|
+
TRIGGERS: Array[String]
|
|
8
|
+
RETRY_WAIT: Integer
|
|
9
|
+
|
|
10
|
+
def self.spawn: (Hash[String, String?] env, Array[String] argv, String chdir) -> Integer?
|
|
11
|
+
def self.stopped: () -> bool?
|
|
12
|
+
def self.stopped=: (bool) -> bool
|
|
13
|
+
def self.interrupt: (Integer pid) -> void
|
|
14
|
+
|
|
15
|
+
def initialize: (Project project, ?out: IO | StringIO, ?spawner: untyped, ?sleeper: untyped, ?notifier: untyped) -> void
|
|
16
|
+
def run: (String name, ?headed: bool?, ?retries: untyped, ?inputs: Array[String]?, ?trigger: String, ?notify: bool) -> Integer
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def attempt_runs: (String name, Integer attempts, Hash[Symbol, untyped] options) -> String
|
|
21
|
+
def notify_failure: (String name, String status, String trigger) -> bool
|
|
22
|
+
def start_output: (String name, String trigger) -> String
|
|
23
|
+
def stopped: (String name, String status) -> String
|
|
24
|
+
def attempt_run: (String name, Integer attempt, Hash[Symbol, untyped] options) -> String
|
|
25
|
+
def run_env: (String name, Integer attempt, String run_id, Hash[Symbol, untyped] options) -> Hash[String, String?]
|
|
26
|
+
def input_env: (Array[String]? inputs) -> Hash[String, String]
|
|
27
|
+
def checked_trigger: (String trigger) -> String
|
|
28
|
+
def checked_retries: (untyped retries) -> Integer
|
|
29
|
+
def report: (String name, Hash[String, untyped]? line, Integer? code) -> void
|
|
30
|
+
def outcome: (Hash[String, untyped] line) -> String
|
|
31
|
+
def failed_step: (untyped step) -> String
|
|
32
|
+
def duration: (Hash[String, untyped] line) -> (Float | String)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
class Schedule
|
|
4
|
+
EVERY: Array[String]
|
|
5
|
+
DAYS: Array[String]
|
|
6
|
+
DAYS_RULE: String
|
|
7
|
+
CLOCK: Regexp
|
|
8
|
+
MINUTE: Regexp
|
|
9
|
+
GEM_ENV: Array[String]
|
|
10
|
+
SYSTEM_PATH: Array[String]
|
|
11
|
+
OS_ID_PREFIX: String
|
|
12
|
+
KEYS: Array[String]
|
|
13
|
+
|
|
14
|
+
attr_reader name: String
|
|
15
|
+
attr_reader every: String
|
|
16
|
+
attr_reader at: String
|
|
17
|
+
attr_reader on: String?
|
|
18
|
+
attr_reader retries: Integer
|
|
19
|
+
attr_reader inputs: Array[String]
|
|
20
|
+
attr_reader notify: bool
|
|
21
|
+
attr_reader os_id: String
|
|
22
|
+
attr_reader ruby: String
|
|
23
|
+
attr_reader bundle: String
|
|
24
|
+
attr_reader gem_env: Hash[String, String]
|
|
25
|
+
attr_reader project_root: String
|
|
26
|
+
attr_reader created_at: String
|
|
27
|
+
|
|
28
|
+
def self.build: (project: Project, name: String, every: String, ?at: String?, ?on: String?, ?retries: untyped, ?inputs: Array[String], ?notify: bool, ?now: Time) -> Schedule
|
|
29
|
+
def self.from_h: (untyped hash, String project_root) -> Schedule
|
|
30
|
+
def self.os_id_for: (String project_root, String name) -> String
|
|
31
|
+
def self.bundle_path: () -> String
|
|
32
|
+
def self.captured_gem_env: () -> Hash[String, String]
|
|
33
|
+
|
|
34
|
+
def initialize: (name: untyped, every: untyped, at: untyped, on: untyped, retries: untyped, inputs: untyped, os_id: untyped, ruby: untyped, bundle: untyped, gem_env: untyped, project_root: untyped, created_at: untyped, ?notify: untyped) -> void
|
|
35
|
+
def hour: () -> Integer
|
|
36
|
+
def minute: () -> Integer
|
|
37
|
+
def days: () -> Array[String]
|
|
38
|
+
def argv: () -> Array[String]
|
|
39
|
+
def env: () -> Hash[String, String]
|
|
40
|
+
def working_directory: () -> String
|
|
41
|
+
def log_path: () -> String
|
|
42
|
+
def rule_text: () -> String
|
|
43
|
+
def to_h: () -> Hash[String, untyped]
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def checked_name: (untyped name) -> String
|
|
48
|
+
def checked_every: (untyped every) -> String
|
|
49
|
+
def checked_at: (untyped at) -> String
|
|
50
|
+
def clock: (untyped at) -> String
|
|
51
|
+
def checked_on: (untyped on) -> String?
|
|
52
|
+
def checked_retries: (untyped retries) -> Integer
|
|
53
|
+
def checked_inputs: (untyped inputs) -> Array[String]
|
|
54
|
+
def checked_notify: (untyped notify) -> bool
|
|
55
|
+
def checked_os_id: (untyped os_id) -> String
|
|
56
|
+
def checked_path: (String label, untyped path) -> String
|
|
57
|
+
def checked_gem_env: (untyped gem_env) -> Hash[String, String]
|
|
58
|
+
def checked_text: (String label, untyped text) -> String
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
class ScheduleStore
|
|
4
|
+
DIR: String
|
|
5
|
+
FILE: String
|
|
6
|
+
NOFOLLOW: Integer
|
|
7
|
+
NONBLOCK: Integer
|
|
8
|
+
|
|
9
|
+
class Removed
|
|
10
|
+
attr_reader name: String
|
|
11
|
+
attr_reader os_id: String
|
|
12
|
+
|
|
13
|
+
def initialize: (String name, String os_id) -> void
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize: (Project project) -> void
|
|
17
|
+
def all: () -> Array[Schedule]
|
|
18
|
+
def find: (String name) -> Schedule?
|
|
19
|
+
def save: (Schedule schedule) -> Schedule
|
|
20
|
+
def writable!: () -> nil
|
|
21
|
+
def delete: (String name) -> (Schedule | Removed)?
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def from_entry: (untyped entry) -> Schedule?
|
|
26
|
+
def named?: (untyped entry, String name) -> bool
|
|
27
|
+
def read_entries: () -> Array[untyped]?
|
|
28
|
+
def writable_entries: () -> Array[untyped]
|
|
29
|
+
def read_text: () -> (String | false)?
|
|
30
|
+
def write: (Array[untyped] entries) -> void
|
|
31
|
+
def private_dir: () -> String
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module RubyRaider
|
|
2
|
+
module Flows
|
|
3
|
+
class Scheduler
|
|
4
|
+
NOT_SET_UP: String
|
|
5
|
+
RUBY_NOT_FOUND: String
|
|
6
|
+
FLOW_NOT_FOUND: String
|
|
7
|
+
LAST: Array[String]
|
|
8
|
+
TIME: String
|
|
9
|
+
|
|
10
|
+
type row = { json: Hash[String, untyped], text: String }
|
|
11
|
+
|
|
12
|
+
@project: Project
|
|
13
|
+
@adapter: untyped
|
|
14
|
+
@store: ScheduleStore
|
|
15
|
+
@out: IO | StringIO
|
|
16
|
+
@err: IO | StringIO
|
|
17
|
+
@now: ^() -> Time
|
|
18
|
+
|
|
19
|
+
def self.adapter: (?runner: Os::CommandRunner, ?host_os: String) -> (Os::Launchd | Os::TaskScheduler | Os::Linux)
|
|
20
|
+
|
|
21
|
+
def initialize: (Project project, ?adapter: untyped, ?store: ScheduleStore, ?out: IO | StringIO, ?err: IO | StringIO, ?now: ^() -> Time) -> void
|
|
22
|
+
def schedule: (String name, every: String?, ?at: String?, ?on: String?, ?retries: untyped, ?inputs: Array[String], ?notify: bool) -> void
|
|
23
|
+
def unschedule: (String name) -> void
|
|
24
|
+
def schedules: (?json: bool) -> void
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def adapter: () -> untyped
|
|
29
|
+
def save: (Schedule schedule) -> Schedule
|
|
30
|
+
def delete: (String name, String label) -> (Schedule | ScheduleStore::Removed)?
|
|
31
|
+
def flow_dir: (String name) -> void
|
|
32
|
+
def private_dir: (String relative) -> void
|
|
33
|
+
def row: (Schedule schedule, Time now) -> row
|
|
34
|
+
def unlisted_rows: (Array[String] listed) -> Array[row]
|
|
35
|
+
def present?: (String os_id) -> bool
|
|
36
|
+
def os_state: (Schedule schedule) -> String
|
|
37
|
+
def rule: (Schedule schedule) -> String
|
|
38
|
+
def last_run: (String name) -> Hash[String, untyped]?
|
|
39
|
+
def line: (String name, String rule, String next_run, Hash[String, untyped]? last, String state) -> String
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require_relative '../../lib/ruby_raider'
|
|
6
|
+
|
|
7
|
+
RSpec.describe FlowCommands do
|
|
8
|
+
let(:raider_bin) { File.expand_path('../../bin/raider', __dir__) }
|
|
9
|
+
|
|
10
|
+
def run_raider(*args)
|
|
11
|
+
Open3.capture3(RbConfig.ruby, raider_bin, *args)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'lists init, run and list in raider flow help' do
|
|
15
|
+
out, _err, status = run_raider('flow', 'help')
|
|
16
|
+
|
|
17
|
+
expect(status.exitstatus).to eq(0)
|
|
18
|
+
expect(out).to include('flow init', 'flow run NAME', 'flow list')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'maps raider f to the flow commands' do
|
|
22
|
+
out, _err, status = run_raider('f', 'help')
|
|
23
|
+
|
|
24
|
+
expect(status.exitstatus).to eq(0)
|
|
25
|
+
expect(out).to include('flow run NAME')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'is listed in raider help' do
|
|
29
|
+
out, = run_raider('help')
|
|
30
|
+
|
|
31
|
+
expect(out).to include('raider flow')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'init' do
|
|
35
|
+
it 'sets up flows in the --project folder from any working directory' do
|
|
36
|
+
Dir.mktmpdir('flow-init') do |dir|
|
|
37
|
+
File.write(File.join(dir, 'Gemfile'), "gem 'ruby_raider', '~> 4.0'\ngem 'selenium-webdriver'\n")
|
|
38
|
+
FileUtils.mkdir_p(File.join(dir, 'helpers'))
|
|
39
|
+
File.write(File.join(dir, 'helpers/driver_helper.rb'), "require 'ruby_raider/runtime'\n")
|
|
40
|
+
|
|
41
|
+
out, _err, status = run_raider('flow', 'init', '--project', dir)
|
|
42
|
+
|
|
43
|
+
expect(status.exitstatus).to eq(0)
|
|
44
|
+
expect(out).to include('Created flows/flow_helper.rb', 'Run bundle install')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'exits 2 for a project that cannot hold flows' do
|
|
49
|
+
Dir.mktmpdir('flow-init') do |dir|
|
|
50
|
+
_out, err, status = run_raider('flow', 'init', '--project', dir)
|
|
51
|
+
|
|
52
|
+
expect(status.exitstatus).to eq(2)
|
|
53
|
+
expect(err).to include('Flows need a Selenium web project made with Ruby Raider 4.0 or later')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'exits 2 for a missing project folder' do
|
|
58
|
+
_out, err, status = run_raider('flow', 'init', '--project', '/nonexistent/raider')
|
|
59
|
+
|
|
60
|
+
expect(status.exitstatus).to eq(2)
|
|
61
|
+
expect(err).to include('Project folder not found')
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'offers --notify on flow run and flow schedule' do
|
|
66
|
+
run_help, = run_raider('flow', 'help', 'run')
|
|
67
|
+
schedule_help, = run_raider('flow', 'help', 'schedule')
|
|
68
|
+
|
|
69
|
+
expect([run_help, schedule_help]).to all(include('--notify'))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe 'schedules' do
|
|
73
|
+
# Only paths refused before the OS scheduler is asked: this machine's launchd is real
|
|
74
|
+
it 'lists schedule, unschedule and schedules in raider flow help' do
|
|
75
|
+
out, _err, status = run_raider('flow', 'help')
|
|
76
|
+
|
|
77
|
+
expect(status.exitstatus).to eq(0)
|
|
78
|
+
expect(out).to include('flow schedule NAME', 'flow unschedule NAME', 'flow schedules')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'dispatches raider flow schedule NAME to schedule, not schedules' do
|
|
82
|
+
Dir.mktmpdir('flow-schedule') do |dir|
|
|
83
|
+
_out, err, status = run_raider('flow', 'schedule', 'x', '--every', 'day', '--at', '08:00', '--project', dir)
|
|
84
|
+
|
|
85
|
+
expect(status.exitstatus).to eq(2)
|
|
86
|
+
expect(err).to include('No flow x: flows/x_flow.rb not found')
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'exits 2 through the rule check when --every is left out' do
|
|
91
|
+
Dir.mktmpdir('flow-schedule') do |dir|
|
|
92
|
+
%w[flows/flow_helper.rb flows/support/run.rb flows/report_flow.rb].each do |file|
|
|
93
|
+
FileUtils.mkdir_p(File.dirname(File.join(dir, file)))
|
|
94
|
+
File.write(File.join(dir, file), '')
|
|
95
|
+
end
|
|
96
|
+
_out, err, status = run_raider('flow', 'schedule', 'report', '--at', '08:00', '--project', dir)
|
|
97
|
+
|
|
98
|
+
expect(status.exitstatus).to eq(2)
|
|
99
|
+
expect(err).to include('Invalid every nil: use hour, day, weekday or week')
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'exits 2 for an invalid name to unschedule' do
|
|
104
|
+
Dir.mktmpdir('flow-schedule') do |dir|
|
|
105
|
+
_out, err, status = run_raider('flow', 'unschedule', 'Bad-Name', '--project', dir)
|
|
106
|
+
|
|
107
|
+
expect(status.exitstatus).to eq(2)
|
|
108
|
+
expect(err).to include('Invalid flow name "Bad-Name"')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'exits 2 with a message for an argument that is not valid UTF-8' do
|
|
113
|
+
_out, err, status = run_raider('flow', 'schedule', "a\xFF".b, '--every', 'day')
|
|
114
|
+
|
|
115
|
+
expect(status.exitstatus).to eq(2)
|
|
116
|
+
expect(err).to eq("Invalid argument \"a\\xFF\": use valid UTF-8\n")
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'says there are no schedules, as text and as JSON' do
|
|
120
|
+
Dir.mktmpdir('flow-schedule') do |dir|
|
|
121
|
+
text, = run_raider('flow', 'schedules', '--project', dir)
|
|
122
|
+
json, = run_raider('flow', 'schedules', '--json', '--project', dir)
|
|
123
|
+
|
|
124
|
+
expect([text, json]).to eq(["No schedules yet: raider flow schedule <name> --every day --at 08:00\n", "[]\n"])
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'erb'
|
|
4
|
+
|
|
5
|
+
# The flow templates are copied into projects by `raider flow init`
|
|
6
|
+
RSpec.describe 'flow templates' do
|
|
7
|
+
let(:templates) { File.expand_path('../../lib/generators/templates', __dir__) }
|
|
8
|
+
let(:helper) { render('flows/flow_helper.tt') }
|
|
9
|
+
|
|
10
|
+
def render(relative) = ERB.new(File.read(File.join(templates, relative)), trim_mode: '-').result
|
|
11
|
+
|
|
12
|
+
it 'starts the run before loading spec_helper, so the lock and HEADLESS come before the driver' do
|
|
13
|
+
expect(helper.index('RaiderFlows::Run.start!')).to be < helper.index("require_relative '../helpers/spec_helper'")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'sends the report to the flow results folder without cleaning it, even when start! refuses the run' do
|
|
17
|
+
expect(helper).to match(/begin\n RaiderFlows::Run.start!\nensure\n RaiderFlows::Run.configure_reporter\nend/)
|
|
18
|
+
expect(render('flows/run.tt')).to include('reporter.output_dir = results_dir ||', 'reporter.clean_output_dir = false')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'never retries a flow inside one run' do
|
|
22
|
+
expect(helper).to include('config.default_retry_count = 0')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'marks the start of the steps after spec_helper set up the driver' do
|
|
26
|
+
expect(helper).to include('config.append_before(:each) { RaiderFlows::Run.steps_started! }')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'never sets the reporter output folder from spec_helper, so a test run cannot wipe flow results' do
|
|
30
|
+
spec_helper = File.read(File.join(templates, 'helpers/spec_helper.tt'))
|
|
31
|
+
|
|
32
|
+
expect(spec_helper).not_to match(/output_dir|clean_output_dir/)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'renders Ruby that parses' do
|
|
36
|
+
[helper, render('flows/run.tt')].each do |source|
|
|
37
|
+
expect { RubyVM::InstructionSequence.compile(source) }.not_to raise_error
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -128,6 +128,19 @@ describe 'Generated VideoHelper' do
|
|
|
128
128
|
expect(argv.each_cons(2).to_a).to include(['-vf', "scale='min(1280,iw)':-2"])
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
+
# The pinned ffmpeg has only what this encode needs (.github/ffmpeg/build.sh), and
|
|
132
|
+
# .github/ffmpeg/check.sh proves it on every build: both must run the same arguments.
|
|
133
|
+
it 'runs the encode that .github/ffmpeg/check.sh proves on the pinned ffmpeg builds' do
|
|
134
|
+
recorder = VideoHelper.recorder_for(driver)
|
|
135
|
+
recorder.start
|
|
136
|
+
recorder.stop(keep: true)
|
|
137
|
+
|
|
138
|
+
check = File.read(File.expand_path('../../.github/ffmpeg/check.sh', __dir__)).gsub(/\\\n\s*/, '')
|
|
139
|
+
shell = argv[0..-2].map { |arg| arg.include?("'") ? %("#{arg}") : arg }
|
|
140
|
+
shell[shell.index('-i') + 1] = '"$work/list.txt"'
|
|
141
|
+
expect(check).to include(%("$binary" #{shell.join(' ')} "$work/video.webm"))
|
|
142
|
+
end
|
|
143
|
+
|
|
131
144
|
context 'when the config sets other fps and max_width' do
|
|
132
145
|
let(:video_config) { { 'enabled' => true, 'fps' => 10, 'max_width' => 640 } }
|
|
133
146
|
|
|
@@ -351,9 +364,14 @@ describe 'Generated VideoHelper' do
|
|
|
351
364
|
end
|
|
352
365
|
end
|
|
353
366
|
|
|
354
|
-
context 'when no ffmpeg can be obtained (no override,
|
|
367
|
+
context 'when no ffmpeg can be obtained (no override, no build for this platform)' do
|
|
355
368
|
let(:env) { { 'RAIDER_FFMPEG_PATH' => nil } }
|
|
356
369
|
|
|
370
|
+
before do
|
|
371
|
+
require 'ruby_raider/ffmpeg'
|
|
372
|
+
stub_const('RubyRaider::Ffmpeg::MANIFEST', { version: '7.1', assets: {} })
|
|
373
|
+
end
|
|
374
|
+
|
|
357
375
|
it 'decides once, at the first call: listener nil, NullRecorder, exactly one [video] line' do
|
|
358
376
|
require 'ruby_raider/ffmpeg'
|
|
359
377
|
allow(RubyRaider::Ffmpeg).to receive(:ensure!)
|
|
@@ -362,9 +380,8 @@ describe 'Generated VideoHelper' do
|
|
|
362
380
|
expect(warnings.size).to eq(1)
|
|
363
381
|
expect(VideoHelper.recorder_for(driver)).to be_a(VideoHelper::NullRecorder)
|
|
364
382
|
expect(VideoHelper.listener).to be_nil
|
|
365
|
-
expect(warnings).to eq(['[video] no ffmpeg
|
|
366
|
-
|
|
367
|
-
"recording disabled for this run\n"])
|
|
383
|
+
expect(warnings).to eq(['[video] no ffmpeg download for this platform (set RAIDER_FFMPEG_PATH to an ffmpeg ' \
|
|
384
|
+
"with libvpx); recording disabled for this run\n"])
|
|
368
385
|
expect(RubyRaider::Ffmpeg).not_to have_received(:ensure!)
|
|
369
386
|
expect(shots).to be_empty
|
|
370
387
|
end
|
|
@@ -85,8 +85,8 @@ describe 'Gemfile content' do
|
|
|
85
85
|
expect(gemfile).to include("gem 'ruby_raider', '~> #{major_minor}'")
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
it 'pins ruby_raider to the 4.
|
|
89
|
-
expect(gemfile).to include("gem 'ruby_raider', '~> 4.
|
|
88
|
+
it 'pins ruby_raider to the 4.1 release line' do
|
|
89
|
+
expect(gemfile).to include("gem 'ruby_raider', '~> 4.1'")
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
@@ -17,8 +17,13 @@ describe 'Generated Readme content' do
|
|
|
17
17
|
'RAIDER_CACHE_DIR', 'raider-results/attachments/')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
it '
|
|
21
|
-
expect(section).to include('ffmpeg-7.1'
|
|
20
|
+
it 'names the ffmpeg-7.1 release and no longer says it is unpublished' do
|
|
21
|
+
expect(section).to include('ffmpeg-7.1') if web
|
|
22
|
+
expect(section).not_to include('not published yet')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'lists the platforms with an ffmpeg download for web projects' do
|
|
26
|
+
expect(section).to include('macOS (Apple silicon and Intel), Linux x64 and Windows x64') if web
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
it 'names the right video format and how to turn video off for this project' do
|