Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  update the documentation
  add option to never clear the terminal
  add available option
  replace travis by github ci
  CS
  rename __toString to toString
  use Path::resolve instead of manipulating strings
  clear terminal when the tests are green
  fail tests on warning
  add psalm
  update deps
  require php 7.4
  remove git-release integrating as the behaviour is not consistent
  • Loading branch information
Baptouuuu committed Mar 28, 2020
2 parents 59c8339 + 034c1c6 commit 752e28a
Show file tree
Hide file tree
Showing 41 changed files with 711 additions and 1,539 deletions.
3 changes: 0 additions & 3 deletions .gitattributes
@@ -1,7 +1,4 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/fixtures export-ignore
/tests export-ignore
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,65 @@
name: CI

on: [push]

jobs:
phpunit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['7.4']
name: 'PHPUnit - PHP/${{ matrix.php-version }} - OS/${{ matrix.os }}'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug
ini-values: xdebug.max_nesting_level=2048
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install --no-progress
- name: PHPUnit
run: vendor/bin/phpunit --coverage-clover=coverage.clover
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4']
name: 'Psalm - PHP/${{ matrix.php-version }}'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install --no-progress
- name: Psalm
run: vendor/bin/psalm --shepherd
6 changes: 0 additions & 6 deletions .scrutinizer.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

9 changes: 3 additions & 6 deletions README.md
@@ -1,10 +1,8 @@
# Lab Station

| `develop` |
|-----------|
| [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Innmind/LabStation/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/LabStation/?branch=develop) |
| [![Code Coverage](https://scrutinizer-ci.com/g/Innmind/LabStation/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/LabStation/?branch=develop) |
| [![Build Status](https://scrutinizer-ci.com/g/Innmind/LabStation/badges/build.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/LabStation/build-status/develop) |
[![Build Status](https://github.com/Innmind/LabStation/workflows/CI/badge.svg)](https://github.com/Innmind/LabStation/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/Innmind/LabStation/branch/develop/graph/badge.svg)](https://codecov.io/gh/Innmind/LabStation)
[![Type Coverage](https://shepherd.dev/github/Innmind/LabStation/coverage.svg)](https://shepherd.dev/github/Innmind/LabStation)

Development tool to automate certain parts of the dev cycle.

Expand All @@ -14,7 +12,6 @@ Automatisations:
- Launch PHPUnit tests when `src` or `tests` folders are modified
- Launch Psalm checks (if a `psalm.xml` exists) when `src` or `tests` folders are modified
- Start docker compose when there is a `docker-compose.yml` at the project root
- Ask for the kind of tag to create when branch is changed to `master`

![](example.gif)

Expand Down
19 changes: 9 additions & 10 deletions composer.json
Expand Up @@ -15,16 +15,14 @@
"issues": "http://github.com/Innmind/LabStation/issues"
},
"require": {
"php": "~7.2",
"innmind/url": "^2.0",
"innmind/cli": "^1.7",
"innmind/operating-system": "^1.6",
"php": "~7.4",
"innmind/url": "~3.3",
"innmind/cli": "~2.0",
"innmind/operating-system": "~2.0",
"innmind/json": "^1.1",
"symfony/dotenv": "^4.2",
"innmind/file-watch": "^1.1",
"innmind/ipc": "^2.1",
"innmind/process-manager": "^2.1",
"innmind/git-release": "^1.5"
"symfony/dotenv": "~5.0",
"innmind/ipc": "~3.0",
"innmind/process-manager": "~3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -39,7 +37,8 @@
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"giorgiosironi/eris": "^0.11.0"
"giorgiosironi/eris": "^0.11.0",
"vimeo/psalm": "^3.10"
},
"bin": ["lab-station"]
}
16 changes: 16 additions & 0 deletions psalm.xml
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
4 changes: 2 additions & 2 deletions src/Activity.php
Expand Up @@ -7,8 +7,8 @@

final class Activity
{
private $type;
private $data;
private Type $type;
private array $data;

public function __construct(Type $type, array $data)
{
Expand Down
25 changes: 19 additions & 6 deletions src/Activity/Type.php
Expand Up @@ -3,6 +3,8 @@

namespace Innmind\LabStation\Activity;

use Innmind\LabStation\Exception\LogicException;

final class Type
{
private $value;
Expand All @@ -12,6 +14,22 @@ private function __construct(string $value)
$this->value = $value;
}

public static function of(string $type): self
{
switch ($type) {
case 'sourcesModified':
return self::sourcesModified();

case 'testsModified':
return self::testsModified();

case 'start':
return self::start();
}

throw new LogicException("Unknown type '$type'");
}

public static function sourcesModified(): self
{
return new self('sourcesModified');
Expand All @@ -27,17 +45,12 @@ public static function start(): self
return new self('start');
}

public static function gitBranchChanged(): self
{
return new self('gitBranchChanged');
}

public function equals(self $other): bool
{
return $this->value === $other->value;
}

public function __toString(): string
public function toString(): string
{
return $this->value;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Agent.php
Expand Up @@ -3,9 +3,9 @@

namespace Innmind\LabStation;

use Innmind\Url\PathInterface;
use Innmind\Url\Path;

interface Agent
{
public function __invoke(PathInterface $project): void;
public function __invoke(Path $project): void;
}
71 changes: 0 additions & 71 deletions src/Agent/WatchCurrentGitBranch.php

This file was deleted.

29 changes: 13 additions & 16 deletions src/Agent/WatchSources.php
Expand Up @@ -9,45 +9,42 @@
Activity,
Activity\Type,
};
use Innmind\FileWatch\Watch;
use Innmind\OperatingSystem\Filesystem;
use Innmind\IPC\{
IPC,
Process\Name,
};
use Innmind\Url\{
PathInterface,
Path,
};
use Innmind\Url\Path;

final class WatchSources implements Agent
{
private $protocol;
private $watch;
private $ipc;
private $monitor;
private Protocol $protocol;
private Filesystem $filesystem;
private IPC $ipc;
private Name $monitor;

public function __construct(
Protocol $protocol,
Watch $watch,
Filesystem $filesystem,
IPC $ipc,
Name $monitor
) {
$this->protocol = $protocol;
$this->watch = $watch;
$this->filesystem = $filesystem;
$this->ipc = $ipc;
$this->monitor = $monitor;
}

public function __invoke(PathInterface $project): void
public function __invoke(Path $project): void
{
$src = new Path($project.'/src');
$src = $project->resolve(Path::of('src'));

($this->watch)($src)(function() {
$this->filesystem->watch($src)(function() {
$monitor = $this->ipc->get($this->monitor);
$monitor->send(
$this->protocol->encode(
new Activity(Type::sourcesModified(), [])
)
new Activity(Type::sourcesModified(), []),
),
);
$monitor->close();
});
Expand Down

0 comments on commit 752e28a

Please sign in to comment.