Skip to content

Commit

Permalink
Revert: move tests back to dev directory (#11)
Browse files Browse the repository at this point in the history
* Revert "Test: moved tests to root (as common practice)"

This reverts commit 29b1e43.

* Revert "Remove docker install running php82"

This reverts commit 1fd3702.

* Revert "Remove gitpod running php73"

This reverts commit e4baf37.

* Move tests back to dev directory

* Fixed paths
  • Loading branch information
sreichel authored Feb 16, 2024
1 parent 38e3480 commit 923148f
Show file tree
Hide file tree
Showing 1,618 changed files with 367 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ jobs:
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "./tests/logging/junit*.xml"
files: "./dev/tests/logs/junit*.xml"
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
echo $PWD
ls -la
head ./tests/reports/clover-sonar.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./tests/logging/junit-sonar.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./tests/reports/clover-sonar.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/logs/junit-sonar.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/reports/clover-sonar.xml
head ./tests/reports/clover-sonar.xml
ls -la
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

# Add a base setup for running unit Tests with code coverage and send them to SonarCloud
# https://github.com/OpenMage/magento-lts/pull/1836
/tests/reports/*
/tests/logging/*
/tests/functional/generated
/tests/functional/vendor
/dev/tests/reports/*
/dev/tests/logs/*
/dev/tests/functional/generated
/dev/tests/functional/vendor

/media/*
!/media/.htaccess
Expand Down
4 changes: 2 additions & 2 deletions tests/.htaccess → dev/.htaccess
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Order deny,allow
Deny from all
Order deny,allow
Deny from all
67 changes: 67 additions & 0 deletions dev/gitpod/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: "3.7"

services:
apache:
image: openmage/php-dev:7.3-apache
hostname: ${HOST_NAME:-openmage-7f000001.nip.io}
user: "33333:33333"
ports:
- "${HOST_PORT:-80}:80"
volumes:
- ../..:/var/www/html
environment:
- ENABLE_SENDMAIL=true
- XDEBUG_CONFIG=remote_connect_back=1 remote_enable=1 idekey=phpstorm
- MAGE_IS_DEVELOPER_MODE=1
links:
- mysql

cron:
image: openmage/php-dev:7.3-cli
working_dir: /var/www/html
command: /run-cron.sh
user: www-data
volumes:
- ../..:/var/www/html
environment:
- ENABLE_SENDMAIL=true
links:
- mysql

cli:
image: openmage/php-dev:7.3-apache
working_dir: /var/www/html
command: /bin/true
user: "33333:33333"
volumes:
- ../..:/var/www/html
# environment:
# - AWS_ACCESS_KEY_ID=00000000000000000000
# - AWS_SECRET_ACCESS_KEY=0000000000000000000000000000000000000000
# - AWS_REGION=eu-west-1
# - AWS_BUCKET=magedbm
# - AWS_MEDIA_BUCKET=magemm
links:
- mysql
- "apache:${HOST_NAME:-openmage-7f000001.nip.io}"

composer:
image: composer:2.4
volumes:
- ../..:/app

mysql:
image: mysql:5.7
ports:
- 3306
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_USER=openmage
- MYSQL_PASSWORD=openmage
- MYSQL_DATABASE=openmage
volumes:
- mysql:/var/lib/mysql

volumes:
mysql:
53 changes: 53 additions & 0 deletions dev/gitpod/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -e
dir=$(dirname "${BASH_SOURCE[0]}")
cd $dir
test -f .env && source .env

chmod 777 ../../app/etc ../../media ../../var

docker-compose up -d mysql apache
sleep 4
# mostly a copy from the openmage directory
echo "Starting services..."
for i in $(seq 1 20); do
sleep 1
docker exec gitpod-mysql-1 mysql -e 'show databases;' 2>/dev/null | grep -qF 'openmage' && break
done

HOST_PORT_PART=":${HOST_PORT:-80}"
test "$HOST_PORT_PART" = ":80" && HOST_PORT_PART=""
BASE_URL=${BASE_URL:-"http://${HOST_NAME:-openmage-7f000001.nip.io}${HOST_PORT_PART}/"}
ADMIN_EMAIL="${ADMIN_EMAIL:-admin@example.com}"
ADMIN_USERNAME="${ADMIN_USERNAME:-admin}"
ADMIN_PASSWORD="${ADMIN_PASSWORD:-veryl0ngpassw0rd}"

echo "Installing Composer dependencies..."
docker-compose run --rm composer composer install --no-progress --ignore-platform-req=ext-*

echo "Installing OpenMage LTS..."
docker-compose run --rm cli php install.php \
--license_agreement_accepted yes \
--locale en_US \
--timezone America/New_York \
--default_currency USD \
--db_host mysql \
--db_name openmage \
--db_user openmage \
--db_pass openmage \
--url "$BASE_URL" \
--use_rewrites yes \
--use_secure no \
--secure_base_url "$BASE_URL" \
--use_secure_admin no \
--skip_url_validation \
--admin_firstname OpenMage \
--admin_lastname User \
--admin_email "$ADMIN_EMAIL" \
--admin_username "$ADMIN_USERNAME" \
--admin_password "$ADMIN_PASSWORD"

echo ""
echo "Setup is complete!"
echo "Visit ${BASE_URL}/admin and login with '$ADMIN_USERNAME' : '$ADMIN_PASSWORD'"
echo "MySQL server IP: $(docker exec gitpod-apache-1 getent hosts mysql | awk '{print $1}')"
70 changes: 70 additions & 0 deletions dev/openmage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
OpenMage Dev Environment
===

With these files you can have a fully operational OpenMage LTS development environment in ONE step!

**NOTE: This is not for production use!**

For a more robust development environment that supports https, please consider using [ddev](https://ddev.readthedocs.io/en/stable/users/cli-usage/#magento-1-quickstart).

## Prerequisites

- Install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/)
- Port 80 on your host must be unused. See [Environment Variables](#environment-variables) below if you need to use another port.
- Clone the OpenMage LTS repo to your location of choice (`git clone https://github.com/OpenMage/magento-lts.git`).

## Installation

Run `dev/openmage/install.sh`. That's it!

Visit [http://openmage-7f000001.nip.io/](http://openmage-7f000001.nip.io/) and start coding!

Tips
===

See [colinmollenhour/docker-openmage-dev](https://github.com/colinmollenhour/docker-openmage-dev) for more information
on the containers used in this setup, but here are some quick tips:

- You can start the cron task using `docker-compose up -d cron`.
- The `cli` service contains many useful tools like `composer`, `magerun`, `modman`, `mageconfigsync` and more.
- XDebug is enabled using `remote_connect_back=1` with `idekey=phpstorm`. Customize this in `.env` if needed as described below.

Here are some common commands you may wish to try (from the `dev/openmage` directory):

```
$ docker-compose run --rm -u $(id -u):$(id -g) cli composer show
$ docker-compose run --rm -u $(id -u):$(id -g) cli bash
$ docker-compose run --rm cli magerun sys:check
$ docker-compose run --rm cli magerun cache:clean
$ docker-compose run --rm cli magerun db:console
$ docker-compose exec mysql mysql
```

- *The cli container runs as `www-data` by default so use `-u $(id -u):$(id -g)` with composer so that the container will create/modify files with your user permissions to avoid file permission errors in your IDE.*
- *Always use `run --rm` with the cli container to avoid creating lots of orphan containers.*

Environment Variables
---

You can override some defaults using environment variables defined in a file (that you must create) at `dev/openmage/.env`.

- `ENABLE_SENDMAIL=false` - Disable the sendmail MTA
- `XDEBUG_CONFIG=...` - Override the default XDebug config
- `HOST_NAME=your-preferred-hostname`
- `openmage-7f000001.nip.io` is used by default to resolve to `127.0.0.1`. See [nip.io](https://nip.io) for more info.
- `HOST_PORT=8888`
- `80` is used by default
- `ADMIN_EMAIL`
- `ADMIN_USERNAME`
- `ADMIN_PASSWORD`
- `MAGE_IS_DEVELOPER_MODE`
- Set to 1 by default, set to 0 to disable

Wiping
---

If you want to start fresh, wipe out your installation with the following command:

```
$ docker-compose down --volumes && rm -f ../../app/etc/local.xml
```
6 changes: 6 additions & 0 deletions dev/openmage/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/colinmollenhour/docker-openmage-dev:8.2-apache

ENV APACHE_DOCUMENT_ROOT /var/www/html/pub/default

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
68 changes: 68 additions & 0 deletions dev/openmage/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: "3.7"

services:
apache:
build: apache
hostname: ${HOST_NAME:-openmage-7f000001.nip.io}
ports:
- "${HOST_PORT:-80}:80"
volumes:
- ../..:/var/www/html
environment:
- ENABLE_SENDMAIL=${ENABLE_SENDMAIL:-true}
- XDEBUG_CONFIG=${XDEBUG_CONFIG:-client_host=host.docker.internal mode=debug force_display_errors=1 start_with_request=yes}
- MAGE_IS_DEVELOPER_MODE=${MAGE_IS_DEVELOPER_MODE:-1}
links:
- mysql

cron:
image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-cli
working_dir: /var/www/html
command: /run-cron.sh
volumes:
- ../..:/var/www/html
environment:
- ENABLE_CRON=true
links:
- mysql

cli:
image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-cli
working_dir: /var/www/html
command: /bin/true
user: www-data
volumes:
- ../..:/var/www/html
environment:
- COMPOSER_HOME=${COMPOSER_HOME:-/var/www/html/var/.composer}
# - AWS_ACCESS_KEY_ID=00000000000000000000
# - AWS_SECRET_ACCESS_KEY=0000000000000000000000000000000000000000
# - AWS_REGION=eu-west-1
# - AWS_BUCKET=magedbm
# - AWS_MEDIA_BUCKET=magemm
links:
- mysql
- "apache:${HOST_NAME:-openmage-7f000001.nip.io}"

mysql:
image: mysql:8.0
ports:
- 3306
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_USER=openmage
- MYSQL_PASSWORD=openmage
- MYSQL_DATABASE=openmage
volumes:
- mysql:/var/lib/mysql

redis:
image: redis:7-alpine
command: redis-server --appendonly yes --maxmemory 10m
volumes:
- redis:/data

volumes:
mysql:
redis:
79 changes: 79 additions & 0 deletions dev/openmage/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
set -e
dir=$(dirname "${BASH_SOURCE[0]}")
cd $dir

# Detect "docker compose" or "docker-compose"
dc="docker compose"
if ! docker compose --help >/dev/null; then
if ! command -v docker-compose 2>&1 >/dev/null; then
echo "Please first install docker-compose."
else
dc="docker-compose"
fi
fi
test -f .env && source .env

HOST_PORT=":${HOST_PORT:-80}"
test "$HOST_PORT" = ":80" && HOST_PORT=""
BASE_URL=${BASE_URL:-"http://${HOST_NAME:-openmage-7f000001.nip.io}${HOST_PORT}/"}
ADMIN_EMAIL="${ADMIN_EMAIL:-admin@example.com}"
ADMIN_USERNAME="${ADMIN_USERNAME:-admin}"
ADMIN_PASSWORD="${ADMIN_PASSWORD:-veryl0ngpassw0rd}"

if test -f ../../app/etc/local.xml; then
echo "Already installed!";
if [[ "$1" = "--reset" ]]; then
echo "Wiping previous installation..."
cd $dir && $dc down --volumes && rm ../../app/etc/local.xml
else
echo "Visit ${BASE_URL}admin and login with '$ADMIN_USERNAME' : '$ADMIN_PASSWORD'"
echo "MySQL server IP: $($dc exec apache getent hosts mysql | awk '{print $1}')"
echo "To start a clean installation run: $0 --reset"
exit 1
fi
fi

echo "Preparing filesystem..."
mkdir -p ../../vendor
chgrp 33 ../../app/etc ../../media ../../media/* ../../var ../../vendor
chmod g+ws ../../app/etc ../../media ../../media/* ../../var ../../vendor
$dc run --rm --no-deps cli mkdir -p var/cache var/log var/locks var/session

echo "Starting services..."
$dc up -d mysql apache
sleep 4
for i in $(seq 1 20); do
sleep 1
$dc exec mysql mysql -e 'show databases;' 2>/dev/null | grep -qF 'openmage' && break
done

echo "Installing Composer dependencies..."
$dc run --rm -u "$(id -u):$(id -g)" cli composer install --no-progress

echo "Installing OpenMage LTS..."
$dc run --rm cli php install.php \
--license_agreement_accepted yes \
--locale en_US \
--timezone America/New_York \
--default_currency USD \
--db_host mysql \
--db_name openmage \
--db_user openmage \
--db_pass openmage \
--url "$BASE_URL" \
--use_rewrites yes \
--use_secure no \
--secure_base_url "$BASE_URL" \
--use_secure_admin no \
--skip_url_validation \
--admin_firstname OpenMage \
--admin_lastname User \
--admin_email "$ADMIN_EMAIL" \
--admin_username "$ADMIN_USERNAME" \
--admin_password "$ADMIN_PASSWORD"

echo ""
echo "Setup is complete!"
echo "Visit ${BASE_URL}admin and login with '$ADMIN_USERNAME' : '$ADMIN_PASSWORD'"
echo "MySQL server IP: $($dc exec apache getent hosts mysql | awk '{print $1}')"
Loading

0 comments on commit 923148f

Please sign in to comment.