Skip to content

Commit 1cdb89e

Browse files
authored
minor #40 Set-up GitHub workflow (sstok)
This PR was merged into the 1.0-dev branch. Discussion ---------- | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | | License | MIT Commits ------- 1d830d9 Set-up GitHub workflow
2 parents e414f3f + 1d830d9 commit 1cdb89e

File tree

14 files changed

+161
-97
lines changed

14 files changed

+161
-97
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ core.autocrlf=lf
99
.php_cs export-ignore
1010
.scrutinizer.yml export-ignore
1111
.travis.yml export-ignore
12+
Makefile export-ignore
1213
.github export-ignore
1314
phpunit.xml.dist export-ignore
1415
/tests export-ignore

.github/workflows/ci.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Full CI process
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
test:
12+
name: PHP ${{ matrix.php-versions }}
13+
runs-on: ubuntu-18.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- PHP_VERSION: '7.1'
19+
SYMFONY_REQUIRE: '^3.4'
20+
- PHP_VERSION: '7.2'
21+
SYMFONY_REQUIRE: '^4.4'
22+
- PHP_VERSION: '7.3'
23+
SYMFONY_REQUIRE: '^5.0'
24+
- PHP_VERSION: '7.4'
25+
26+
steps:
27+
# —— Setup Github actions 🐙 —————————————————————————————————————————————
28+
# https://github.com/actions/checkout (official)
29+
-
30+
name: Checkout
31+
uses: actions/checkout@v2
32+
33+
# https://github.com/shivammathur/setup-php (community)
34+
-
35+
name: Setup PHP, extensions and composer with shivammathur/setup-php
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.PHP_VERSION }}
39+
extensions: mbstring, ctype, iconv, bcmath, filter, json
40+
coverage: none
41+
env:
42+
update: true
43+
44+
# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
45+
-
46+
name: Install Composer dependencies
47+
env:
48+
SYMFONY_REQUIRE: ${{ matrix.SYMFONY_REQUIRE }}
49+
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
50+
SYMFONY_PHPUNIT_REMOVE: "symfony/yaml"
51+
SYMFONY_PHPUNIT_VERSION: '7.5.6'
52+
run: |
53+
git config --global author.name Sebastiaan Stok
54+
git config --global author.email [email protected]
55+
git config --global user.name Sebastiaan Stok
56+
git config --global user.email [email protected]
57+
58+
rm -f composer.lock
59+
composer global require symfony/flex
60+
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi
61+
62+
## —— Tests ✅ ———————————————————————————————————————————————————————————
63+
-
64+
name: Run Tests
65+
run: |
66+
make test
67+
lint:
68+
name: PHP-QA
69+
runs-on: ubuntu-latest
70+
strategy:
71+
fail-fast: false
72+
steps:
73+
-
74+
name: Checkout
75+
uses: actions/checkout@v2
76+
77+
# https://github.com/shivammathur/setup-php (community)
78+
-
79+
name: Setup PHP, extensions and composer with shivammathur/setup-php
80+
uses: shivammathur/setup-php@v2
81+
with:
82+
php-version: '7.4'
83+
extensions: mbstring, ctype, iconv, bcmath, filter, json
84+
coverage: none
85+
86+
# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
87+
-
88+
name: Install Composer dependencies
89+
run: |
90+
rm -f composer.lock
91+
composer global require symfony/flex
92+
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi
93+
94+
-
95+
name: Run PHP-QA
96+
run: |
97+
make cs-full

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/vendor/
55
/.php_cs.cache
66
symfony.lock
7+
.phpunit.result.cache

.travis.yml

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

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
QA_DOCKER_IMAGE=jakzal/phpqa:1.34.1-php7.4-alpine
2+
QA_DOCKER_COMMAND=docker run --init -t --rm --user "$(shell id -u):$(shell id -g)" --volume /tmp/tmp-phpqa-$(shell id -u):/tmp --volume "$(shell pwd):/project" --workdir /project ${QA_DOCKER_IMAGE}
3+
4+
dist: install cs-full phpstan test-full
5+
lint: install security-check cs-full phpstan
6+
7+
install:
8+
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --prefer-dist --ansi
9+
10+
test:
11+
./vendor/bin/simple-phpunit --verbose
12+
13+
# Linting tools
14+
security-check: ensure
15+
sh -c "${QA_DOCKER_COMMAND} security-checker security:check ./composer.lock"
16+
17+
phpstan: ensure
18+
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon"
19+
20+
cs: ensure
21+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"
22+
23+
cs-full: ensure
24+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff"
25+
26+
cs-full-check: ensure
27+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run"
28+
29+
ensure:
30+
mkdir -p ${HOME}/.composer /tmp/tmp-phpqa-$(shell id -u)
31+
32+
.PHONY: install test phpstan cs cs-full cs-full-check

composer.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
"symfony/validator": "^3.4.22 || ^4.0 || ^5.0"
2828
},
2929
"require-dev": {
30+
"guzzlehttp/psr7": "^1.4",
31+
"php-http/httplug": "^1.1",
32+
"phpspec/prophecy": "^1.10.3",
3033
"symfony/config": "^3.4.22 || ^4.0 || ^5.0",
3134
"symfony/console": "^3.4.22 || ^4.0 || ^5.0",
32-
"symfony/phpunit-bridge": "^3.4.22 || ^4.0 || ^5.0",
33-
"php-http/httplug": "^1.1",
34-
"guzzlehttp/psr7": "^1.4"
35+
"symfony/phpunit-bridge": "^4.4 || ^5.0"
3536
},
3637
"autoload": {
3738
"psr-4": {
@@ -42,10 +43,7 @@
4243
"autoload-dev": {
4344
"psr-4": {
4445
"Rollerworks\\Component\\PasswordStrength\\Tests\\": "tests/"
45-
},
46-
"files": [
47-
"tests/Symfony27Compat.php"
48-
]
46+
}
4947
},
5048
"extra": {
5149
"branch-alias": {

phpstan.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ includes:
22
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
33

44
parameters:
5-
autoload_files:
6-
- vendor/autoload.php
7-
- vendor/bin/.phpunit/phpunit-7.5.6-0/vendor/autoload.php # Pain is your friend.... (at least it works for now)
85
level: 5
96
paths:
107
- ./src
11-
- ./tests
128

139
ignoreErrors:
1410
#- '#__construct\(\) does not call parent constructor from .+#'

tests/Blacklist/SqliteProviderTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
16+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1617

1718
class SqliteProviderTest extends TestCase
1819
{
20+
use SetUpTearDownTrait;
21+
1922
/**
2023
* @var string
2124
*/
@@ -26,7 +29,7 @@ class SqliteProviderTest extends TestCase
2629
*/
2730
protected static $provider;
2831

29-
public static function setUpBeforeClass()
32+
public static function doSetUpBeforeClass()
3033
{
3134
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
3235
self::markTestSkipped('This test requires SQLite support in your environment');
@@ -40,7 +43,7 @@ public static function setUpBeforeClass()
4043
self::$provider = new SqliteProvider('sqlite:'.self::$dbFile);
4144
}
4245

43-
public static function tearDownAfterClass()
46+
public static function doTearDownAfterClass()
4447
{
4548
@unlink(self::$dbFile);
4649
}
@@ -84,7 +87,7 @@ public function testPurge()
8487
self::assertTrue(self::$provider->isBlacklisted('test'));
8588
}
8689

87-
protected function setUp()
90+
protected function doSetUp()
8891
{
8992
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
9093
$this->markTestSkipped('This test requires SQLite support in your environment');

tests/Command/BlacklistCommandTestCase.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
1616
use Rollerworks\Component\PasswordStrength\Tests\BlackListMockProviderTrait;
17+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1718

1819
abstract class BlacklistCommandTestCase extends TestCase
1920
{
2021
use BlackListMockProviderTrait;
22+
use SetUpTearDownTrait;
2123

2224
protected static $dbFile;
2325
protected static $storage;
@@ -27,7 +29,7 @@ abstract class BlacklistCommandTestCase extends TestCase
2729
*/
2830
protected static $blackListProvider;
2931

30-
public static function setUpBeforeClass()
32+
public static function doSetUpBeforeClass()
3133
{
3234
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
3335
self::markTestSkipped('This test requires SQLite support in your environment');
@@ -41,12 +43,12 @@ public static function setUpBeforeClass()
4143
self::$blackListProvider = new SqliteProvider('sqlite:'.self::$dbFile);
4244
}
4345

44-
public static function tearDownAfterClass()
46+
public static function doTearDownAfterClass()
4547
{
4648
@unlink(self::$dbFile);
4749
}
4850

49-
protected function setUp()
51+
protected function doSetUp()
5052
{
5153
self::$blackListProvider->purge();
5254
}

tests/P0wnedPassword/Request/ClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
use Psr\Log\NullLogger;
2020
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Client;
2121
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Result;
22+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
2223

2324
class ClientTest extends TestCase
2425
{
26+
use SetUpTearDownTrait;
27+
2528
/** @var HttpClient|MockObject */
2629
private $client;
2730

@@ -56,7 +59,7 @@ class ClientTest extends TestCase
5659
0C341F894BD4EE961AE874ACD3BC8157825:4
5760
';
5861

59-
public function setUp()
62+
public function doSetUp()
6063
{
6164
$this->client = $this->createMock(HttpClient::class);
6265
$this->checker = new Client($this->client, new NullLogger());

0 commit comments

Comments
 (0)