Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  update the doc
  add missing test
  add missing memory activity
  add missing activity messages
  only disable functional test for linux in ci
  add missing env variable
  replace travis by github ci
  CS
  remove the use of an iterator
  rename __toString to toString
  add psalm
  update deps
  require php 7.4
  modify crawled website as example.com does not resolve locally
  • Loading branch information
Baptouuuu committed Mar 27, 2020
2 parents 656500c + 6183463 commit ab39d8b
Show file tree
Hide file tree
Showing 140 changed files with 1,805 additions and 645 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
@@ -1,7 +1,5 @@
/.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
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,67 @@
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
env:
CI: 'github'
- 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
7 changes: 0 additions & 7 deletions .scrutinizer.yml

This file was deleted.

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

This file was deleted.

10 changes: 4 additions & 6 deletions README.md
@@ -1,10 +1,8 @@
# Silent Cartographer

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

Simple tool to visualize all the operations done on the operating system inside other php applications.

Expand Down Expand Up @@ -42,7 +40,7 @@ use function Innmind\SilentCartographer\bootstrap;
new class extends Main {
protected function main(Environment $env, OperatingSystem $os): void
{
$os = bootstrap($os)['cli'](new Path(__DIR__));
$os = bootstrap($os)['cli'](Path::of(__DIR__));
// then use the $os variable like you would normally do
}
}
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
@@ -0,0 +1,2 @@
ignore:
- fixtures/
17 changes: 9 additions & 8 deletions composer.json
Expand Up @@ -15,14 +15,13 @@
"issues": "http://github.com/Innmind/SilentCartographer/issues"
},
"require": {
"php": "~7.2",
"innmind/url": "^2.0",
"innmind/server-status": "^1.3",
"innmind/immutable": "^2.13",
"innmind/operating-system": "^1.6",
"innmind/ipc": "^2.0",
"php": "~7.4",
"innmind/url": "~3.3",
"innmind/immutable": "~3.5",
"innmind/operating-system": "~2.0",
"innmind/ipc": "~3.0",
"innmind/json": "^1.1",
"innmind/cli": "^1.7"
"innmind/cli": "~2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,7 +37,9 @@
"require-dev": {
"phpunit/phpunit": "~8.0",
"giorgiosironi/eris": "^0.11.0",
"innmind/object-graph": "^1.4"
"innmind/object-graph": "~2.0",
"vimeo/psalm": "^3.10",
"innmind/black-box": "^4.2"
},
"bin": ["silent-cartographer"]
}
10 changes: 5 additions & 5 deletions fixtures/crawler.php
Expand Up @@ -7,18 +7,18 @@
use Innmind\Url\Url;
use Innmind\Http\{
Message\Request\Request,
Message\Method\Method,
ProtocolVersion\ProtocolVersion,
Message\Method,
ProtocolVersion,
};
use Innmind\TimeContinuum\Period\Earth\Millisecond;
use Innmind\TimeContinuum\Earth\Period\Millisecond;
use function Innmind\SilentCartographer\bootstrap;

$os = Factory::build();
$os = bootstrap($os)['cli'](Url::fromString('file://'.__DIR__));
$os = bootstrap($os)['cli'](Url::of('file://'.__DIR__));

do {
$os->remote()->http()(new Request(
Url::fromString('http://example.com'),
Url::of('https://github.com'),
Method::get(),
new ProtocolVersion(2, 0)
));
Expand Down
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>
10 changes: 5 additions & 5 deletions src/Command/AutoStartSubRoutine.php
Expand Up @@ -16,8 +16,8 @@

final class AutoStartSubRoutine implements Command
{
private $run;
private $processes;
private Command $run;
private Processes $processes;

public function __construct(Command $run, Processes $processes)
{
Expand All @@ -32,14 +32,14 @@ public function __invoke(Environment $env, Arguments $arguments, Options $option
->execute(
Executable::background('silent-cartographer')
->withArgument('sub-routine')
->withWorkingDirectory((string) $env->workingDirectory())
->withWorkingDirectory($env->workingDirectory()),
);

($this->run)($env, $arguments, $options);
}

public function __toString(): string
public function toString(): string
{
return (string) $this->run;
return $this->run->toString();
}
}
25 changes: 13 additions & 12 deletions src/Command/Panel.php
Expand Up @@ -24,13 +24,14 @@
};
use Innmind\Stream\Writable;
use Innmind\Immutable\Str;
use function Innmind\Immutable\unwrap;

final class Panel implements Command
{
private $ipc;
private $subRoutine;
private $protocol;
private $signals;
private IPC $ipc;
private Name $subRoutine;
private Protocol $protocol;
private Signals $signals;

public function __construct(
IPC $ipc,
Expand All @@ -49,16 +50,16 @@ public function __invoke(Environment $env, Arguments $arguments, Options $option
$this->ipc->wait($this->subRoutine);
$process = $this->ipc->get($this->subRoutine);
$this->safe($process);
$process->send(new PanelActivated(...$arguments->pack()));
$process->send(new PanelActivated(...unwrap($arguments->pack())));

$this->print(
$process,
$env->output(),
$options->contains('format') ? $options->get('format') : '[{type}][{pid}][{room}][{tags}] {activity}'
$options->contains('format') ? $options->get('format') : '[{type}][{pid}][{room}][{tags}] {activity}',
);
}

public function __toString(): string
public function toString(): string
{
return <<<USAGE
panel ...tags --format=
Expand Down Expand Up @@ -105,11 +106,11 @@ private function print(Process $process, Writable $output, string $format): void

$output->write(
Str::of("$format\n")
->replace('{type}', (string) $roomActivity->program()->type())
->replace('{pid}', (string) $roomActivity->program()->id())
->replace('{room}', (string) $roomActivity->program()->room()->location()->path())
->replace('{tags}', \implode('/', \iterator_to_array($roomActivity->activity()->tags())))
->replace('{activity}', (string) $roomActivity->activity())
->replace('{type}', $roomActivity->program()->type()->toString())
->replace('{pid}', $roomActivity->program()->id()->toString())
->replace('{room}', $roomActivity->program()->room()->location()->path()->toString())
->replace('{tags}', \implode('/', $roomActivity->activity()->tags()->list()))
->replace('{activity}', $roomActivity->activity()->toString()),
);
} while (!$process->closed());
} catch (RuntimeException $e) {
Expand Down
17 changes: 7 additions & 10 deletions src/Command/SubRoutine.php
Expand Up @@ -17,15 +17,12 @@

final class SubRoutine implements Command
{
private $ipc;
private $subRoutine;
private $listen;

public function __construct(
IPC $ipc,
Name $subRoutine,
Listen $listen
) {
private IPC $ipc;
private Name $subRoutine;
private Listen $listen;

public function __construct(IPC $ipc, Name $subRoutine, Listen $listen)
{
$this->ipc = $ipc;
$this->subRoutine = $subRoutine;
$this->listen = $listen;
Expand All @@ -40,7 +37,7 @@ public function __invoke(Environment $env, Arguments $arguments, Options $option
($this->listen)();
}

public function __toString(): string
public function toString(): string
{
return <<<USAGE
sub-routine
Expand Down
8 changes: 8 additions & 0 deletions src/Exception/LogicException.php
@@ -0,0 +1,8 @@
<?php
declare(strict_types = 1);

namespace Innmind\SilentCartographer\Exception;

class LogicException extends \LogicException implements Exception
{
}
13 changes: 7 additions & 6 deletions src/IPC/Message/PanelActivated.php
Expand Up @@ -5,21 +5,21 @@

use Innmind\IPC\Message;
use Innmind\Json\Json;
use Innmind\Filesystem\MediaType;
use Innmind\MediaType\MediaType;
use Innmind\Immutable\Str;

final class PanelActivated implements Message
{
private $content;
private $mediaType;
private Str $content;
private MediaType $mediaType;

public function __construct(string ...$tags)
{
$this->content = Str::of(Json::encode([
'message' => 'panel_activated',
'tags' => $tags,
]));
$this->mediaType = new MediaType\MediaType('application', 'json');
$this->mediaType = new MediaType('application', 'json');
}

public function mediaType(): MediaType
Expand All @@ -34,11 +34,12 @@ public function content(): Str

public function equals(Message $message): bool
{
if ((string) $this->mediaType !== (string) $message->mediaType()) {
if ($this->mediaType->toString() !== $message->mediaType()->toString()) {
return false;
}

$data = Json::decode((string) $message->content());
/** @var array */
$data = Json::decode($message->content()->toString());

return ($data['message'] ?? '') === 'panel_activated';
}
Expand Down
12 changes: 6 additions & 6 deletions src/IPC/Message/PanelDeactivated.php
Expand Up @@ -4,18 +4,18 @@
namespace Innmind\SilentCartographer\IPC\Message;

use Innmind\IPC\Message;
use Innmind\Filesystem\MediaType;
use Innmind\MediaType\MediaType;
use Innmind\Immutable\Str;

final class PanelDeactivated implements Message
{
private $content;
private $mediaType;
private Str $content;
private MediaType $mediaType;

public function __construct()
{
$this->content = Str::of('panel_deactivated');
$this->mediaType = new MediaType\MediaType('text', 'plain');
$this->mediaType = new MediaType('text', 'plain');
}

public function mediaType(): MediaType
Expand All @@ -30,7 +30,7 @@ public function content(): Str

public function equals(Message $message): bool
{
return (string) $this->mediaType === (string) $message->mediaType() &&
(string) $this->content === (string) $message->content();
return $this->mediaType->toString() === $message->mediaType()->toString() &&
$this->content->toString() === $message->content()->toString();
}
}

0 comments on commit ab39d8b

Please sign in to comment.