Skip to content

Commit

Permalink
- use composer v2
Browse files Browse the repository at this point in the history
 - link to guide for queue setup in readme
 - fix namespace for tests
 - rm artifacts in common config
  • Loading branch information
eLFuvo committed Jul 5, 2021
1 parent 6f1657c commit a01bdde
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 39 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build the docker-compose stack
run: docker-compose -f docker-compose.yml -p yii2-import build
run: docker build -t yii2-import:latest -f ./tests/docker/Dockerfile ./tests/docker
- name: Install composer packages
run: docker run --rm --volume $PWD:/app yii2-import_application composer install
run: docker run --rm --volume $PWD:/app yii2-import:latest composer install
- name: Run docker containers
run: docker-compose -f docker-compose.yml up -d
- name: Check running containers
run: docker ps -a
run: docker-compose ps
- name: Check logs
run: docker logs yii2-import
run: docker-compose logs
- name: Run test suite
run: docker-compose exec -T application composer test
- name: Stop docker containers
run: docker-compose -f docker-compose.yml down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 bankrot
Copyright (c) 2020 eLFuvo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ to the "require" section of your `composer.json` file.
Configure
---------

Configure desired storage option for the import result and the available import adapters
Configure desired storage option for the import result and available import adapters

```php
// in common app config
Expand Down Expand Up @@ -158,7 +158,7 @@ Also, the validation rules set automatically type of conversion of import data t

Important! Import file must have column(s) with unique (identity) values for updating existing models.

Yii2 queue component must be configured for executing ImportJob.
Yii2 [queue](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/README.md) component must be configured for executing ImportJob.

Screenshots
------------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"autoload": {
"psr-4": {
"elfuvo\\import\\": "src",
"elfuvo\\import\\app\\": "tests/app"
"elfuvo\\import\\tests\\app\\": "tests/app"
}
},
"require-dev": {
Expand Down
1 change: 1 addition & 0 deletions src/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function importBatch(): bool
/** @var Model|ActiveRecord $model */
$model = clone $this->model;
// some behaviors can be detached for the original model
// so detach its for cloned model
foreach ($model->getBehaviors() as $behavior => $config) {
if (!in_array($behavior, $behaviors)) {
$model->detachBehavior($behavior);
Expand Down
14 changes: 4 additions & 10 deletions tests/app/config/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

return [
'id' => 'tests',
'controllerNamespace' => 'elfuvo\\import\\app\\controllers',
'controllerNamespace' => 'elfuvo\\import\\tests\\app\\controllers',
'viewPath' => '@app/views',
'defaultRoute' => 'default/upload-file-import',
'name' => 'Import wizard',
Expand All @@ -34,23 +34,17 @@
\elfuvo\import\adapter\AdapterImportCsv::class,
]
],
yii\web\Request::class => [
'class' => yii\web\Request::class,
\yii\web\Request::class => [
'class' => \yii\web\Request::class,
'enableCookieValidation' => false,
'enableCsrfValidation' => false,
]
],
],
'modules' => [],
'components' => [
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => 'localhost',
'port' => 6379,
'database' => 0,
],
'cache' => [
'class' => yii\caching\FileCache::class,
'class' => \yii\caching\FileCache::class,
'keyPrefix' => 'import-wizard',
],
'queue' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/app/config/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return \yii\helpers\ArrayHelper::merge(require('common.php'),
[
'id' => 'tests',
'controllerNamespace' => 'elfuvo\\import\\app\\controllers',
'controllerNamespace' => 'elfuvo\\import\\tests\\app\\controllers',
'viewPath' => '@app/views',
'defaultRoute' => 'default/upload-file-import',
'name' => 'Import wizard',
Expand Down
4 changes: 2 additions & 2 deletions tests/app/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Time: 21:33
*/

namespace elfuvo\import\app\controllers;
namespace elfuvo\import\tests\app\controllers;

use elfuvo\import\actions\ProgressAction;
use elfuvo\import\actions\SetupAction;
use elfuvo\import\actions\UploadFileAction;
use elfuvo\import\app\models\Review;
use elfuvo\import\tests\app\models\Review;
use yii\web\Controller;
use yii\web\ErrorAction;

Expand Down
6 changes: 3 additions & 3 deletions tests/app/models/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 21:33
*/

namespace elfuvo\import\app\models;
namespace elfuvo\import\tests\app\models;

use Yii;
use yii\base\Model;
Expand All @@ -15,7 +15,7 @@
/**
*
* Class Review
* @package elfuvo\import\app\models
* @package elfuvo\import\tests\app\models
*/
class Review extends Model
{
Expand Down Expand Up @@ -105,7 +105,7 @@ public function rules()
* @param null $attributeNames
* @return bool
*/
public function save($runValidation = true, $attributeNames = null)
public function save($runValidation = true, $attributeNames = null): bool
{
if ($this->validate()) {
self::getList();
Expand Down
16 changes: 1 addition & 15 deletions tests/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,8 @@ memory_limit=-1\n\

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp
ENV COMPOSER_VERSION 1.9.3

RUN set -eux; \
curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://raw.githubusercontent.com/composer/getcomposer.org/cb19f2aa3aeaa2006c0cd69a7ef011eb31463067/web/installer; \
php -r " \
\$signature = '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5'; \
\$hash = hash('sha384', file_get_contents('/tmp/installer.php')); \
if (!hash_equals(\$signature, \$hash)) { \
unlink('/tmp/installer.php'); \
echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \
exit(1); \
}"; \
php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION}; \
composer --ansi --version --no-interaction; \
rm -f /tmp/installer.php; \
find /tmp -type d -exec chmod -v 1777 {} +
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

COPY docker-entrypoint.sh /docker-entrypoint.sh

Expand Down

0 comments on commit a01bdde

Please sign in to comment.