Skip to content

Commit 0d7ec34

Browse files
Take into account architecture when selecting linux artifact (#59)
StyLua recently started producing linux-aarch64 builds. Foreman does not correctly take into account the architecture on linux, and selects the linux-aarch64 build when linux-x86_64 should be used. This causes GitHub Actions CI to fail. We fix this by preferring a more explicit name in platform keywords for linux (depending on arch), and falling back to the generic one if nothing is found
1 parent ee74f86 commit 0d7ec34

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Foreman Changelog
22

3+
## Unreleased
4+
5+
- Take into account architecture when downloading binaries for linux ([#59](https://github.com/Roblox/foreman/pull/59))
6+
37
## 1.0.4 (2022-05-13)
48

59
- Introduce improved error output on using uninstalled tools ([#51](https://github.com/Roblox/foreman/pull/51))

src/artifact_choosing.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ static PLATFORM_KEYWORDS: &[&str] = &[
1414
"darwin",
1515
];
1616

17-
#[cfg(target_os = "linux")]
17+
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
18+
static PLATFORM_KEYWORDS: &[&str] = &["linux-x86_64", "linux"];
19+
20+
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
21+
static PLATFORM_KEYWORDS: &[&str] = &["linux-arm64", "linux-aarch64", "linux"];
22+
23+
#[cfg(all(
24+
target_os = "linux",
25+
not(any(target_arch = "x86_64", target_arch = "aarch64"))
26+
))]
1827
static PLATFORM_KEYWORDS: &[&str] = &["linux"];
1928

2029
pub fn platform_keywords() -> &'static [&'static str] {

src/tool_cache.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,38 @@ mod test {
295295
assert_eq!(choose_asset(&release, &["linux"]), Some(0));
296296
}
297297

298+
#[test]
299+
fn select_correct_asset_linux() {
300+
let release = Release {
301+
prerelease: false,
302+
tag_name: "v0.5.2".to_string(),
303+
assets: vec![
304+
ReleaseAsset {
305+
name: "tool-linux-aarch64.zip".to_string(),
306+
url: "https://example.com/some/repo/releases/assets/1".to_string(),
307+
},
308+
ReleaseAsset {
309+
name: "tool-linux-x86_64.zip".to_string(),
310+
url: "https://example.com/some/repo/releases/assets/2".to_string(),
311+
},
312+
ReleaseAsset {
313+
name: "tool-macos-x86_64.zip".to_string(),
314+
url: "https://example.com/some/repo/releases/assets/3".to_string(),
315+
},
316+
ReleaseAsset {
317+
name: "tool-win64.zip".to_string(),
318+
url: "https://example.com/some/repo/releases/assets/4".to_string(),
319+
},
320+
],
321+
};
322+
assert_eq!(choose_asset(&release, &["linux"]), Some(0));
323+
assert_eq!(choose_asset(&release, &["linux-x86_64", "linux"]), Some(1));
324+
assert_eq!(
325+
choose_asset(&release, &["linux-arm64", "linux-aarch64", "linux"]),
326+
Some(0)
327+
);
328+
}
329+
298330
mod load {
299331
use super::*;
300332

0 commit comments

Comments
 (0)