@@ -5,7 +5,7 @@ use std::{
5
5
} ;
6
6
7
7
use crate :: load:: { partition_in_place, SiteCtxt } ;
8
- use chrono:: { DateTime , NaiveDate , Timelike , Utc } ;
8
+ use chrono:: { DateTime , NaiveDate , Utc } ;
9
9
use database:: { BenchmarkRequest , BenchmarkRequestStatus , BenchmarkRequestType } ;
10
10
use hashbrown:: HashSet ;
11
11
use parking_lot:: RwLock ;
@@ -48,20 +48,16 @@ async fn create_benchmark_request_master_commits(
48
48
/// `static.rust-lang.org/dist/2025-06-26/channel-rust-1.89-beta.toml`
49
49
/// `static.rust-lang.org/dist/2025-06-26/channel-rust-1.89.0-beta.toml`
50
50
/// `static.rust-lang.org/dist/2025-06-26/channel-rust-1.89.0-beta.2.toml`
51
- fn parse_release_string ( url : & str ) -> anyhow :: Result < Option < ( String , DateTime < Utc > ) > > {
51
+ fn parse_release_string ( url : & str ) -> Option < ( String , DateTime < Utc > ) > {
52
52
static VERSION_RE : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"(\d+\.\d+\.\d+)" ) . unwrap ( ) ) ;
53
53
54
54
// Grab ".../YYYY-MM-DD/FILE.toml" components with Path helpers.
55
- let file = Path :: new ( url)
56
- . file_name ( )
57
- . and_then ( |n| n. to_str ( ) )
58
- . ok_or_else ( || anyhow:: anyhow!( "URL lacks a file name" ) ) ?;
55
+ let file = Path :: new ( url) . file_name ( ) . and_then ( |n| n. to_str ( ) ) ?;
59
56
60
57
let date_str = Path :: new ( url)
61
58
. parent ( )
62
59
. and_then ( Path :: file_name)
63
- . and_then ( |n| n. to_str ( ) )
64
- . ok_or_else ( || anyhow:: anyhow!( "URL lacks a date segment" ) ) ?;
60
+ . and_then ( |n| n. to_str ( ) ) ?;
65
61
66
62
// No other beta releases are recognized as toolchains.
67
63
//
@@ -73,30 +69,30 @@ fn parse_release_string(url: &str) -> anyhow::Result<Option<(String, DateTime<Ut
73
69
//
74
70
// Which should get ignored for now, they're not consumable via rustup yet.
75
71
if file. contains ( "beta" ) && file != "channel-rust-beta.toml" {
76
- return Ok ( None ) ;
72
+ return None ;
77
73
}
78
74
79
75
// Parse the YYYY-MM-DD segment and stamp it with *current* UTC time.
80
- let naive = NaiveDate :: parse_from_str ( date_str, "%Y-%m-%d" ) ?;
81
- let now = Utc :: now ( ) ;
82
- let published = naive
83
- . and_hms_nano_opt ( now. hour ( ) , now. minute ( ) , now. second ( ) , now. nanosecond ( ) )
84
- . expect ( "valid HMS" )
85
- . and_local_timezone ( Utc )
86
- . single ( )
87
- . unwrap ( ) ;
88
-
89
- // Special-case the rolling beta channel.
90
- if file == "channel-rust-beta.toml" {
91
- return Ok ( Some ( ( format ! ( "beta-{date_str}" ) , published) ) ) ;
92
- }
76
+ if let Ok ( naive) = NaiveDate :: parse_from_str ( date_str, "%Y-%m-%d" ) {
77
+ let published = naive
78
+ . and_hms_opt ( 0 , 0 , 0 )
79
+ . expect ( "valid HMS" )
80
+ . and_local_timezone ( Utc )
81
+ . single ( )
82
+ . unwrap ( ) ;
83
+
84
+ // Special-case the rolling beta channel.
85
+ if file == "channel-rust-beta.toml" {
86
+ return Some ( ( format ! ( "beta-{date_str}" ) , published) ) ;
87
+ }
93
88
94
- // Otherwise pull out a semver like "1.70.0" and return it.
95
- if let Some ( cap) = VERSION_RE . captures ( file) . and_then ( |m| m. get ( 1 ) ) {
96
- return Ok ( Some ( ( cap. as_str ( ) . to_owned ( ) , published) ) ) ;
89
+ // Otherwise pull out a semver like "1.70.0" and return it.
90
+ if let Some ( cap) = VERSION_RE . captures ( file) . and_then ( |m| m. get ( 1 ) ) {
91
+ return Some ( ( cap. as_str ( ) . to_owned ( ) , published) ) ;
92
+ }
97
93
}
98
94
99
- Ok ( None )
95
+ None
100
96
}
101
97
102
98
/// Store the latest release commits or do nothing if all of them are
@@ -111,8 +107,8 @@ async fn create_benchmark_request_releases(
111
107
// TODO; delete at some point in the future
112
108
let cutoff: chrono:: DateTime < Utc > = chrono:: DateTime :: from_str ( "2025-06-01T00:00:00.000Z" ) ?;
113
109
114
- for release_string in releases. lines ( ) {
115
- if let Some ( ( name, date_time) ) = parse_release_string ( release_string) ? {
110
+ for release_string in releases. lines ( ) . rev ( ) . take ( 20 ) {
111
+ if let Some ( ( name, date_time) ) = parse_release_string ( release_string) {
116
112
if date_time >= cutoff {
117
113
let release_request = BenchmarkRequest :: create_release (
118
114
& name,
@@ -313,18 +309,13 @@ mod tests {
313
309
/// Helper: unwrap the Option, panic otherwise.
314
310
fn tag ( url : & str ) -> String {
315
311
parse_release_string ( url)
316
- . unwrap ( ) // anyhow::Result<_>
317
312
. expect ( "Some" ) // Option<_>
318
313
. 0 // take the tag
319
314
}
320
315
321
316
/// Helper: unwrap the DateTime and keep only the YYYY-MM-DD part
322
317
fn day ( url : & str ) -> NaiveDate {
323
- parse_release_string ( url)
324
- . unwrap ( )
325
- . expect ( "Some" )
326
- . 1
327
- . date_naive ( )
318
+ parse_release_string ( url) . expect ( "Some" ) . 1 . date_naive ( )
328
319
}
329
320
330
321
fn days_ago ( day_str : & str ) -> chrono:: DateTime < Utc > {
@@ -749,7 +740,6 @@ mod tests {
749
740
assert ! ( parse_release_string(
750
741
"static.rust-lang.org/dist/2016-05-31/channel-rust-nightly.toml"
751
742
)
752
- . unwrap( )
753
743
. is_none( ) ) ;
754
744
755
745
// versioned-beta artefacts are skipped too
@@ -759,7 +749,7 @@ mod tests {
759
749
"static.rust-lang.org/dist/2025-06-26/channel-rust-1.89.0-beta.2.toml" ,
760
750
] {
761
751
assert ! (
762
- parse_release_string( should_ignore) . unwrap ( ) . is_none( ) ,
752
+ parse_release_string( should_ignore) . is_none( ) ,
763
753
"{should_ignore} should be ignored"
764
754
) ;
765
755
}
0 commit comments