Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
eluhr committed Dec 15, 2021
2 parents 0890478 + 349d798 commit acf2be4
Show file tree
Hide file tree
Showing 90 changed files with 6,296 additions and 3,732 deletions.
7 changes: 5 additions & 2 deletions .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
# append the file to the list below.

# Full stack (development und testing)
COMPOSE_FILE=./docker/docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.test.yml:./docker/docker-compose.selenium.yml
COMPOSE_FILE=./docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.test.yml:./docker/docker-compose.selenium.yml
# Small stack (development only)
#COMPOSE_FILE=./docker/docker-compose.yml:./docker/docker-compose.dev.yml
#COMPOSE_FILE=./docker-compose.yml:./docker/docker-compose.dev.yml


# Project name, used for container-prefixes by docker-compose
COMPOSE_PROJECT_NAME=phd

# Name for build PHP application images
STACK_PHP_IMAGE=local/phd

# 3-digit port prefix, between 100-299
STACK_PORT_PREFIX=111
24 changes: 6 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ stages:

variables:
ISOLATION: "buildpipeline${CI_PIPELINE_ID}${CI_PROJECT_NAME}"
COMPOSE_FILE: "./docker/docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.test.yml:./docker/docker-compose.selenium.yml"
COMPOSE_FILE: "./docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.test.yml:./docker/docker-compose.selenium.yml"
STACK_PHP_IMAGE: "${PHP_IMAGE_NAME}:${CI_BUILD_REF}"
REGISTRY_PHP_IMAGE: "${PHP_IMAGE_NAME}:${CI_BUILD_REF_NAME}"

# ----------------------------------------------------------
# before/after scripts, these will be used in every job within the job-scope
Expand All @@ -24,7 +23,8 @@ before_script:
- docker-compose config
- echo ${ISOLATION}
- echo $(git describe --always --dirty --tags)
# run all commands from test environment
- export APP_VERSION=$(git describe --always --dirty --tags)
- export REGISTRY_PHP_IMAGE=${PHP_IMAGE_NAME}:${APP_VERSION}

after_script:
# set docker-compose isolation
Expand Down Expand Up @@ -70,7 +70,7 @@ after_script:
stage: test
script:
- export COMPOSE_PROJECT_NAME=${ISOLATION}${CI_BUILD_NAME}
- export PHP_ENABLE_XDEBUG=1
- make test-init
- make test-coverage
only:
- coverage
Expand All @@ -79,7 +79,7 @@ after_script:
when: always
expire_in: 4 weeks
paths:
- tests/_log
- _host-volumes/tests-log


.release_tmpl: &release_tmpl_ref
Expand All @@ -92,8 +92,7 @@ after_script:
- docker tag ${STACK_PHP_IMAGE} ${REGISTRY_PHP_IMAGE}
- docker push ${REGISTRY_PHP_IMAGE}
only:
- latest
- experimental
- releases
- tags


Expand All @@ -114,14 +113,3 @@ lint-debian:
# ----------------------------------------------------------
release-debian:
<<: *release_tmpl_ref

# ----------------------------------------------------------
deploy:staging:
stage: deploy
environment: staging
allow_failure: true
script:
- echo "Auto-deployment trigger not implemented."
- exit 1
only:
- latest
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# Changelog

### dev
### 5.6.0

- updated base-image `dmstr/php-yii2:7.4-fpm-8.0`
- composer 2
- added healthchecks
- use asset-packagist (preferred); disabled fxp/composer-asset-plugin

### 5.5.0-beta1

- added `Cell`s (`_beforeContent`, `_afterContent`) to `layouts/main.php`
- removed `Pjax` container in `layouts/main.php`

### 5.5.0-alpha1

- `yii db` has changed API
- base-image upgraded to `PHP 7.4`

### 5.4.1

- added `fsFtp` filesystem component

### 5.4.0

- added `APP_PAGES_TITLE_PREFIX`
- removed `cinghie/yii2-cookie-consent`
- removed `dmstr/yii2-contact-module`
- changed default vendor-asset paths to `bower-asset` & `npm-asset`
- changed scheduler to use `--entrySolo` for `audit/cleanup`

### 5.3.0

Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM dmstr/php-yii2:7.3-fpm-6.0-rc3-nginx
FROM dmstr/php-yii2:7.4-fpm-8.0-beta3-nginx
ARG BUILD_NO_INSTALL

RUN apt-get update \
&& apt-get install -y $PHPIZE_DEPS \
cron \
procps # recommended for dmstr/yii2-resque-module \
&& pecl install mailparse \
&& docker-php-ext-enable mailparse \
Expand All @@ -17,9 +18,12 @@ WORKDIR /app
COPY src/composer.* /app/src/

# Composer installation (skipped on first build in dist-upgrade)
# create bc link if not exists
RUN if [ -z "$BUILD_NO_INSTALL" ]; then \
composer -dsrc install --no-dev --prefer-dist --optimize-autoloader && \
composer -dsrc clear-cache; \
composer -dsrc clear-cache && \
ln -s bower-asset /app/vendor/bower && \
ln -s npm-asset /app/vendor/npm; \
fi

# Application source-code
Expand All @@ -29,16 +33,14 @@ COPY ./src /app/src/
COPY ./config /app/config/
COPY ./migrations /app/migrations/

# Tests source-code for integration tests in derived images
COPY ./tests /app/tests
RUN test -f /app/yii || ln -s /app/src/bin/yii /app/yii

# Permissions
RUN mkdir -p runtime web/assets web/bundles /mnt/storage && \
chmod -R 775 runtime web/assets web/bundles /mnt/storage && \
chmod -R ugo+r /root/.composer/vendor && \
chmod u+x /usr/local/bin/unique-number.sh /usr/local/bin/export-env.sh && \
chmod -R u+x /etc/periodic && \
chown -R www-data:www-data runtime web/assets web/bundles /root/.composer/vendor /mnt/storage
chown -R www-data:www-data runtime web/assets web/bundles /mnt/storage

VOLUME /app/runtime
VOLUME /app/web/assets
Expand All @@ -53,3 +55,9 @@ RUN crontab config/crontab

# export container environment for cronjobs on container start
CMD supervisord -c /etc/supervisor/supervisord.conf

# Tests source-code for integration tests in derived images
COPY ./tests /app/tests

HEALTHCHECK --interval=30s --timeout=5s --start-period=1m \
CMD curl -f http://localhost/static/status.php || exit 1
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ endif
default: help

all: ##@base shorthand for 'build init up setup open'
all: init build install up setup browser
all: init build install up setup open
all:
#
# make all
# Done.

dev: up setup browser

build: ##@base build images in stack
#
Expand Down Expand Up @@ -88,7 +89,7 @@ dist-upgrade: ##@base update application package, pull, rebuild
install: ##@base install PHP packages
$(DOCKER_COMPOSE) run --rm php composer -dsrc install

bash: ##@development execute application bash in one-off container
bash: ##@development execute application bash in php container
#
# Starting application bash
#
Expand Down Expand Up @@ -122,12 +123,18 @@ setup: ##@development run application setup
#
$(DOCKER_COMPOSE) run --rm $(PHP_SERVICE) yii app/setup

open: browser ##@development alias for: browser
browser: ##@development open application web service in browser
#
# Opening application on mapped web-service port
#
$(OPEN_CMD) http://$(DOCKER_HOST_IP):$(shell $(DOCKER_COMPOSE) port $(PHP_SERVICE) 80 | sed 's/[0-9.]*://') &>/dev/null

open-mailcatcher: ##@development open development mailcatcher
#
# Opening application on mapped web-service port
#
$(OPEN_CMD) http://$(DOCKER_HOST_IP):$(shell $(DOCKER_COMPOSE) port mailcatcher 80 | sed 's/[0-9.]*://') &>/dev/null

test: version build install up
test: ##@test run tests
Expand All @@ -136,24 +143,30 @@ test: ##@test run tests
$(DOCKER_COMPOSE) logs $(PHP_SERVICE) > _host-volumes/tests-log/php.log
$(DOCKER_COMPOSE) logs $(TESTER_SERVICE) > _host-volumes/tests-log/tester.log

test-coverage: version build install up
test-coverage: ##@test run tests with code coverage
PHP_ENABLE_XDEBUG=1 $(DOCKER_COMPOSE) up -d
$(DOCKER_COMPOSE) up -d
$(DOCKER_COMPOSE) run --rm -e YII_ENV=test $(TESTER_SERVICE) yii app/setup
$(DOCKER_COMPOSE) run --rm -e YII_ENV=test $(TESTER_SERVICE) codecept clean
$(DOCKER_COMPOSE) run --rm -e YII_ENV=test -e PHP_ENABLE_XDEBUG=1 $(TESTER_SERVICE) codecept run --env $(BROWSER_SERVICE) -x optional --coverage-html --coverage-xml --html --xml

test-init: ##@test initialize test-environment
cp -n .env-dist .env &2>/dev/null
mkdir -p _log/codeception && chmod 777 _log/codeception
mkdir -p _log/lint && chmod 777 _log/lint
mkdir -p _host-volumes/tests-log/codeception/_log && chmod 777 _host-volumes/tests-log/codeception/_log
mkdir -p _host-volumes/tests-log/lint && chmod 777 _host-volumes/tests-log/lint

test-bash: ##@test run application bash in one-off container
#
# Starting application bash
#
$(DOCKER_COMPOSE) run --rm $(TESTER_SERVICE) bash

test-browser: ##@test open application web service in browser
test-cli: ##@test run application test bash in one-off container
#
# Starting application bash
#
$(DOCKER_COMPOSE) run --rm -v $(PWD)/vendor-dev:/app/vendor $(TESTER_SERVICE) bash

test-open: ##@test open application web service in browser
#
# Opening application on mapped web-service port
#
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ See [configuration](https://github.com/dmstr/phd5-docs/blob/master/guide/develop

Initialize application and run command from `tests` folder

make init
cd tests

Setup test application stack

make up setup bash
make test

Run tests inside the container
Debug tests inside the container

$ codecept run
make bash
$ codecept run -d

See [testing](https://github.com/dmstr/phd5-docs/blob/master/guide/development/testing.md)...

Expand Down
16 changes: 14 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Upgrading

### 5.4/5.5 to 5.6

- upgrade `"wikimedia/composer-merge-plugin": "~2.0"`
- add ` "ap": { "type": "composer", "url": "https://asset-packagist.org" }` to `repositories` section in `composer.json`
- disable `fxp/asset-plugin` eg. `"enabled": false`
- make sure you have a `Public` role, which is a child of `Default` and `Guest` (`dmstr/yii2-web:>=1.1.1`)

### 5.3 to 5.4

- set `ENV COMPOSER=/app/composer.json` in project `Dockerfile`
- set `ENV COMPOSER=/app/composer.json` or `ENV COMPOSER=/app/project/composer.json` in project `Dockerfile`
- adjust merge path `"src/composer.phd5.json"` in project `composer.json`
- adjust config path `/app/config/` eg. in tests
- adjust config path `src/config/` to `config/` eg. in tests
- adjust bower and npm aliases/path in config and `composer.json`
- `"npm-asset-library": "../vendor/npm-asset"`
- `"bower-asset-library": "../vendor/bower-asset"`
- register empty `register_shutdown_function` for unit and functional tests, see also
- `tests/codeception/mock_register_shutdown_function.php`
- `tests/codeception/functional/_bootstrap.php`
- `tests/codeception/unit/_bootstrap.php`
- default value for `APP_ADMIN_EMAIL` removed, must be set in project
- image startup command has been changed from `forego` to `supervisord`
- update namespaces for `RbacMigration`, which has been extracted into separate package `dmstr/yii2-rbac-migration`
- make sure to assign `FileflyDefault` to `Editor` and `FileflyAdmin` to `Master`

### 5.2 to 5.3

Expand Down
43 changes: 43 additions & 0 deletions config/autocomplete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use pheme\settings\components\Settings;

/**
* Yii bootstrap file.
* Used for enhanced IDE code autocompletion.
*/
class Yii extends \yii\BaseYii
{
/**
* @var BaseApplication|WebApplication|ConsoleApplication the application instance
*/
public static $app;
}

/**
* Class BaseApplication
* Used for properties that are identical for both WebApplication and ConsoleApplication
*
*/
abstract class BaseApplication extends yii\base\Application
{
}

/**
* Class WebApplication
* Include only Web application related components here
*
* @property Settings $settings Settings component
*/
class WebApplication extends yii\web\Application
{
}

/**
* Class ConsoleApplication
* Include only Console application related components here
*
*/
class ConsoleApplication extends yii\console\Application
{
}
Loading

0 comments on commit acf2be4

Please sign in to comment.