Skip to content

Commit

Permalink
Merge pull request #3 from webstream-framework/feature/#1_infrastructure
Browse files Browse the repository at this point in the history
各種環境更新
  • Loading branch information
mapserver2007 authored Jul 25, 2020
2 parents a341708 + fd1c008 commit 9ec21f6
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 50 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nanasess/setup-php@master
with:
php-version: '7.4'
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite and calculate coverage
run: phpdbg -qrr vendor/bin/phpunit --configuration phpunit.xml --coverage-clover=coverage.clover
- name: Prepare send coverage
run: wget https://scrutinizer-ci.com/ocular.phar
- name: Send coverage report to scrutinizer
run: php ocular.phar code-coverage:upload --format=php-clover coverage.clover
10 changes: 6 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ build:
nodes:
analysis:
environment:
php: 7.0.20
php: 7.3.0
tests:
override:
- command: phpcs-run
use_website_config: true
- phpcs-run
- php-scrutinizer-run

filter:
excluded_paths:
- 'Test/*'
- 'Modules/*'
tools:
external_code_coverage:
timeout: 2400
Expand All @@ -23,10 +23,11 @@ tools:
enabled: false
php_cs_fixer:
config:
level: psr2
level: psr12
filter:
excluded_paths:
- 'Test/*'
- 'Modules/*'
php_mess_detector:
config:
rulesets:
Expand All @@ -40,3 +41,4 @@ tools:
filter:
excluded_paths:
- 'Test/*'
- 'Modules/*'
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Container.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace WebStream\Container;

use WebStream\Exception\Extend\InvalidArgumentException;
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:7.4-cli
LABEL maintainer Ryuichi Tanaka <mapserver2007@gmail.com>

RUN apt-get update && apt-get install -y \
git

RUN pecl install xdebug-2.9.6 && \
docker-php-ext-enable xdebug

RUN rm -rf /var/lib/apt/lists/* && rm -rf /tmp/pear && rm -rf /tmp/* && \
apt-get clean -y && apt-get autoclean -y

WORKDIR /workspace
38 changes: 38 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'yaml'

def force_sh(cmd)
begin
sh cmd
rescue => e
puts e.message
end
end

task :default => :create_dev

task :create_dev => [:create_network, :prune] do
cmd = <<-EOS
docker-compose build
docker-compose down
docker-compose up -d
EOS
sh cmd
end

task :create_dev_debug do
cmd = <<-EOS
docker-compose build
docker-compose down
docker-compose up
EOS
sh cmd
end

task :prune do
force_sh 'docker volume prune -f > /dev/null 2>&1'
force_sh 'docker rmi -f $(docker images -f "dangling=true" -q) > /dev/null 2>&1'
end

task :create_network do
force_sh 'docker network create --driver bridge webstream_framework'
end
19 changes: 10 additions & 9 deletions Test/ContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace WebStream\Container\Test;

require_once dirname(__FILE__) . '/../Container.php';
Expand All @@ -7,7 +8,6 @@
require_once dirname(__FILE__) . '/../Test/Modules/InvalidArgumentException.php';

use WebStream\Container\Container;
use WebStream\Container\ValueProxy;
use WebStream\Container\Test\Providers\ContainerProvider;

/**
Expand Down Expand Up @@ -51,10 +51,11 @@ public function okLength()
* 値を削除できること
* 削除後の要素にアクセスすると例外が発生すること
* @test
* @expectedException WebStream\Exception\Extend\InvalidArgumentException
*/
public function okRemove()
{
$this->expectException(\WebStream\Exception\Extend\InvalidArgumentException::class);

$container = new Container();
$container->test1 = 1;
$container->remove("test1");
Expand Down Expand Up @@ -83,12 +84,12 @@ public function okRegisterPrimitive($value, $result)
*/
public function okRegisterClosure()
{
$func = function() {
$func = function () {
return "test";
};
$container = new Container();
$container->register("test", $func);
$this->assertInternalType("object", $container->test);
$this->assertIsObject($container->test);
$result = $container->test;
$this->assertEquals($result(), "test");
}
Expand All @@ -100,7 +101,7 @@ public function okRegisterClosure()
*/
public function okRegisterAsDynamic()
{
$func = function() {
$func = function () {
echo "evaluated";
return "test";
};
Expand All @@ -117,13 +118,13 @@ public function okRegisterAsDynamic()
*/
public function okRegisterAsLazy()
{
$func = function() {
$func = function () {
echo "evaluated";
return "test";
};
$container = new Container();
$container->registerAsLazy("test", $func);
$this->expectOutputString(null);
$this->expectOutputString("");
$this->assertEquals($container->test, "test");
$this->expectOutputString("evaluated");
}
Expand All @@ -135,7 +136,7 @@ public function okRegisterAsLazy()
*/
public function okRegisterCached()
{
$func = function() {
$func = function () {
echo "evaluated";
return "test";
};
Expand Down Expand Up @@ -163,7 +164,7 @@ public function okRegisterCached()
*/
public function okRegisterUnCached()
{
$func = function() {
$func = function () {
echo "evaluated";
return "test";
};
Expand Down
1 change: 1 addition & 0 deletions Test/Modules/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace WebStream\Exception\Extend;

/**
Expand Down
5 changes: 3 additions & 2 deletions Test/Providers/ContainerProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace WebStream\Container\Test\Providers;

/**
Expand All @@ -11,7 +12,7 @@ trait ContainerProvider
{
public function valueLazyProvider()
{
$func = function() {
$func = function () {
return "test";
};

Expand All @@ -25,7 +26,7 @@ public function valueLazyProvider()

public function valueDynamicProvider()
{
$func = function() {
$func = function () {
return "test";
};

Expand Down
1 change: 1 addition & 0 deletions ValueProxy.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace WebStream\Container;

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"phpunit/phpunit": "6.*"
"phpunit/phpunit": "9.*"
}
}
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'
services:
webstream-framework-container:
build: ./
image: webstream-framework/container
container_name: webstream-framework-container
volumes:
- ./:/workspace
working_dir: /workspace
tty: true
networks:
- webstream_framework
networks:
webstream_framework:
external: true
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset>
<file>./</file>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>./Test/*</exclude-pattern>
<rule ref="PSR12" />
<ini name="memory_limit" value="128M"/>
</ruleset>
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<exclude>
<directory>./Test</directory>
<directory>./Modules</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
Expand Down

0 comments on commit 9ec21f6

Please sign in to comment.