Skip to content

Commit 6e1d549

Browse files
committed
Migrate to GitHub Actions, use test container
1 parent 5844cd0 commit 6e1d549

15 files changed

Lines changed: 115 additions & 57 deletions

.github/workflows/test.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: flysystem-bundle
2+
3+
on: pull_request
4+
5+
jobs:
6+
coding-style:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- uses: shivammathur/setup-php@v2
11+
with:
12+
php-version: '7.4'
13+
- name: php-cs-fixer
14+
run: |
15+
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -q
16+
php php-cs-fixer.phar fix --dry-run --diff
17+
18+
tests-php-7-1-symfony-4-2:
19+
runs-on: ubuntu-latest
20+
env:
21+
SYMFONY_VERSION: 4.2.*
22+
steps:
23+
- uses: actions/checkout@master
24+
- uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '7.1'
27+
- name: PHPUnit
28+
run: |
29+
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
30+
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
31+
composer remove --no-update --dev async-aws/flysystem-s3
32+
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
33+
php vendor/bin/phpunit
34+
35+
tests-php-7-4-symfony-5-0:
36+
runs-on: ubuntu-latest
37+
env:
38+
SYMFONY_VERSION: 5.0.*
39+
steps:
40+
- uses: actions/checkout@master
41+
- uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: '7.4'
44+
- name: PHPUnit
45+
run: |
46+
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
47+
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
48+
composer update --prefer-dist --no-interaction --no-ansi --no-progress
49+
php vendor/bin/phpunit
50+
51+
tests-php-7-4-symfony-5-2:
52+
runs-on: ubuntu-latest
53+
env:
54+
SYMFONY_VERSION: 5.2.*
55+
steps:
56+
- uses: actions/checkout@master
57+
- uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: '7.4'
60+
- name: PHPUnit
61+
run: |
62+
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
63+
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
64+
composer update --prefer-dist --no-interaction --no-ansi --no-progress
65+
php vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
composer.lock
33
.php_cs.cache
4+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"symfony/options-resolver": "^4.2|^5.0"
2929
},
3030
"require-dev": {
31-
"async-aws/flysystem-s3": "^0.3",
31+
"async-aws/flysystem-s3": "^0.4",
3232
"league/flysystem-aws-s3-v3": "^1.0.22",
3333
"league/flysystem-azure-blob-storage": "^0.1.5",
3434
"league/flysystem-cached-adapter": "^1.0.9",

tests/Adapter/AdapterDefinitionFactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Tests\League\FlysystemBundle\Adapter;
1313

14+
use AsyncAws\Flysystem\S3\S3FilesystemV1;
1415
use League\FlysystemBundle\Adapter\AdapterDefinitionFactory;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\DependencyInjection\Definition;
@@ -23,9 +24,10 @@ public function provideConfigOptions()
2324
$config = Yaml::parseFile(__DIR__.'/options.yaml');
2425

2526
foreach ($config as $fs) {
26-
if (isset($fs['_php_version']) && version_compare(PHP_VERSION, $fs['_php_version'], '<')) {
27+
if ('asyncaws' === $fs['adapter'] && !class_exists(S3FilesystemV1::class)) {
2728
continue;
2829
}
30+
2931
yield $fs['adapter'] => [$fs['adapter'], $fs['options'] ?? []];
3032
}
3133
}

tests/Adapter/Builder/AsyncAwsAdapterDefinitionBuilderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,19 @@ public function provideValidOptions()
5353
*/
5454
public function testCreateDefinition($options)
5555
{
56+
if (!class_exists(S3FilesystemV1::class)) {
57+
$this->markTestSkipped();
58+
}
59+
5660
$this->assertSame(S3FilesystemV1::class, $this->createBuilder()->createDefinition($options)->getClass());
5761
}
5862

5963
public function testOptionsBehavior()
6064
{
65+
if (!class_exists(S3FilesystemV1::class)) {
66+
$this->markTestSkipped();
67+
}
68+
6169
$definition = $this->createBuilder()->createDefinition([
6270
'client' => 'my_client',
6371
'bucket' => 'bucket',

tests/Adapter/Builder/WebdavAdapterDefinitionBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function provideValidOptions()
2929
'client' => 'my_client',
3030
]];
3131

32-
yield 'minimal' => [[
32+
yield 'minimal-stream' => [[
3333
'client' => 'my_client',
3434
'use_stream_copy' => false,
3535
]];

tests/Adapter/options.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
fs_async_aws:
2-
_php_version: '7.2.5'
32
adapter: 'asyncaws'
43
options:
54
client: 'aws_client_service'
@@ -61,11 +60,11 @@ fs_local:
6160
skip_links: false
6261
permissions:
6362
file:
64-
public: 0744
65-
private: 0700
63+
public: '0744'
64+
private: '0700'
6665
dir:
67-
public: 0755
68-
private: 0700
66+
public: '0755'
67+
private: '0700'
6968

7069
fs_memory:
7170
adapter: 'memory'

tests/DependencyInjection/FlysystemExtensionTest.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
use Sabre\DAV\Client as WebDAVClient;
2323
use Spatie\Dropbox\Client as DropboxClient;
2424
use Symfony\Component\Dotenv\Dotenv;
25+
use Symfony\Component\HttpKernel\Kernel;
2526
use Tests\League\FlysystemBundle\Kernel\FlysystemAppKernel;
2627

2728
class FlysystemExtensionTest extends TestCase
2829
{
2930
public function provideFilesystems()
3031
{
3132
$fsNames = [
32-
'fs_asyncaws',
3333
'fs_aws',
3434
'fs_azure',
3535
'fs_cache',
@@ -57,7 +57,9 @@ public function provideFilesystems()
5757
public function testFileystems(string $fsName)
5858
{
5959
$kernel = $this->createFysystemKernel();
60-
$fs = $kernel->getContainer()->get('flysystem.test.'.$fsName);
60+
$container = $kernel->getContainer()->get('test.service_container');
61+
62+
$fs = $container->get('flysystem.test.'.$fsName);
6163

6264
$this->assertInstanceOf(FilesystemInterface::class, $fs, 'Filesystem "'.$fsName.'" should be an instance of FilesystemInterface');
6365
$this->assertEquals('plugin', $fs->pluginTest());
@@ -69,12 +71,13 @@ public function testFileystems(string $fsName)
6971
public function testTaggedCollection(string $fsName)
7072
{
7173
$kernel = $this->createFysystemKernel();
74+
$container = $kernel->getContainer()->get('test.service_container');
7275

73-
if (!$kernel->getContainer()->has('storages_tagged_collection')) {
76+
if (!$container->has('storages_tagged_collection')) {
7477
$this->markTestSkipped('Symfony 4.3+ is required to use indexed tagged service collections');
7578
}
7679

77-
$storages = iterator_to_array($kernel->getContainer()->get('storages_tagged_collection')->locator);
80+
$storages = iterator_to_array($container->get('storages_tagged_collection')->locator);
7881

7982
$this->assertInstanceOf(FilesystemInterface::class, $storages[$fsName]);
8083
$this->assertEquals('plugin', $storages[$fsName]->pluginTest());
@@ -92,9 +95,11 @@ private function createFysystemKernel()
9295
$kernel->setAdapterClients($this->getClientMocks());
9396
$kernel->boot();
9497

95-
$container = $kernel->getContainer();
98+
$container = $kernel->getContainer()->get('test.service_container');
9699
foreach ($this->getClientMocks() as $service => $mock) {
97-
$container->set($service, $mock);
100+
if ($mock) {
101+
$container->set($service, $mock);
102+
}
98103
}
99104

100105
return $kernel;
@@ -105,9 +110,14 @@ private function getClientMocks()
105110
$gcloud = $this->createMock(StorageClient::class);
106111
$gcloud->method('bucket')->willReturn($this->createMock(Bucket::class));
107112

113+
$asyncAws = null;
114+
if (Kernel::VERSION_ID > 50200 && class_exists(AsyncS3Client::class)) {
115+
$asyncAws = $this->createMock(AsyncS3Client::class);
116+
}
117+
108118
return [
109119
'aws_client_service' => $this->createMock(S3Client::class),
110-
'asyncaws_client_service' => $this->createMock(AsyncS3Client::class),
120+
'asyncaws_client_service' => $asyncAws,
111121
'azure_client_service' => $this->createMock(BlobRestProxy::class),
112122
'dropbox_client_service' => $this->createMock(DropboxClient::class),
113123
'gcloud_client_service' => $gcloud,

tests/Kernel/FrameworkAppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function registerBundles()
2929
public function registerContainerConfiguration(LoaderInterface $loader)
3030
{
3131
$loader->load(function (ContainerBuilder $container) {
32-
$container->loadFromExtension('framework', ['secret' => '$ecret']);
32+
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true]);
3333
$container->loadFromExtension('flysystem', [
3434
'storages' => [
3535
'uploads.storage' => [

0 commit comments

Comments
 (0)