OXYGENHUB

Event::ScheduleAt: the jobs with a schedule line due at a minute (refs #24) f2609cf795d8

Author
Andy McCall @andymccall <[email protected]>
When
· 2026-10-02 22:04 UTC
Signature
✔ signed by Andy McCall
Hash
f2609cf795d80aae88e715e237d4ac48404454b2060e27bbb96dcdad5fbc97a6
Depends on
bf7bb1b80fa3 e0918b887850
Depended on by
nothing yet
In bookmarks
main newer-pipeline push-uses-login
In tags
v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.5.0 v0.5.1 v0.5.2 v0.5.3
Edits
6 atoms, 0 tree operations, 2 files

Browse the tree at this change

modified crates/flow-core/src/pipeline.rs +19 −1
…
47 unchanged lines
48 48
    Tag(&'a str),
49 49
    /// "Run pipeline", `oh run start`.
50 50
    Manual,
51 -
    /// A `schedule` line came due.
51 +
    /// A rerun of a scheduled run: any job with a schedule.
52 52
    Schedule,
53 +
    /// The hub's clock at a minute (UTC): the jobs with a line due then.
54 +
    ScheduleAt(When),
53 55
}
54 56
57 +
/// A minute of the hub's clock, UTC, as cron reads it.
58 +
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
59 +
pub struct When {
60 +
    pub minute: u32,
61 +
    pub hour: u32,
62 +
    pub day: u32,
63 +
    pub month: u32,
64 +
    /// 0 is Sunday.
65 +
    pub weekday: u32,
66 +
}
67 +
55 68
impl On {
56 69
    /// What a job without any `on` runs for: every push, and by hand.
57 70
    pub fn default_on() -> On {
…
11 unchanged lines
69 82
            Event::Tag(t) => any(&self.tag, t),
70 83
            Event::Manual => self.manual,
71 84
            Event::Schedule => !self.schedule.is_empty(),
85 +
            Event::ScheduleAt(w) => self
86 +
                .schedule
87 +
                .iter()
88 +
                .filter_map(|l| crate::cron::Cron::parse(l))
89 +
                .any(|c| c.matches(w.minute, w.hour, w.day, w.month, w.weekday)),
72 90
        }
73 91
    }
74 92
}
…
987 unchanged lines
modified crates/flow-core/src/tests.rs +3 −0
…
430 unchanged lines
431 431
    assert!(runs("dist", Event::Tag("v0.3.1")) && !runs("dist", Event::Tag("nightly")));
432 432
    assert!(!runs("dist", Event::Push("main")) && runs("dist", Event::Manual));
433 433
    assert!(runs("nightly", Event::Schedule) && !runs("nightly", Event::Manual));
434 +
    use crate::pipeline::When;
435 +
    let at = |hour, minute| Event::ScheduleAt(When { minute, hour, day: 2, month: 10, weekday: 5 });
436 +
    assert!(runs("nightly", at(3, 0)) && !runs("nightly", at(3, 1)) && !runs("test", at(3, 0)));
434 437
    // Without any `on`, as before.
435 438
    let plain = text.replace("on {\n    push \"main\" \"feature/*\"\n    manual\n}\n", "");
436 439
    let p = Pipeline::parse(&plain).unwrap();
…
11 unchanged lines