1
Fork 0

Compare installed browser-ui-test version to the one used in CI

This commit is contained in:
Guillaume Gomez 2022-03-11 15:29:11 +01:00
parent 691d1c1e12
commit 1ddbae372f
3 changed files with 50 additions and 19 deletions

View file

@ -836,9 +836,9 @@ impl Step for RustdocJSNotStd {
} }
} }
fn check_if_browser_ui_test_is_installed_global(npm: &Path, global: bool) -> bool { fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String> {
let mut command = Command::new(&npm); let mut command = Command::new(&npm);
command.arg("list").arg("--depth=0"); command.arg("list").arg("--parseable").arg("--long").arg("--depth=0");
if global { if global {
command.arg("--global"); command.arg("--global");
} }
@ -846,12 +846,29 @@ fn check_if_browser_ui_test_is_installed_global(npm: &Path, global: bool) -> boo
.output() .output()
.map(|output| String::from_utf8_lossy(&output.stdout).into_owned()) .map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
.unwrap_or(String::new()); .unwrap_or(String::new());
lines.contains(&" browser-ui-test@") lines.lines().find_map(|l| l.split(":browser-ui-test@").skip(1).next()).map(|v| v.to_owned())
} }
fn check_if_browser_ui_test_is_installed(npm: &Path) -> bool { fn get_browser_ui_test_version(npm: &Path) -> Option<String> {
check_if_browser_ui_test_is_installed_global(npm, false) get_browser_ui_test_version_inner(npm, false)
|| check_if_browser_ui_test_is_installed_global(npm, true) .or_else(|| get_browser_ui_test_version_inner(npm, true))
}
fn compare_browser_ui_test_version(installed_version: &str, src: &Path) {
match fs::read_to_string(
src.join("src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version"),
) {
Ok(v) => {
if v.trim() != installed_version {
eprintln!(
"⚠️ Installed version of browser-ui-test (`{}`) is different than the \
one used in the CI (`{}`)",
installed_version, v
);
}
}
Err(e) => eprintln!("Couldn't find the CI browser-ui-test version: {:?}", e),
}
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@ -874,7 +891,7 @@ impl Step for RustdocGUI {
.config .config
.npm .npm
.as_ref() .as_ref()
.map(|p| check_if_browser_ui_test_is_installed(p)) .map(|p| get_browser_ui_test_version(p).is_some())
.unwrap_or(false) .unwrap_or(false)
})) }))
} }
@ -892,7 +909,13 @@ impl Step for RustdocGUI {
// The goal here is to check if the necessary packages are installed, and if not, we // The goal here is to check if the necessary packages are installed, and if not, we
// panic. // panic.
if !check_if_browser_ui_test_is_installed(&npm) { match get_browser_ui_test_version(&npm) {
Some(version) => {
// We also check the version currently used in CI and emit a warning if it's not the
// same one.
compare_browser_ui_test_version(&version, &builder.build.src);
}
None => {
eprintln!( eprintln!(
"error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \ "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
dependency is missing", dependency is missing",
@ -903,6 +926,7 @@ impl Step for RustdocGUI {
); );
panic!("Cannot run rustdoc-gui tests"); panic!("Cannot run rustdoc-gui tests");
} }
}
let out_dir = builder.test_out(self.target).join("rustdoc-gui"); let out_dir = builder.test_out(self.target).join("rustdoc-gui");

View file

@ -65,14 +65,20 @@ RUN /scripts/cmake.sh
COPY host-x86_64/x86_64-gnu-tools/checktools.sh /tmp/ COPY host-x86_64/x86_64-gnu-tools/checktools.sh /tmp/
RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ
ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}" ENV NODE_FOLDER=/node-v14.4.0-linux-x64/bin
ENV PATH="$NODE_FOLDER:${PATH}"
COPY host-x86_64/x86_64-gnu-tools/browser-ui-test.version /tmp/
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries # For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
# to create a new folder. For reference: # to create a new folder. For reference:
# https://github.com/puppeteer/puppeteer/issues/375 # https://github.com/puppeteer/puppeteer/issues/375
# #
# We also specify the version in case we need to update it to go around cache limitations. # We also specify the version in case we need to update it to go around cache limitations.
RUN npm install -g browser-ui-test@0.8.3 --unsafe-perm=true #
# The `browser-ui-test.version` file is also used by bootstrap to emit warnings in case
# the local version of the package is different than the one used by the CI.
RUN npm install -g browser-ui-test@$(head -n 1 /tmp/browser-ui-test.version) --unsafe-perm=true
ENV RUST_CONFIGURE_ARGS \ ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \ --build=x86_64-unknown-linux-gnu \

View file

@ -0,0 +1 @@
0.8.3