Skip to content

Commit 51a190c

Browse files
authored
Merge pull request #1145 from KristofferC/kc/nightly_release
support `x.y-nightly` channel to allow testing nightlies on release branches
2 parents f7a2f97 + 2bdfabe commit 51a190c

File tree

6 files changed

+98
-24
lines changed

6 files changed

+98
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ The available system provided channels are:
133133
- `beta`: always points to the latest beta version if one exists. If a newer release candidate exists, it will point to that, and if there is neither a beta or rc candidate available it will point to the same version as the `release` channel.
134134
- `rc`: same as `beta`, but only starts with release candidate versions.
135135
- `nightly`: always points to the latest build from the `master` branch in the Julia repository.
136+
- `x.y-nightly`: always points to the latest build from the `release-x.y` branch in the Julia repository, e.g. `1.11-nightly` gives the latest build on the `release-1.11` branch`.
136137
- `pr{number}` (e.g. `pr123`): points to the latest successful build of a PR branch (https://github.com/JuliaLang/julia/pull/{number}). Only available if CI has recently and successfully built Julia on that branch.
137138
- specific versions, e.g. `1.5.4`.
138139
- minor version channels, e.g. `1.5`.

src/command_add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use regex::Regex;
1111

1212
pub fn run_command_add(channel: &str, paths: &GlobalPaths) -> Result<()> {
1313
// This regex is dynamically compiled, but its runtime is negligible compared to downloading Julia
14-
if Regex::new(r"^(pr\d+|nightly)(~|$)")
14+
if Regex::new(r"^(?:pr\d+|nightly|\d+\.\d+-nightly)(?:~|$)")
1515
.unwrap()
1616
.is_match(channel)
1717
{

src/command_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn run_command_list(paths: &GlobalPaths) -> Result<()> {
2222

2323
let non_db_channels: Vec<String> = (get_channel_variations("nightly")?)
2424
.into_iter()
25+
.chain(get_channel_variations("x.y-nightly")?)
2526
.chain(get_channel_variations("pr{number}")?)
2627
.collect();
2728
let non_db_rows: Vec<ChannelRow> = non_db_channels

src/operations.rs

Lines changed: 84 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,33 @@ pub fn is_pr_channel(channel: &String) -> bool {
502502
return Regex::new(r"^(pr\d+)(~|$)").unwrap().is_match(channel);
503503
}
504504

505+
fn parse_nightly_channel_or_id(channel: &str) -> Option<String> {
506+
let nightly_re =
507+
Regex::new(r"^((?:nightly|latest)|latest|(\d+\.\d+)-(?:nightly|latest))").unwrap();
508+
509+
let caps = nightly_re.captures(channel)?;
510+
if let Some(xy_match) = caps.get(2) {
511+
Some(xy_match.as_str().to_string())
512+
} else {
513+
Some("".to_string())
514+
}
515+
}
516+
505517
// Identify the unversioned name of a nightly (e.g., `latest-macos-x86_64`) for a channel
506518
pub fn channel_to_name(channel: &String) -> Result<String> {
507519
let mut parts = channel.splitn(2, '~');
508520

509521
let channel = parts.next().expect("Failed to parse channel name.");
510522

511-
let version = match channel {
512-
"nightly" => "latest",
513-
other => other,
523+
let version = if let Some(version_prefix) = parse_nightly_channel_or_id(channel) {
524+
if version_prefix.is_empty() {
525+
"latest".to_string()
526+
} else {
527+
format!("{}-latest", version_prefix)
528+
}
529+
} else {
530+
channel.to_string()
514531
};
515-
516532
let arch = match parts.next() {
517533
Some(arch) => arch.to_string(),
518534
None => default_arch()?,
@@ -621,41 +637,86 @@ pub fn install_non_db_version(
621637
) -> Result<crate::config_file::JuliaupConfigChannel> {
622638
// Determine the download URL
623639
let download_url_base = get_julianightlies_base_url()?;
640+
624641
let mut parts = name.splitn(2, '-');
625-
let id = parts.next().expect("Failed to parse channel name.");
626-
let arch = parts.next().expect("Failed to parse channel name.");
627-
let download_url_path = if id == "latest" {
642+
643+
let mut id = parts
644+
.next()
645+
.expect("Failed to parse channel name.")
646+
.to_string();
647+
let mut arch = parts.next().expect("Failed to parse channel name.");
648+
649+
// Check for the case where name is given as "x.y-latest-...", in which case
650+
// we peel off the "latest" part of the `arch` and attach it to the `id``.
651+
if arch.starts_with("latest") {
652+
let mut parts = arch.splitn(2, '-');
653+
let nightly = parts.next().expect("Failed to parse channel name.");
654+
id.push_str("-");
655+
id.push_str(nightly);
656+
arch = parts.next().expect("Failed to parse channel name.");
657+
}
658+
659+
let nightly_version = parse_nightly_channel_or_id(&id);
660+
661+
let download_url_path = if let Some(nightly_version) = nightly_version {
662+
let nightly_folder = if nightly_version.is_empty() {
663+
"".to_string() // No version folder
664+
} else {
665+
format!("/{}", nightly_version) // Use version as folder
666+
};
628667
match arch {
629-
"macos-x86_64" => Ok("bin/macos/x86_64/julia-latest-macos-x86_64.tar.gz".to_owned()),
630-
"macos-aarch64" => Ok("bin/macos/aarch64/julia-latest-macos-aarch64.tar.gz".to_owned()),
631-
"win64" => Ok("bin/winnt/x64/julia-latest-win64.tar.gz".to_owned()),
632-
"win32" => Ok("bin/winnt/x86/julia-latest-win32.tar.gz".to_owned()),
633-
"linux-x86_64" => Ok("bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz".to_owned()),
634-
"linux-i686" => Ok("bin/linux/i686/julia-latest-linux-i686.tar.gz".to_owned()),
635-
"linux-aarch64" => Ok("bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz".to_owned()),
636-
"freebsd-x86_64" => {
637-
Ok("bin/freebsd/x86_64/julia-latest-freebsd-x86_64.tar.gz".to_owned())
638-
}
668+
"macos-x86_64" => Ok(format!(
669+
"bin/macos/x86_64{}/julia-latest-macos-x86_64.tar.gz",
670+
nightly_folder
671+
)),
672+
"macos-aarch64" => Ok(format!(
673+
"bin/macos/aarch64{}/julia-latest-macos-aarch64.tar.gz",
674+
nightly_folder
675+
)),
676+
"win64" => Ok(format!(
677+
"bin/winnt/x64{}/julia-latest-win64.tar.gz",
678+
nightly_folder
679+
)),
680+
"win32" => Ok(format!(
681+
"bin/winnt/x86{}/julia-latest-win32.tar.gz",
682+
nightly_folder
683+
)),
684+
"linux-x86_64" => Ok(format!(
685+
"bin/linux/x86_64{}/julia-latest-linux-x86_64.tar.gz",
686+
nightly_folder
687+
)),
688+
"linux-i686" => Ok(format!(
689+
"bin/linux/i686{}/julia-latest-linux-i686.tar.gz",
690+
nightly_folder
691+
)),
692+
"linux-aarch64" => Ok(format!(
693+
"bin/linux/aarch64{}/julia-latest-linux-aarch64.tar.gz",
694+
nightly_folder
695+
)),
696+
"freebsd-x86_64" => Ok(format!(
697+
"bin/freebsd/x86_64{}/julia-latest-freebsd-x86_64.tar.gz",
698+
nightly_folder
699+
)),
639700
_ => Err(anyhow!("Unknown nightly.")),
640701
}
641702
} else if id.starts_with("pr") {
642703
match arch {
643704
// https://github.com/JuliaLang/juliaup/issues/903#issuecomment-2183206994
644705
"macos-x86_64" => {
645-
Ok("bin/macos/x86_64/julia-".to_owned() + id + "-macos-x86_64.tar.gz")
706+
Ok("bin/macos/x86_64/julia-".to_owned() + &id + "-macos-x86_64.tar.gz")
646707
}
647708
"macos-aarch64" => {
648-
Ok("bin/macos/aarch64/julia-".to_owned() + id + "-macos-aarch64.tar.gz")
709+
Ok("bin/macos/aarch64/julia-".to_owned() + &id + "-macos-aarch64.tar.gz")
649710
}
650-
"win64" => Ok("bin/windows/x86_64/julia-".to_owned() + id + "-windows-x86_64.tar.gz"),
711+
"win64" => Ok("bin/windows/x86_64/julia-".to_owned() + &id + "-windows-x86_64.tar.gz"),
651712
"linux-x86_64" => {
652-
Ok("bin/linux/x86_64/julia-".to_owned() + id + "-linux-x86_64.tar.gz")
713+
Ok("bin/linux/x86_64/julia-".to_owned() + &id + "-linux-x86_64.tar.gz")
653714
}
654715
"linux-aarch64" => {
655-
Ok("bin/linux/aarch64/julia-".to_owned() + id + "-linux-aarch64.tar.gz")
716+
Ok("bin/linux/aarch64/julia-".to_owned() + &id + "-linux-aarch64.tar.gz")
656717
}
657718
"freebsd-x86_64" => {
658-
Ok("bin/freebsd/x86_64/julia-".to_owned() + id + "-freebsd-x86_64.tar.gz")
719+
Ok("bin/freebsd/x86_64/julia-".to_owned() + &id + "-freebsd-x86_64.tar.gz")
659720
}
660721
_ => Err(anyhow!("Unknown pr.")),
661722
}

tests/command_add.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ fn command_add() {
2525
.success()
2626
.stdout("");
2727

28+
Command::cargo_bin("juliaup")
29+
.unwrap()
30+
.arg("add")
31+
.arg("1.11-nightly")
32+
.env("JULIA_DEPOT_PATH", depot_dir.path())
33+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
34+
.assert()
35+
.success()
36+
.stdout("");
37+
2838
Command::cargo_bin("julia")
2939
.unwrap()
3040
.arg("+1.6.4")

tests/command_list_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn command_list() {
1717
.success()
1818
.stdout(predicate::str::starts_with(" Channel").and(predicate::str::contains("release")))
1919
.stdout(predicate::str::contains("nightly"))
20+
.stdout(predicate::str::contains("x.y-nightly"))
2021
.stdout(predicate::str::contains("pr{number}"));
2122

2223
Command::cargo_bin("juliaup")

0 commit comments

Comments
 (0)