-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Unify shell scripts for local and saucelabs testing
- Loading branch information
1 parent
28ababa
commit fa3023f
Showing
3 changed files
with
136 additions
and
112 deletions.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,46 +1,148 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
# Global variables | ||
BROWSER="" | ||
USE_SAUCELABS=false | ||
|
||
if [ -z "$1" ]; then | ||
echo "No testcafe browser supplied, e.g. 'chrome:headless'" | ||
fi | ||
# Function to parse arguments and save values to global variables | ||
parse_arguments() { | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
-s|--saucelabs) | ||
USE_SAUCELABS=true | ||
;; | ||
-b|--browser) | ||
BROWSER="$2" | ||
shift | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
cd ../../.. | ||
# Function to print usage information | ||
usage() { | ||
cat <<EOF | ||
Usage: $0 [options] | ||
rm -rf DummyDistributionPackages || true | ||
mv DistributionPackages DummyDistributionPackages | ||
mkdir DistributionPackages | ||
Options: | ||
-h, --help Show this help message | ||
-s, --saucelabs Enable remote browser from SauceLabs | ||
-b, --browser Specify local browser to use | ||
EOF | ||
} | ||
|
||
ln -s "../Packages/Application/Neos.Neos.Ui/Tests/IntegrationTests/SharedNodeTypesPackage" DistributionPackages/Neos.TestNodeTypes | ||
|
||
for fixture in Packages/Application/Neos.Neos.Ui/Tests/IntegrationTests/Fixtures/*/; do | ||
echo "$fixture" | ||
function check_testcafe_browser { | ||
if [ -z "$BROWSER" ] && [ "$USE_SAUCELABS" = false ]; then | ||
echo "No testcafe browser supplied, e.g. 'chrome:headless'" | ||
exit 1 | ||
fi | ||
} | ||
|
||
ln -s "../${fixture}SitePackage" DistributionPackages/Neos.TestSite | ||
function check_saucelabs_setup { | ||
if [ "$USE_SAUCELABS" = true ]; then | ||
check_saucectl_variables | ||
check_saucectl_installed | ||
fi | ||
} | ||
|
||
# TODO: optimize this | ||
composer reinstall neos/test-nodetypes | ||
composer reinstall neos/test-site | ||
# make sure neos is installed even if patching led to the removal (bug) | ||
composer update neos/neos-development-collection | ||
./flow flow:cache:flush --force | ||
./flow flow:cache:warmup | ||
./flow configuration:show --path Neos.ContentRepository.contentDimensions | ||
# Check if SAUCE_USERNAME and SAUCE_ACCESS_KEY are set | ||
function check_saucectl_variables { | ||
if [[ -n "$SAUCE_USERNAME" && -n "$SAUCE_ACCESS_KEY" ]]; then | ||
echo "SAUCE_USERNAME and SAUCE_ACCESS_KEY are set. Configuring saucectl..." | ||
#saucectl configure | ||
else | ||
echo "SAUCE_USERNAME or SAUCE_ACCESS_KEY is not set. Skipping saucectl configuration." | ||
exit 1 | ||
fi | ||
} | ||
|
||
if ./flow site:list | grep -q 'Node name'; then | ||
./flow site:prune '*' | ||
# Check if saucectl is installed | ||
function check_saucectl_installed { | ||
if ! command -v saucectl &> /dev/null; then | ||
echo "saucectl is not installed. Installing saucectl..." | ||
# Install saucectl via npm (assuming npm is installed) | ||
npm install -g saucectl | ||
fi | ||
./flow site:import --package-key=Neos.TestSite | ||
./flow resource:publish | ||
} | ||
|
||
# get dimension from fixture | ||
function get_dimension() { | ||
dimension=$(basename "$1") | ||
echo "$dimension" | ||
} | ||
|
||
# Function that gets a fixture as parameter. With the fixture we | ||
# load the related site package and import the site. | ||
function initialize_neos_site() { | ||
local fixture=$1 | ||
|
||
ln -s "../${fixture}SitePackage" DistributionPackages/Neos.TestSite | ||
|
||
# TODO: optimize this | ||
composer reinstall neos/test-nodetypes | ||
composer reinstall neos/test-site | ||
# make sure neos is installed even if patching led to the removal (bug) | ||
composer update neos/neos-development-collection | ||
./flow flow:cache:flush --force | ||
./flow flow:cache:warmup | ||
./flow configuration:show --path Neos.ContentRepository.contentDimensions | ||
|
||
if ./flow site:list | grep -q 'Node name'; then | ||
./flow site:prune '*' | ||
fi | ||
./flow site:import --package-key=Neos.TestSite | ||
./flow resource:publish | ||
} | ||
|
||
cd Packages/Application/Neos.Neos.Ui | ||
yarn run testcafe "$1" "../../../${fixture}*.e2e.js" \ | ||
--selector-timeout=10000 --assertion-timeout=30000 | ||
function run_tests() { | ||
cd ../../.. | ||
rm -f DistributionPackages/Neos.TestSite | ||
|
||
done | ||
rm -rf DummyDistributionPackages || true | ||
mv DistributionPackages DummyDistributionPackages | ||
mkdir DistributionPackages | ||
|
||
ln -s "../Packages/Application/Neos.Neos.Ui/Tests/IntegrationTests/SharedNodeTypesPackage" DistributionPackages/Neos.TestNodeTypes | ||
|
||
for fixture in Packages/Application/Neos.Neos.Ui/Tests/IntegrationTests/Fixtures/*/; do | ||
dimension=$(get_dimension "$fixture") | ||
initialize_neos_site "$fixture" | ||
|
||
# go tp the Neos.Neos.Ui package and run the tests | ||
cd Packages/Application/Neos.Neos.Ui | ||
|
||
if [[ $BROWSER ]]; then | ||
yarn run testcafe "$BROWSER" "../../../${fixture}*.e2e.js" --selector-timeout=10000 --assertion-timeout=30000 | ||
fi | ||
|
||
if [[ $USE_SAUCELABS ]]; then | ||
saucectl run --config .sauce/config${dimension}.yml | ||
fi | ||
|
||
# cd back to the root directory and clean up | ||
cd ../../.. | ||
rm -f DistributionPackages/Neos.TestSite | ||
done | ||
|
||
rm -rf DistributionPackages | ||
mv DummyDistributionPackages DistributionPackages | ||
} | ||
|
||
# Parse arguments | ||
parse_arguments "$@" | ||
|
||
# check if incoming parameters are correct | ||
check_testcafe_browser | ||
check_saucelabs_setup | ||
|
||
rm -rf DistributionPackages | ||
mv DummyDistributionPackages DistributionPackages | ||
# Run the tests | ||
run_tests |