blob: 12b122e13d357f4ca6d1dc3883a0d03b7b8425ff [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# NB(sollyross): if you're modifying this file, please make sure any "global" operations
# (e.g. installing outside a tempdir, changing configuration files for the user, etc)
# are gated behind an ON_CI flag. If possible, prefer local-to-shell-instance operations.
set -eo pipefail
echo "figuring out common paths and such..." >&2
export ci_dir="$(realpath $(dirname -- "${BASH_SOURCE[0]}"))"
export root_dir=${ci_dir:?could not figure out script dir}/../
node_version="${NODE_VERSION:-19.4.0}"
export PATH="${root_dir}/prebuilt/nodejs/bin/:${PATH}"
ensure-node() {
echo "installing node ${node_version}..." >&2
# TODO(sollyross): we probably just want to pull this from an internal
# cache or CIPD, but this is fine for now
[[ -d ${root_dir}/prebuilt ]] || mkdir ${root_dir}/prebuilt
# subshell to not clobber our current path
(
cd ${root_dir}/prebuilt
wget --no-verbose https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-x64.tar.xz
tar -xJf node-v${node_version}-linux-x64.tar.xz
# rename to make the rest of our script easier
mv node-v${node_version}-linux-x64 nodejs
)
}
setup-python() {
if [[ -n "${ON_CI:-""}" ]]; then
pyenv global 3.9
echo "Using python version: $(python --version)" >&2
fi
}
ensure-all() {
ensure-node
setup-python
if [[ -n "${ON_CI:-""}" ]]; then
echo "installing testing OS deps..." >&2
# these are required by vscode itself, plus xvfb for for running vscode headless
# xvfb should already be installed but better to be clear that we need it.
# (libsecret-1-dev and below are for node deps)
sudo apt-get update
sudo apt-get install --fix-missing -y \
libnss3 libatk1.0 libatk-bridge2.0 libdrm2 \
libgtk-3-0 libpango-1.0 libcairo2 libgdk-pixbuf2.0 \
libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
libgbm1 libxkbcommon0 libasound2 xvfb \
libsecret-1-dev
# Install chrome for webview tests.
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
fi
}