Skip to content

Commit

Permalink
Merge pull request #1145 from KristofferC/kc/nightly_release
Browse files Browse the repository at this point in the history
support `x.y-nightly` channel to allow testing nightlies on release branches
  • Loading branch information
davidanthoff authored Jan 22, 2025
2 parents f7a2f97 + 2bdfabe commit 51a190c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ The available system provided channels are:
- `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.
- `rc`: same as `beta`, but only starts with release candidate versions.
- `nightly`: always points to the latest build from the `master` branch in the Julia repository.
- `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`.
- `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.
- specific versions, e.g. `1.5.4`.
- minor version channels, e.g. `1.5`.
Expand Down
2 changes: 1 addition & 1 deletion src/command_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use regex::Regex;

pub fn run_command_add(channel: &str, paths: &GlobalPaths) -> Result<()> {
// This regex is dynamically compiled, but its runtime is negligible compared to downloading Julia
if Regex::new(r"^(pr\d+|nightly)(~|$)")
if Regex::new(r"^(?:pr\d+|nightly|\d+\.\d+-nightly)(?:~|$)")
.unwrap()
.is_match(channel)
{
Expand Down
1 change: 1 addition & 0 deletions src/command_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn run_command_list(paths: &GlobalPaths) -> Result<()> {

let non_db_channels: Vec<String> = (get_channel_variations("nightly")?)
.into_iter()
.chain(get_channel_variations("x.y-nightly")?)
.chain(get_channel_variations("pr{number}")?)
.collect();
let non_db_rows: Vec<ChannelRow> = non_db_channels
Expand Down
107 changes: 84 additions & 23 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,17 +502,33 @@ pub fn is_pr_channel(channel: &String) -> bool {
return Regex::new(r"^(pr\d+)(~|$)").unwrap().is_match(channel);
}

fn parse_nightly_channel_or_id(channel: &str) -> Option<String> {
let nightly_re =
Regex::new(r"^((?:nightly|latest)|latest|(\d+\.\d+)-(?:nightly|latest))").unwrap();

let caps = nightly_re.captures(channel)?;
if let Some(xy_match) = caps.get(2) {
Some(xy_match.as_str().to_string())
} else {
Some("".to_string())
}
}

// Identify the unversioned name of a nightly (e.g., `latest-macos-x86_64`) for a channel
pub fn channel_to_name(channel: &String) -> Result<String> {
let mut parts = channel.splitn(2, '~');

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

let version = match channel {
"nightly" => "latest",
other => other,
let version = if let Some(version_prefix) = parse_nightly_channel_or_id(channel) {
if version_prefix.is_empty() {
"latest".to_string()
} else {
format!("{}-latest", version_prefix)
}
} else {
channel.to_string()
};

let arch = match parts.next() {
Some(arch) => arch.to_string(),
None => default_arch()?,
Expand Down Expand Up @@ -621,41 +637,86 @@ pub fn install_non_db_version(
) -> Result<crate::config_file::JuliaupConfigChannel> {
// Determine the download URL
let download_url_base = get_julianightlies_base_url()?;

let mut parts = name.splitn(2, '-');
let id = parts.next().expect("Failed to parse channel name.");
let arch = parts.next().expect("Failed to parse channel name.");
let download_url_path = if id == "latest" {

let mut id = parts
.next()
.expect("Failed to parse channel name.")
.to_string();
let mut arch = parts.next().expect("Failed to parse channel name.");

// Check for the case where name is given as "x.y-latest-...", in which case
// we peel off the "latest" part of the `arch` and attach it to the `id``.
if arch.starts_with("latest") {
let mut parts = arch.splitn(2, '-');
let nightly = parts.next().expect("Failed to parse channel name.");
id.push_str("-");
id.push_str(nightly);
arch = parts.next().expect("Failed to parse channel name.");
}

let nightly_version = parse_nightly_channel_or_id(&id);

let download_url_path = if let Some(nightly_version) = nightly_version {
let nightly_folder = if nightly_version.is_empty() {
"".to_string() // No version folder
} else {
format!("/{}", nightly_version) // Use version as folder
};
match arch {
"macos-x86_64" => Ok("bin/macos/x86_64/julia-latest-macos-x86_64.tar.gz".to_owned()),
"macos-aarch64" => Ok("bin/macos/aarch64/julia-latest-macos-aarch64.tar.gz".to_owned()),
"win64" => Ok("bin/winnt/x64/julia-latest-win64.tar.gz".to_owned()),
"win32" => Ok("bin/winnt/x86/julia-latest-win32.tar.gz".to_owned()),
"linux-x86_64" => Ok("bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz".to_owned()),
"linux-i686" => Ok("bin/linux/i686/julia-latest-linux-i686.tar.gz".to_owned()),
"linux-aarch64" => Ok("bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz".to_owned()),
"freebsd-x86_64" => {
Ok("bin/freebsd/x86_64/julia-latest-freebsd-x86_64.tar.gz".to_owned())
}
"macos-x86_64" => Ok(format!(
"bin/macos/x86_64{}/julia-latest-macos-x86_64.tar.gz",
nightly_folder
)),
"macos-aarch64" => Ok(format!(
"bin/macos/aarch64{}/julia-latest-macos-aarch64.tar.gz",
nightly_folder
)),
"win64" => Ok(format!(
"bin/winnt/x64{}/julia-latest-win64.tar.gz",
nightly_folder
)),
"win32" => Ok(format!(
"bin/winnt/x86{}/julia-latest-win32.tar.gz",
nightly_folder
)),
"linux-x86_64" => Ok(format!(
"bin/linux/x86_64{}/julia-latest-linux-x86_64.tar.gz",
nightly_folder
)),
"linux-i686" => Ok(format!(
"bin/linux/i686{}/julia-latest-linux-i686.tar.gz",
nightly_folder
)),
"linux-aarch64" => Ok(format!(
"bin/linux/aarch64{}/julia-latest-linux-aarch64.tar.gz",
nightly_folder
)),
"freebsd-x86_64" => Ok(format!(
"bin/freebsd/x86_64{}/julia-latest-freebsd-x86_64.tar.gz",
nightly_folder
)),
_ => Err(anyhow!("Unknown nightly.")),
}
} else if id.starts_with("pr") {
match arch {
// https://github.com/JuliaLang/juliaup/issues/903#issuecomment-2183206994
"macos-x86_64" => {
Ok("bin/macos/x86_64/julia-".to_owned() + id + "-macos-x86_64.tar.gz")
Ok("bin/macos/x86_64/julia-".to_owned() + &id + "-macos-x86_64.tar.gz")
}
"macos-aarch64" => {
Ok("bin/macos/aarch64/julia-".to_owned() + id + "-macos-aarch64.tar.gz")
Ok("bin/macos/aarch64/julia-".to_owned() + &id + "-macos-aarch64.tar.gz")
}
"win64" => Ok("bin/windows/x86_64/julia-".to_owned() + id + "-windows-x86_64.tar.gz"),
"win64" => Ok("bin/windows/x86_64/julia-".to_owned() + &id + "-windows-x86_64.tar.gz"),
"linux-x86_64" => {
Ok("bin/linux/x86_64/julia-".to_owned() + id + "-linux-x86_64.tar.gz")
Ok("bin/linux/x86_64/julia-".to_owned() + &id + "-linux-x86_64.tar.gz")
}
"linux-aarch64" => {
Ok("bin/linux/aarch64/julia-".to_owned() + id + "-linux-aarch64.tar.gz")
Ok("bin/linux/aarch64/julia-".to_owned() + &id + "-linux-aarch64.tar.gz")
}
"freebsd-x86_64" => {
Ok("bin/freebsd/x86_64/julia-".to_owned() + id + "-freebsd-x86_64.tar.gz")
Ok("bin/freebsd/x86_64/julia-".to_owned() + &id + "-freebsd-x86_64.tar.gz")
}
_ => Err(anyhow!("Unknown pr.")),
}
Expand Down
10 changes: 10 additions & 0 deletions tests/command_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ fn command_add() {
.success()
.stdout("");

Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("1.11-nightly")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("julia")
.unwrap()
.arg("+1.6.4")
Expand Down
1 change: 1 addition & 0 deletions tests/command_list_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fn command_list() {
.success()
.stdout(predicate::str::starts_with(" Channel").and(predicate::str::contains("release")))
.stdout(predicate::str::contains("nightly"))
.stdout(predicate::str::contains("x.y-nightly"))
.stdout(predicate::str::contains("pr{number}"));

Command::cargo_bin("juliaup")
Expand Down

0 comments on commit 51a190c

Please sign in to comment.