-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from 2pisoftware/feat/phpunit-10
Phpunit 10 and dev tools script
- Loading branch information
Showing
14 changed files
with
162 additions
and
953 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
# To be run on the container, see install_dev_tools.sh | ||
set -e | ||
|
||
echo "🏗️ Installing required system packages" | ||
apk add --no-cache php$PHPVERSION-dom php$PHPVERSION-xmlwriter php$PHPVERSION-tokenizer php$PHPVERSION-ctype mysql-client mariadb-connector-c-dev bash | ||
|
||
echo "🔨 Installing phpunit v${PHPUNIT}" | ||
cd /usr/local/bin && curl -L https://phar.phpunit.de/phpunit-${PHPUNIT}.phar -o phpunit && chmod +x phpunit && chmod 777 . | ||
|
||
# NOTE: Playwright is not recommended to be installed here |
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,113 @@ | ||
#!/bin/sh | ||
# Installs the dev tools to the desired cmfive container | ||
|
||
## USAGE: | ||
# If you have docker compose running: | ||
# ./install_dev_tools.sh | ||
# Or specify container name: | ||
# CONTAINER=cmfive_webapp_1 ./install_dev_tools.sh | ||
# To skip playwright dependencies: | ||
# SKIP_PLAYWRIGHT=true ./install_dev_tools.sh | ||
|
||
#Settings | ||
PHPVERSION=81 | ||
PHPUNIT=10 | ||
|
||
# If CONTAINER is not defined, default to the container name of the webapp service in docker compose | ||
if [ -z "$CONTAINER" ]; then | ||
CONTAINER=$(docker compose ps -q webapp) | ||
if [ -z "$CONTAINER" ]; then | ||
echo "❌ Error: Could not find container name. Please specify the container name with CONTAINER=container_name" | ||
exit 1 | ||
fi | ||
echo "💭 Using container from docker compose" | ||
fi | ||
|
||
# Check if $CONTAINER is a valid container name or id | ||
if ! docker inspect --type=container "$CONTAINER" >/dev/null 2>&1; then | ||
echo "❌ Error: Invalid container name or id: $CONTAINER" | ||
exit 1 | ||
fi | ||
|
||
# Tell user if test dir already exists in container (and has greater than 0 files) | ||
if docker exec $CONTAINER sh -c 'test -d "/var/www/html/test" && test "$(ls -A /var/www/html/test | wc -l)" -gt 0'; then | ||
echo "💭 Test directory exists in the container" | ||
else | ||
# Find test dir | ||
TEST_DIR="" | ||
if test -d "./test"; then | ||
TEST_DIR="./test" | ||
elif test -d "../test"; then | ||
TEST_DIR="../test" | ||
elif test -d "../../test"; then | ||
TEST_DIR="../../test" | ||
fi | ||
# If test dir is found and the container doesnt have an existing test dir, copy it | ||
if [ -n "$TEST_DIR" ] ; then | ||
echo "💭 Using test directory: $TEST_DIR" | ||
echo "📦 Copying test directory to container" | ||
docker cp "$TEST_DIR" "$CONTAINER:/var/www/html" | ||
if [ $? -ne 0 ]; then | ||
echo "❌ Error: Could not copy test directory to container" | ||
exit 1 | ||
fi | ||
else | ||
# If test dir is not found, exit the script | ||
echo "❌ Error: Could not find test directory" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "" | ||
echo "👷 -- Installing dev tools to container: $CONTAINER --" | ||
echo "" | ||
|
||
# Copy cmfive_dev_tools | ||
SCRIPT_DIR=$(dirname "$0") | ||
docker cp "$SCRIPT_DIR/cmfive_dev_tools.sh" "$CONTAINER:/home/cmfive" | ||
if [ $? -ne 0 ]; then | ||
echo "❌ Error: Could not copy cmfive_dev_tools.sh to container" | ||
exit 1 | ||
fi | ||
|
||
# Run cmfive_dev_tools | ||
docker exec $CONTAINER sh -c "PHPUNIT=${PHPUNIT} PHPVERSION=${PHPVERSION} /home/cmfive/cmfive_dev_tools.sh" | ||
if [ $? -ne 0 ]; then | ||
echo "❌ Error: cmfive_dev_tools.sh failed" | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "👷 -- Installing host machine dev tools --" | ||
echo "" | ||
|
||
# If SKIP_PLAYWRIGHT is true skip the rest of the script | ||
if [ "$SKIP_PLAYWRIGHT" = true ]; then | ||
echo "✔️ Dev tools installed successfully" | ||
exit 0 | ||
fi | ||
|
||
# --- Install Playwright dependencies --- | ||
echo "🔨 Installing Playwright dependencies" | ||
|
||
# If not Debian or Ubuntu exit the script | ||
if ! command -v apt-get &> /dev/null; then | ||
echo "⚠️ WARNING: Playwright dependencies are only supported on Debian and Ubuntu" | ||
echo "✔️ Dev tools installed successfully" | ||
exit 0 | ||
fi | ||
|
||
# Check if npm is installed on host machine | ||
if ! command -v npm &> /dev/null; then | ||
echo "⚠️ WARNING: npm is not installed on this machine. Please install npm and run 'npm install' in the test directory" | ||
echo "✔️ Dev tools installed successfully" | ||
exit 0 | ||
fi | ||
|
||
yes | npx playwright install --with-deps | ||
if [ $? -ne 0 ]; then | ||
echo "❌ Error: Failed to install Playwright dependencies" | ||
exit 1 | ||
fi | ||
|
||
echo "✔️ Dev tools installed successfully" |
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
Oops, something went wrong.