Skip to content

Commit

Permalink
Merge pull request #2576 from TanaseTeofil/contribution/Setting_up_de…
Browse files Browse the repository at this point in the history
…v_enviornment

Contribution/setting up dev enviornment
  • Loading branch information
dpfaffenbauer committed Apr 29, 2024
2 parents 36dd7e7 + db079cd commit 6272e01
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 302 deletions.
12 changes: 1 addition & 11 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
# }

upstream php-pimcore10 {
server coreshop-php:9000;
}

upstream php-pimcore10-debug {
server coreshop-php-debug:9000;
server coreshop3-php:9000;
}

server {
Expand Down Expand Up @@ -121,7 +117,6 @@ server {
#try_files $fastcgi_script_name =404;
# include fastcgi.conf if needed
include fastcgi_params;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
Expand All @@ -134,11 +129,6 @@ server {
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";

# If Xdebug session is requested, pass it to the Xdebug enabled container
if ($http_cookie ~* "XDEBUG_SESSION") {
fastcgi_pass php-pimcore10-debug;
}

fastcgi_pass php-pimcore10;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
Expand Down
171 changes: 0 additions & 171 deletions .docker/nginx8.conf

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ drivers
vendor/
docs/generated-docs
node_modules
docker-compose.override.yaml
95 changes: 95 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,101 @@ your PR (if one is not already open), and your approach to solving it (not neces
* [Fork us!](https://help.github.com/articles/fork-a-repo/) Code! Follow the coding standards PSR-1 and PSR-2
* [Send a pull request](https://help.github.com/articles/using-pull-requests/) from your fork’s branch to our `master` branch.

## Set up local development environment
This guide outlines the steps to set up CoreShop for development on your local machine.
### Prerequisites:
* Docker Desktop: Ensure you have Docker Desktop installed and running on your system. You can find download and installation instructions for Windows, Mac and Linux here: https://docs.docker.com/desktop/ or
* OrbStack (macOS only): Ensure you have OrbStack installed on your system. You can find download and installation instructions here: https://orbstack.dev/

### Step 1: Build docker images
Navigate to the cloned CoreShop directory in your terminal, and run the following command to build the Docker images:

```shell
docker compose build --build-arg uid=$(id -u) --pull
```

### Step 2: Full Install
Run the following command to install Pimcore and CoreShop:
```shell
docker compose run --rm php bin/install
````

#### Step 3: Handle permissions
```shell
docker compose run --rm php chown www-data:www-data public/var/* var/*
```
For Linux Native systems we also need to execute:
```shell
sudo chown -R $(id -u):$(id -g)
```

### Manual Installation
Optionally you can run the single steps:

#### Step 1: Install Dependencies
Navigate to the cloned CoreShop directory in your terminal.

Run the following command to install all the required dependencies using Composer:
```shell
docker compose run --rm php composer install
```

#### Step 2: Install Pimcore
Run the following command to install Pimcore using the provided Docker image:
```shell
docker compose run --rm php vendor/bin/pimcore-install --no-interaction --ignore-existing-config
```

#### Step 3: Install CoreShop
Run the following command to install CoreShop:
```shell
docker compose run --rm php bin/console coreshop:install
```

#### Step 4: Install Demo Data (Optional)
CoreShop offers a demo dataset for testing purposes. To install the demo data, run the following command:
```shell
docker compose run --rm php bin/console coreshop:install:demo
```

## Running Code Analysis
CoreShop provides options for running code analysis tools like Psalm and PHPStan. These tools help identify potential errors and improve code quality.
Run the following command to execute Psalm within a Docker container:

```shell
docker compose run --rm php vendor/bin/psalm
```

Run the following command to run PHPStan with specific configuration options:
```shell
docker compose run --env SYMFONY_ENV=test --rm php vendor/bin/phpstan analyse -c phpstan.neon src -l 3 --memory-limit=-1
```

## Running Tests

Setup the behat container first by building the image and installing the dependencies:

```shell
docker compose build --build-arg behat
```

### BEHAT Domain

Run the following command to execute the domain tests:

```shell
docker compose run --rm behat vendor/bin/behat -c behat.yml.dist -p default
```

### BEHAT UI

UI tests require a running coreshop instance and a browser. Use the following command to run the UI tests
in a container:

```shell
docker compose run --rm behat
```

### Contributor License Agreement
The following terms are used throughout this agreement:

Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM pimcore/pimcore:php8.1-debug-latest as dev
RUN set -eux; \
apt-get update; \
apt-get install -y $PHPIZE_DEPS libxslt1-dev; \
docker-php-ext-install xsl; \
sync; \
apt-get purge -y $PHPIZE_DEPS; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
ARG uid=1000
RUN usermod -u $uid www-data && chown -R www-data:www-data /var/www

FROM dev as behat
RUN apt update && \
apt install -y chromium chromium-driver

# Install Symfony, Pimcore and CoreShop inside Tests container
# RUN wget https://get.symfony.com/cli/installer -O - | bash
RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash
RUN apt install symfony-cli

ENV PANTHER_NO_SANDBOX=1
ENV PANTHER_CHROME_ARGUMENTS='--disable-dev-shm-usage'
ENV CORESHOP_SKIP_DB_SETUP=1
ENV PANTHER_NO_HEADLESS=0
ENV APP_ENV="test"

30 changes: 2 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,10 @@ Password: coreshop
```

## Running Tests Locally
### Psalm
```
vendor/bin/psalm
```

### PHPStan
```
SYMFONY_ENV=test vendor/bin/phpstan analyse -c phpstan.neon src -l 3 --memory-limit=-1
```

### BEHAT Domain
```
CORESHOP_SKIP_DB_SETUP=1 PIMCORE_TEST_DB_DSN=mysql://root:ROOT@coreshop-3-mariadb/coreshop2___behat vendor/bin/behat -c behat.yml.dist -p default
```

### BEHAT UI
```
vendor/bin/bdi detect drivers
# Install Pimcore and CoreShop in Test Env
APP_ENV=test PIMCORE_TEST_DB_DSN=mysql://root:ROOT@coreshop-3-mariadb/coreshop2___behat PIMCORE_INSTALL_ADMIN_USERNAME=admin PIMCORE_INSTALL_ADMIN_PASSWORD=admin PIMCORE_INSTALL_MYSQL_HOST_SOCKET=coreshop-3-mariadb PIMCORE_INSTALL_MYSQL_USERNAME=root PIMCORE_INSTALL_MYSQL_PASSWORD=ROOT PIMCORE_INSTALL_MYSQL_DATABASE=coreshop2___behat PIMCORE_INSTALL_MYSQL_PORT=3306 PIMCORE_KERNEL_CLASS=Kernel vendor/bin/pimcore-install --ignore-existing-config --env=test --skip-database-config
APP_ENV=test PIMCORE_CLASS_DIRECTORY=var/tmp/behat/var/classes PIMCORE_TEST_DB_DSN=mysql://root:ROOT@coreshop-3-mariadb/coreshop2___behat bin/console coreshop:install

# OUTSIDE CONTAINER
# Run Symfony Server
APP_ENV=test PIMCORE_TEST_DB_DSN=mysql://root:ROOT@127.0.0.1:3306/coreshop2___behat symfony server:start --port=9080 --dir=public --no-tls
Follow the instructions in the [CONTRIBUTING.md](./CONTRIBUTING.md) to set up your local development environment
and run the tests.

# Run Behat
CORESHOP_SKIP_DB_SETUP=1 PANTHER_EXTERNAL_BASE_URI=http://127.0.0.1:9080/index_test.php PANTHER_NO_HEADLESS=0 PIMCORE_TEST_DB_DSN=mysql://root:ROOT@127.0.0.1:3306/coreshop2___behat php -d memory_limit=-1 vendor/bin/behat -c behat.yml.dist -p ui -vvv
```

## Copyright and license
Copyright: [CoreShop GmbH](https://www.coreshop.org)
Expand Down
6 changes: 6 additions & 0 deletions bin/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

composer install
vendor/bin/pimcore-install --no-interaction --ignore-existing-config
bin/console coreshop:install
bin/console coreshop:install:demo

0 comments on commit 6272e01

Please sign in to comment.