-
Notifications
You must be signed in to change notification settings - Fork 57
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
Install Chrome for chromote
#302
Open
schloerke
wants to merge
9
commits into
rstudio:main
Choose a base branch
from
schloerke:chromote
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−4
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
deaa121
bust makefile cache
schloerke 44b1496
Add chrome support for chromote
schloerke f5916d7
Create chromote test.R
schloerke 661385d
Update default chromote object for current testing
schloerke d8e3c4b
Add file to install chromium. Favor installing `chrome`. Keeping for …
schloerke b2d25f5
Add PR note
schloerke ce1d2a0
install from master
schloerke 6e86114
Remove setting the default chromote object
schloerke 82d0379
Debug the `default_chrome_args()`
schloerke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
apt-get update -qq | ||
|
||
# install chrome | ||
curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | ||
apt-get install -y ./google-chrome-stable_current_amd64.deb | ||
rm google-chrome-stable_current_amd64.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
# See https://github.com/rstudio/shinyapps-package-dependencies/pull/302 as to why this file is not used. | ||
|
||
apt-get update -qq | ||
|
||
# On Ubuntu <= 18... | ||
if [ ${OS_CODENAME} == "xenial" ]; then | ||
apt-get install -y chromium-browser | ||
else | ||
## On Ubuntu Focal... | ||
## When installing chromium using ... | ||
# apt-get install -y chromium-browser | ||
## When `chromium` is first ran, an error will be throw, asking you to install chromium using... | ||
# snap install chromium | ||
## However, installing `snapd` on docker is not trivial. :-( | ||
|
||
|
||
# Following directions similar to | ||
# * Chromium official suggestion: https://github.com/scheib/chromium-latest-linux/blob/4f4e9b85ea02a109e071452de936389cc2fd7376/update.sh | ||
# * GHA Virtual Environments: https://github.com/actions/virtual-environments/blob/cfffe35709dcc45d09f0a08189be5984f3f13bbb/images/linux/scripts/installers/google-chrome.sh#L69-L85 | ||
|
||
# Install all dependencies that are not regularly installed when using `.deb` files | ||
# https://github.com/puppeteer/puppeteer/blob/feec588f951d8833e3b9758cde9f34c325837407/.ci/node12/Dockerfile.linux#L3-L9 | ||
# Matches libraries installed when using xenial deb file | ||
apt-get install -y xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \ | ||
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \ | ||
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \ | ||
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ | ||
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget | ||
|
||
# Set up variables | ||
CHROMIUM_VERSION_FILE="chromiumLastChange.txt" | ||
CHROMIUM_ZIP_FILE="chromium.zip" | ||
CHROMIUM_ZIP_FOLDER="/tmp/chromium" | ||
CHROMIUM_ZIP="${CHROMIUM_ZIP_FOLDER}/${CHROMIUM_ZIP_FILE}" | ||
|
||
mkdir -p "${CHROMIUM_ZIP_FOLDER}" | ||
|
||
# Download chromium latest version. Ex: 382086 | ||
curl -L4 "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2FLAST_CHANGE?alt=media" -o "${CHROMIUM_VERSION_FILE}" | ||
CHROMIUM_VERSION=`cat ${CHROMIUM_VERSION_FILE}` | ||
curl -L4 "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${CHROMIUM_VERSION}%2Fchrome-linux.zip?alt=media" -o "${CHROMIUM_ZIP}" | ||
|
||
|
||
# Unzip Chromium archive | ||
CHROMIUM_FOLDER="/usr/local/share/chromium" | ||
CHROMIUM_BIN="$CHROMIUM_FOLDER/chrome-linux/chrome" | ||
|
||
mkdir "${CHROMIUM_FOLDER}" | ||
unzip -qq ${CHROMIUM_ZIP} -d "${CHROMIUM_FOLDER}" | ||
|
||
# Link binaries | ||
ln -s "${CHROMIUM_BIN}" /usr/bin/chromium | ||
ln -s "${CHROMIUM_BIN}" /usr/bin/chromium-browser | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
options(download.file.method = "curl") | ||
|
||
avail_pkgs <- unname(available.packages(repos = "https://cran.rstudio.com")[, "Package"]) | ||
if ("chromote" %in% avail_pkgs) { | ||
install.packages("chromote", repos = "https://cran.rstudio.com", type = "source") | ||
} else { | ||
options(repos = c(CRAN="https://cran.rstudio.com")) | ||
install.packages(c("curl", "remotes")) | ||
remotes::install_github("rstudio/chromote", dependencies = TRUE) | ||
} | ||
|
||
|
||
library(chromote) | ||
|
||
schloerke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set_default_chromote_object( | ||
Chromote$new( | ||
Chrome$new( | ||
args = c( | ||
"--disable-gpu", | ||
"--no-sandbox", | ||
"--disable-dev-shm-usage", # required bc the target easily crashes | ||
c("--force-color-profile", "srgb") | ||
) | ||
) | ||
) | ||
) | ||
|
||
schloerke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Make session | ||
b <- ChromoteSession$new() | ||
|
||
# Download google.com | ||
b$Page$navigate("https://www.rstudio.com/") | ||
|
||
# Get the outer HTML of the document | ||
outerHTML <- b$DOM$getOuterHTML(b$DOM$getDocument()$root$nodeId)$outerHTML | ||
print(outerHTML) | ||
|
||
# Yell if it doesn't find the close `html` tag; close tag is more consistent | ||
stopifnot(grepl("</html>", outerHTML, fixed = TRUE)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the context for these Makefile changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't. Reverting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jk. I can.
From deaa12, I added that if
./test
file,./install
file, orDockerfile.xenial
changed, then it would be nice if the method would run again.When running locally, the command wouldn't do anything if it a successful completion. Now, if any of those files changes, it is forced to run again.