Skip to content

Commit

Permalink
Added quickstart badges to Readme.
Browse files Browse the repository at this point in the history
Changed ImportSpecification -> Import in quick start guides.
Changed PHPUnit tests to execute in random instead of deterministic order.
Fixed old reference to AsyncImportSpecification in Readme.
  • Loading branch information
Bilge committed Dec 8, 2022
1 parent 934e199 commit 5898b4c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/Quickstart Symfony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ jobs:
ScriptFUSION\Porter\Porter:
arguments:
- '@providers'
providers:
class: Symfony\Component\DependencyInjection\ServiceLocator
arguments:
-
- '@ScriptFUSION\Porter\Provider\Steam\SteamProvider'
ScriptFUSION\Porter\Provider\Steam\SteamProvider: ~
.
Expand All @@ -65,25 +65,25 @@ jobs:
cat <<'.' | >src/Controller/AppListAction.php sed 's/ *//'
<?php
declare(strict_types=1);
namespace App\Controller;
use ScriptFUSION\Porter\Import\Import;
use ScriptFUSION\Porter\Porter;
use ScriptFUSION\Porter\Provider\Steam\Resource\GetAppList;
use ScriptFUSION\Porter\Specification\ImportSpecification;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Routing\Annotation\Route;
final class AppListAction extends AbstractController
{
#[Route('/')]
public function __invoke(Porter $porter): Response
{
return new StreamedResponse(
function () use ($porter): void {
foreach ($porter->import(new ImportSpecification(new GetAppList())) as $app) {
foreach ($porter->import(new Import(new GetAppList())) as $app) {
echo "$app[appid]\n";
}
},
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/Quickstart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
- name: Initialize Composer project
run: composer init --name foo/bar

- name: Configure minimum stability for Amp v3.
run: |
composer config minimum-stability beta
composer config prefer-stable true
- name: Require ECB
run: composer require provider/european-central-bank

Expand All @@ -45,26 +50,26 @@ jobs:
<?php
use Joomla\DI\Container;
use ScriptFUSION\Porter\Import\Import;
use ScriptFUSION\Porter\Porter;
use ScriptFUSION\Porter\Provider\EuropeanCentralBank\Provider\EuropeanCentralBankProvider;
use ScriptFUSION\Porter\Provider\EuropeanCentralBank\Provider\Resource\DailyForexRates;
use ScriptFUSION\Porter\Specification\ImportSpecification;
require 'vendor/autoload.php';
$container = new Container;
$container->set(EuropeanCentralBankProvider::class, new EuropeanCentralBankProvider);
$porter = new Porter($container);
$rates = $porter->import(new ImportSpecification(new DailyForexRates));
$rates = $porter->import(new Import(new DailyForexRates));
foreach ($rates as $rate) {
echo "$rate[currency]: $rate[rate]\n";
}
.
- name: Test output contains USD
run: "grep --perl-regexp '^USD: [\\d.]+$' out"
run: 'grep --perl-regexp ''^USD: [\d.]+$'' out'

- name: Test output contains between 30-40 lines
run: |
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Porter <img src="https://github.com/ScriptFUSION/Porter/blob/master/docs/images/porter%20222x.png?raw=true" align="right">
======

[![Latest version][Version image]][Releases]
[![Total downloads][Downloads image]][Downloads]
[![Build status][Build image]][Build]
[![Mutation score][MSI image]][MSI report]
[![Test coverage][Coverage image]][Coverage]
[![Version image]][Releases]
[![Downloads image]][Downloads]
[![Build image]][Build]
[![Quickstart image]][Quickstart build]
[![Quickstart Symfony image]][Quickstart Symfony build]
[![Coverage image]][Coverage]
[![Mutation score image][MSI image]][MSI report]

### Durable and concurrent data imports for consuming data at scale and publishing testable SDKs
### Durable and asynchronous data imports for consuming data at scale and publishing testable SDKs

Porter is the all-purpose PHP data importer. She fetches data from APIs, web scraping or anywhere and serves it as an iterable [record collection](#record-collections), encouraging processing one record at a time instead of loading full data sets into memory. [Durability](#durability) features provide automatic, transparent recovery from intermittent network errors by default.

Expand Down Expand Up @@ -214,7 +216,7 @@ Synchronously, we seldom trip protection measures even for high volume imports,
A `DualThrottle` can be assigned by modifying the import specification as follows.
```php
(new AsyncImportSpecification)->setThrottle(new DualThrottle)
(new Import)->setThrottle(new DualThrottle)
```
#### ThrottledConnector
Expand Down Expand Up @@ -534,15 +536,19 @@ Porter is supported by [JetBrains for Open Source][] products.
[Downloads image]: https://poser.pugx.org/scriptfusion/porter/downloads "Total downloads"
[Build]: https://github.com/ScriptFUSION/Porter/actions/workflows/Tests.yaml
[Build image]: https://github.com/ScriptFUSION/Porter/actions/workflows/Tests.yaml/badge.svg "Build status"
[MSI image]: https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FScriptFUSION%2FPorter%2Fmaster
[Quickstart build]: https://github.com/ScriptFUSION/Porter/actions/workflows/Quickstart.yaml
[Quickstart image]: https://github.com/ScriptFUSION/Porter/actions/workflows/Quickstart.yaml/badge.svg "Quick start build status"
[Quickstart Symfony build]: https://github.com/ScriptFUSION/Porter/actions/workflows/Quickstart%20Symfony.yaml
[Quickstart Symfony image]: https://github.com/ScriptFUSION/Porter/actions/workflows/Quickstart%20Symfony.yaml/badge.svg "Symfony quick start build status"
[MSI report]: https://dashboard.stryker-mutator.io/reports/github.com/ScriptFUSION/Porter/master
[MSI image]: https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FScriptFUSION%2FPorter%2Fmaster "Mutation score"
[Coverage]: https://codecov.io/gh/ScriptFUSION/Porter
[Coverage image]: https://codecov.io/gh/ScriptFUSION/Porter/branch/master/graphs/badge.svg "Test coverage"

[Issues]: https://github.com/ScriptFUSION/Porter/issues
[PRs]: https://github.com/ScriptFUSION/Porter/pulls
[Quickstart]: https://github.com/ScriptFUSION/Porter/tree/master/docs/Quickstart.md
[Symfony quickstart]: https://github.com/ScriptFUSION/Porter/tree/master/docs/Quickstart%20Symfony.md
[Symfony quickstart]: https://github.com/ScriptFUSION/Porter/tree/master/docs/Quickstart%20Symfony.md
[Provider]: https://github.com/provider
[Porter transformers]: https://github.com/Porter-transformers
[Porter connectors]: https://github.com/Porter-connectors
Expand Down
8 changes: 4 additions & 4 deletions docs/Quickstart Symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ Refreshing our browser now should recompile the Symfony DI container and show us
Let's replace the previous `StreamedResponse` closure with a new implementation that uses Porter to import data from the `GetAppList` resource (a resource belonging to `SteamProvider`).

```diff
+use ScriptFUSION\Porter\Import\Import;
use ScriptFUSION\Porter\Porter;
+use ScriptFUSION\Porter\Provider\Steam\Resource\GetAppList;
+use ScriptFUSION\Porter\Specification\ImportSpecification;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- fn () => print 'Hello, Porter!',
+ function () use ($porter): void {
+ foreach ($porter->import(new ImportSpecification(new GetAppList())) as $app) {
+ foreach ($porter->import(new Import(new GetAppList())) as $app) {
+ echo "$app[appid]\n";
+ }
+ },
Expand All @@ -158,9 +158,9 @@ declare(strict_types=1);
namespace App\Controller;
use ScriptFUSION\Porter\Import\Import;
use ScriptFUSION\Porter\Porter;
use ScriptFUSION\Porter\Provider\Steam\Resource\GetAppList;
use ScriptFUSION\Porter\Specification\ImportSpecification;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
Expand All @@ -173,7 +173,7 @@ final class AppListAction extends AbstractController
{
return new StreamedResponse(
function () use ($porter): void {
foreach ($porter->import(new ImportSpecification(new GetAppList())) as $app) {
foreach ($porter->import(new Import(new GetAppList())) as $app) {
echo "$app[appid]\n";
}
},
Expand Down
7 changes: 7 additions & 0 deletions docs/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ composer init

For this demo we'll use the [European Central Bank][ECB provider] (ECB) provider by including it in our `composer.json` with the following command.

>Note: The ECB provider requires [Amp v3][], which is currently in beta, so we need to allow beta dependencies temporarily. This can be enabled with the following commands.
> ```sh
> composer config minimum-stability beta
> composer config prefer-stable true
> ```
```sh
composer require provider/european-central-bank
```
Expand Down Expand Up @@ -77,3 +83,4 @@ This just scratches the surface of Porter without going into any details. Explor
[PSR-11 search]: https://packagist.org/explore/?type=library&tags=psr-11
[Joomla DI]: https://github.com/joomla-framework/di
[Symfony quickstart guide]: Quickstart%20Symfony.md
[Amp v3]: https://v3.amphp.org
1 change: 1 addition & 0 deletions test/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<phpunit
beStrictAboutOutputDuringTests="true"
executionOrder="random"
>
<testsuite name="all">
<directory>.</directory>
Expand Down

0 comments on commit 5898b4c

Please sign in to comment.