|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -ex |
| 3 | +###################################################### |
| 4 | +######################## VARS ######################## |
| 5 | +SITE_NAME='rtmedia.local' |
| 6 | +SITE_ROOT="/var/www/$SITE_NAME/htdocs" |
| 7 | +SITE_URL="http://$SITE_NAME/" |
| 8 | +function ee() { wo "$@"; } |
| 9 | +##################################################### |
| 10 | +# Start required services for site creation |
| 11 | +function start_services() { |
| 12 | + echo "Starting services" |
| 13 | + git config --global user.email "[email protected]" |
| 14 | + git config --global user.name "nobody" |
| 15 | + rm /etc/nginx/conf.d/stub_status.conf /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/22222 |
| 16 | + rm -rf /var/www/22222 |
| 17 | + ee stack start --nginx --mysql --php74 |
| 18 | + ee stack status --nginx --mysql --php74 |
| 19 | +} |
| 20 | + |
| 21 | +# Create, setup and populate rtMedia Pro plugin with data |
| 22 | +function create_and_configure_site () { |
| 23 | + |
| 24 | + ee site create $SITE_NAME --wp --php74 |
| 25 | + cd $SITE_ROOT/wp-content/plugins/ |
| 26 | + mkdir rtMedia |
| 27 | + rsync -azh $GITHUB_WORKSPACE/ $SITE_ROOT/wp-content/plugins/rtmedia |
| 28 | + echo "127.0.0.1 $SITE_NAME" >> /etc/hosts |
| 29 | + cd rtmedia |
| 30 | + ls |
| 31 | + wp plugin activate rtmedia --allow-root |
| 32 | + wp user create test [email protected] --role=administrator --user_pass=1234 --allow-root |
| 33 | + wp user create test1 [email protected] --role=administrator --user_pass=1234 --allow-root |
| 34 | + wp theme install twentytwentyone --allow-root |
| 35 | + wp theme activate twentytwentyone --allow-root |
| 36 | + wp plugin install buddypress --allow-root |
| 37 | + wp plugin activate buddypress --allow-root |
| 38 | +} |
| 39 | + |
| 40 | +# Install WPe2e dependency |
| 41 | +function install_playwright_package () { |
| 42 | + |
| 43 | + cd $GITHUB_WORKSPACE/tests/wp-e2e-playwright |
| 44 | + git clone --depth=1 https://github.com/rtCamp/rtmedia-test-data.git test-data |
| 45 | + npm install |
| 46 | + |
| 47 | +} |
| 48 | + |
| 49 | +function install_playwright(){ |
| 50 | + cd $GITHUB_WORKSPACE/tests/wp-e2e-playwright |
| 51 | + npx playwright install |
| 52 | +} |
| 53 | + |
| 54 | +# Run test for new deployed site |
| 55 | +function run_playwright_tests () { |
| 56 | + cd $GITHUB_WORKSPACE/tests/wp-e2e-playwright |
| 57 | + npm run test-e2e:playwright -- prerequisite.spec.js |
| 58 | + npm run test-e2e:playwright -- specs/buddypress |
| 59 | + npm run test-e2e:playwright -- specs/display |
| 60 | + npm run test-e2e:playwright -- specs/other_settings |
| 61 | + npm run test-e2e:playwright -- media_size.spec.js |
| 62 | + npm run test-e2e:playwright -- types.spec.js |
| 63 | +} |
| 64 | + |
| 65 | +function maybe_install_node_dep() { |
| 66 | + if [[ -n "$NODE_VERSION" ]]; then |
| 67 | + echo "Setting up $NODE_VERSION" |
| 68 | + NVM_LATEST_VER=$(curl -s "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | |
| 69 | + grep '"tag_name":' | |
| 70 | + sed -E 's/.*"([^"]+)".*/\1/') && |
| 71 | + curl -fsSL "https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_LATEST_VER/install.sh" | bash |
| 72 | + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" |
| 73 | + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm |
| 74 | + nvm install "$NODE_VERSION" |
| 75 | + nvm use "$NODE_VERSION" |
| 76 | + |
| 77 | + [[ -z "$NPM_VERSION" ]] && NPM_VERSION="latest" || echo '' |
| 78 | + export npm_install=$NPM_VERSION |
| 79 | + curl -fsSL https://www.npmjs.com/install.sh | bash |
| 80 | + fi |
| 81 | +} |
| 82 | + |
| 83 | +function main() { |
| 84 | + start_services |
| 85 | + create_and_configure_site |
| 86 | + maybe_install_node_dep |
| 87 | + install_playwright_package |
| 88 | + install_playwright |
| 89 | + run_playwright_tests |
| 90 | +} |
| 91 | + |
| 92 | +main |
0 commit comments