mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
ci: updated base-image
This commit is contained in:
@@ -1,25 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# version
|
||||
# version - using "stable" for installation but not for verification
|
||||
version="stable"
|
||||
|
||||
# deps
|
||||
apt-get install -y xvfb libxi6 libgconf-2-4
|
||||
|
||||
# install chrome
|
||||
npx @puppeteer/browsers install chrome@${version}
|
||||
# install puppeteer browsers package globally first
|
||||
npm install -g @puppeteer/browsers
|
||||
|
||||
# verify chrome version
|
||||
if [[ ! "$(google-chrome --version)" =~ ^Google\ Chrome\ ${version} ]]; then
|
||||
echo "ERROR: chrome version does not match. expected: \"Google Chrome ${version}\", but actual is \"$(google-chrome --version)\""
|
||||
exit 1
|
||||
# install chrome with auto-yes
|
||||
npx -y @puppeteer/browsers install chrome@${version}
|
||||
|
||||
# verify chrome is installed (without specific version check)
|
||||
if ! command -v google-chrome &> /dev/null; then
|
||||
echo "ERROR: Chrome is not installed properly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# install chromedriver
|
||||
npx @puppeteer/browsers install chromedriver@${version}
|
||||
# install chromedriver with auto-yes
|
||||
npx -y @puppeteer/browsers install chromedriver@${version}
|
||||
|
||||
# verify chromedriver version
|
||||
if [[ ! "$(chromedriver --version)" =~ ^ChromeDriver\ ${version} ]]; then
|
||||
echo "ERROR: chromedriver version does not match. expected: \"ChromeDriver ${version}\", but actual is \"$(chromedriver --version)\""
|
||||
exit 1
|
||||
# verify chromedriver is installed (without specific version check)
|
||||
if ! command -v chromedriver &> /dev/null; then
|
||||
echo "ERROR: ChromeDriver is not installed properly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Print installed versions for reference
|
||||
echo "Installed Chrome version: $(google-chrome --version)"
|
||||
echo "Installed ChromeDriver version: $(chromedriver --version)"
|
||||
|
||||
# Create a temporary directory for the test
|
||||
TEST_DIR=$(mktemp -d)
|
||||
cd "$TEST_DIR"
|
||||
|
||||
# Create a simple test script
|
||||
cat > test.py << 'EOL'
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
try:
|
||||
chrome_options = Options()
|
||||
chrome_options.add_argument('--headless')
|
||||
chrome_options.add_argument('--no-sandbox')
|
||||
chrome_options.add_argument('--disable-dev-shm-usage')
|
||||
|
||||
driver = webdriver.Chrome(options=chrome_options)
|
||||
driver.get('https://www.google.com')
|
||||
print("ChromeDriver test successful!")
|
||||
driver.quit()
|
||||
except Exception as e:
|
||||
print(f"ChromeDriver test failed: {str(e)}")
|
||||
exit(1)
|
||||
EOL
|
||||
|
||||
# Run the test
|
||||
python3 test.py
|
||||
|
||||
# Clean up
|
||||
cd -
|
||||
rm -rf "$TEST_DIR"
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
version="22"
|
||||
|
||||
# installs nvm (Node Version Manager)
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
|
||||
|
||||
# download and install Node.js (you may need to restart the terminal)
|
||||
nvm install 22
|
||||
# ensure changes take effect immediately
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
|
||||
# set node version
|
||||
nvm use 22
|
||||
# download and install Node.js (you may need to restart the terminal)
|
||||
nvm install ${version}
|
||||
|
||||
# set node version and make it the default
|
||||
nvm use ${version}
|
||||
nvm alias default ${version}
|
||||
|
||||
# verifies the right Node.js version is in the environment
|
||||
if [[ ! "$(node -v)" =~ ^v22 ]]; then
|
||||
echo "Node.js version is not v22.x"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# verifies the right npm version is in the environment
|
||||
if [[ ! "$(npm -v)" =~ ^10 ]]; then
|
||||
echo "npm version is not 10.x"
|
||||
if [[ ! "$(node -v)" =~ ^v${version} ]]; then
|
||||
echo "Node.js version is not v${version}.x"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user