Skip to content

[rust] Test Selenium Manager on Linux arm64 #16045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
include:
- os: macos
- os: ubuntu
- os: ubuntu-24.04-arm
- os: windows
with:
name: Tests (${{ matrix.os }})
Expand Down Expand Up @@ -119,17 +120,28 @@ jobs:
- name: "Install cross"
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: "Build release binary"
- name: "Build release binary (x64)"
run: cross build --target x86_64-unknown-linux-musl --release
working-directory: rust
- name: "Build release binary (arm64)"
run: cross build --target aarch64-unknown-linux-musl --release
working-directory: rust
- name: "Rename binary"
run: mv rust/target/x86_64-unknown-linux-musl/release/selenium-manager selenium-manager-linux
run: |
mv rust/target/x86_64-unknown-linux-musl/release/selenium-manager selenium-manager-linux
mv rust/target/aarch64-unknown-linux-musl/release/selenium-manager selenium-manager-linux-arm64
- name: "Upload release binary"
uses: actions/upload-artifact@v4
with:
name: selenium-manager-linux
path: selenium-manager-linux
retention-days: 6
- name: "Upload release binary"
uses: actions/upload-artifact@v4
with:
name: selenium-manager-linux-arm64
path: selenium-manager-linux-arm64
retention-days: 6

linux-debug:
name: "Linux Debug"
Expand All @@ -148,18 +160,30 @@ jobs:
- name: "Install cross"
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: "Build release binary"
- name: "Build release binary (x64)"
run: |
cross build --target x86_64-unknown-linux-musl --profile dev
cd target/x86_64-unknown-linux-musl/debug
tar -cvf ../../../../selenium-manager-linux-debug.tar selenium-manager
working-directory: rust
- name: "Build release binary (arm64)"
run: |
cross build --target aarch64-unknown-linux-musl --profile dev
cd target/aarch64-unknown-linux-musl/debug
tar -cvf ../../../../selenium-manager-linux-arm64-debug.tar selenium-manager
working-directory: rust
- name: "Upload release binary"
uses: actions/upload-artifact@v4
with:
name: selenium-manager-linux-debug
path: selenium-manager-linux-debug.tar
retention-days: 6
- name: "Upload release binary"
uses: actions/upload-artifact@v4
with:
name: selenium-manager-linux-arm64-debug
path: selenium-manager-linux-arm64-debug.tar
retention-days: 6

macos-stable:
name: "MacOS Stable"
Expand Down Expand Up @@ -245,9 +269,10 @@ jobs:
- name: "Prepare and Commit"
run: |
linux_sha=$(shasum -a 256 artifacts/selenium-manager-linux/selenium-manager-linux | awk '{print $1}')
linux_arm64_sha=$(shasum -a 256 artifacts/selenium-manager-linux-arm64/selenium-manager-linux-arm64 | awk '{print $1}')
macos_sha=$(shasum -a 256 artifacts/selenium-manager-macos/selenium-manager-macos | awk '{print $1}')
windows_sha=$(shasum -a 256 artifacts/selenium-manager-windows/selenium-manager-windows.exe | awk '{print $1}')
echo "{\"macos\": \"$macos_sha\", \"windows\": \"$windows_sha\", \"linux\": \"$linux_sha\"}" > latest.json
echo "{\"macos\": \"$macos_sha\", \"windows\": \"$windows_sha\", \"linux\": \"$linux_sha\", \"linux-arm64\": \"$linux_arm64_sha\" }" > latest.json
git config --local user.email "[email protected]"
git config --local user.name "Selenium CI Bot"
git add latest.json
Expand All @@ -266,6 +291,7 @@ jobs:
prerelease: false
files: |
artifacts/selenium-manager-linux/selenium-manager-linux
artifacts/selenium-manager-linux-arm64/selenium-manager-linux-arm64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realizing I forgot to add artifacts/selenium-manager-linux-arm64-debug/selenium-manager-linux-arm64-debug.tar to this list, so let's keep that in mind as we continue working on this PR.

artifacts/selenium-manager-macos/selenium-manager-macos
artifacts/selenium-manager-windows/selenium-manager-windows.exe
artifacts/selenium-manager-linux-debug/selenium-manager-linux-debug.tar
Expand Down
4 changes: 4 additions & 0 deletions rust/src/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ impl SeleniumManager for ChromeManager {
} else {
"mac64"
}
} else if LINUX.is(os) && ARM64.is(arch) {
return Err(anyhow!(
"Linux arm64 is not supported yet by Google Chrome. Please try another browser."
));
} else {
"linux64"
};
Expand Down
5 changes: 5 additions & 0 deletions rust/src/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::{
DASH_DASH_VERSION, DEV, ENV_PROGRAM_FILES_X86, NIGHTLY, OFFLINE_REQUEST_ERR_MSG, REG_PV_ARG,
REG_VERSION_ARG, STABLE,
};
use anyhow::anyhow;
use anyhow::Error;
use reqwest::Client;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -288,6 +289,10 @@ impl SeleniumManager for EdgeManager {
} else {
"mac64"
}
} else if LINUX.is(os) && ARM64.is(arch) {
return Err(anyhow!(
"Linux arm64 is not supported yet by Microsoft Edge. Please try another browser."
));
} else {
"linux64"
};
Expand Down
39 changes: 23 additions & 16 deletions rust/tests/browser_download_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use crate::common::{assert_browser, assert_driver, get_selenium_manager};

use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;

mod common;
Expand All @@ -27,23 +28,27 @@ mod common;
#[case("firefox")]
#[case("edge")]
fn browser_latest_download_test(#[case] browser: String) {
if !browser.eq("edge") || !OS.eq("windows") {
let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
&browser,
"--force-browser-download",
"--output",
"json",
"--debug",
])
.assert()
.success()
.code(0);

assert_driver(&mut cmd);
assert_browser(&mut cmd);
if browser.eq("edge") && OS.eq("windows") {
return;
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
&browser,
"--force-browser-download",
"--output",
"json",
"--debug",
])
.assert()
.success()
.code(0);

assert_driver(&mut cmd);
assert_browser(&mut cmd);
}

#[rstest]
Expand All @@ -59,6 +64,8 @@ fn browser_latest_download_test(#[case] browser: String) {
fn browser_version_download_test(#[case] browser: String, #[case] browser_version: String) {
if OS.eq("windows") && browser.eq("edge") {
println!("Skipping Edge download test on Windows since the installation requires admin privileges");
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
println!("Skipping non-Firefox download test on Linux arm64 since no other browsers are supported yet");
} else {
let mut cmd = get_selenium_manager();
cmd.args([
Expand Down
9 changes: 9 additions & 0 deletions rust/tests/browser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::common::{assert_output, get_selenium_manager, get_stdout};

use exitcode::DATAERR;
use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;
use std::path::Path;

Expand All @@ -40,6 +41,10 @@ fn browser_version_test(
#[case] browser_version: String,
#[case] driver_version: String,
) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
Expand Down Expand Up @@ -78,6 +83,10 @@ fn wrong_parameters_test(
#[case] driver_version: String,
#[case] error_code: i32,
) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
let result = cmd
.args([
Expand Down
1 change: 1 addition & 0 deletions rust/tests/cache_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::path::Path;

mod common;

#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
#[rstest]
#[case("../tmp")]
#[case("../áèîö")]
Expand Down
6 changes: 6 additions & 0 deletions rust/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use selenium_manager::logger::JsonOutput;
use selenium_manager::shell;
use selenium_manager::shell::run_shell_command_by_os;
use std::borrow::BorrowMut;
use std::env::consts::ARCH;
use std::env::consts::OS;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -119,3 +120,8 @@ pub fn assert_output(
.contains(&error_code.to_string()));
}
}

#[allow(dead_code)]
pub fn is_linux_arm64() -> bool {
OS == "linux" && ARCH == "aarch64"
}
5 changes: 5 additions & 0 deletions rust/tests/config_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::common::{assert_browser, assert_driver, get_selenium_manager, get_std

use rstest::rstest;

use std::env::consts::ARCH;
use std::env::consts::OS;
use std::fs::File;
use std::io::{BufWriter, Write};
use tempfile::Builder;
Expand All @@ -30,6 +32,9 @@ mod common;
#[case("firefox")]
#[case("edge")]
fn config_test(#[case] browser_name: String) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
return;
}
let tmp_dir = Builder::new().prefix("sm-config-test").tempdir().unwrap();
let config_path = tmp_dir.path().join("se-config.toml");
let config_file = File::create(config_path.as_path()).unwrap();
Expand Down
5 changes: 5 additions & 0 deletions rust/tests/exec_driver_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use crate::common::{assert_browser, assert_driver, exec_driver, get_selenium_manager};

use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;

mod common;
Expand All @@ -28,6 +29,10 @@ mod common;
#[case("firefox", "geckodriver")]
#[case("iexplorer", "IEDriverServer")]
fn exec_driver_test(#[case] browser_name: String, #[case] driver_name: String) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
cmd.args(["--browser", &browser_name, "--output", "json"])
.assert()
Expand Down
8 changes: 6 additions & 2 deletions rust/tests/mirror_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{assert_driver, get_selenium_manager};
use crate::common::{assert_driver, get_selenium_manager, is_linux_arm64};

mod common;

Expand All @@ -24,7 +24,11 @@ fn mirror_test() {
let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
"chrome",
if is_linux_arm64() {
"firefox"
} else {
"chrome"
},
"--driver-mirror-url",
"https://registry.npmmirror.com/-/binary/chromedriver/",
"--browser-version",
Expand Down
19 changes: 14 additions & 5 deletions rust/tests/offline_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{get_selenium_manager, get_stdout};
use crate::common::{get_selenium_manager, get_stdout, is_linux_arm64};

mod common;

#[test]
fn offline_test() {
let mut cmd = get_selenium_manager();
cmd.args(["--debug", "--browser", "chrome", "--offline"])
.assert()
.success()
.code(0);
cmd.args([
"--debug",
"--browser",
if is_linux_arm64() {
"firefox"
} else {
"chrome"
},
"--offline",
])
.assert()
.success()
.code(0);

let stdout = get_stdout(&mut cmd);

Expand Down
Loading
Loading