Skip to content

Commit fe78f93

Browse files
committed
build: use github actions
1 parent 2cef62b commit fe78f93

6 files changed

Lines changed: 115 additions & 58 deletions

File tree

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Continuous Integration
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
tests:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
- operating-system: 'ubuntu-latest'
14+
php-version: '7.3'
15+
job-description: 'Ubuntu; PHP 7.3; latest-deps'
16+
17+
- operating-system: 'ubuntu-latest'
18+
php-version: '7.3'
19+
composer-flags: '--prefer-lowest'
20+
job-description: 'Ubuntu; PHP 7.3; lowest-deps'
21+
22+
- operating-system: 'ubuntu-latest'
23+
php-version: '7.4'
24+
job-description: 'Ubuntu; PHP 7.4; latest-deps'
25+
26+
- operating-system: 'ubuntu-latest'
27+
php-version: '7.4'
28+
composer-flags: '--prefer-lowest'
29+
job-description: 'Ubuntu; PHP 7.4; lowest-deps'
30+
31+
- operating-system: 'ubuntu-latest'
32+
php-version: '8.0'
33+
job-description: 'Ubuntu; PHP 8.0; latest-deps'
34+
35+
- operating-system: 'ubuntu-latest'
36+
php-version: '8.0'
37+
composer-flags: '--prefer-lowest'
38+
job-description: 'Ubuntu; PHP 8.0; lowest-deps'
39+
40+
- operating-system: 'windows-latest'
41+
php-version: '8.0'
42+
job-description: 'Windows; PHP 8.0; latest-deps'
43+
44+
- operating-system: 'macos-latest'
45+
php-version: '8.0'
46+
job-description: 'MacOS; PHP 8.0; latest-deps'
47+
48+
49+
name: ${{ matrix.job-description }}
50+
51+
runs-on: ${{ matrix.operating-system }}
52+
53+
steps:
54+
- name: Set git to use LF
55+
run: |
56+
git config --global core.autocrlf false
57+
git config --global core.eol lf
58+
59+
- name: Checkout code
60+
uses: actions/checkout@v2
61+
62+
- name: Setup PHP
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: ${{ matrix.php-version }}
66+
67+
- name: Get Composer cache directory
68+
id: composer-cache
69+
run: echo "::set-output name=dir::$(composer config cache-dir)"
70+
71+
- name: Cache dependencies
72+
uses: actions/cache@v2
73+
with:
74+
path: ${{ steps.composer-cache.outputs.dir }}
75+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
76+
restore-keys: |
77+
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
78+
composer-${{ runner.os }}-${{ matrix.php-version }}-
79+
composer-${{ runner.os }}-
80+
composer-
81+
82+
- name: Install dependencies
83+
uses: nick-invision/retry@v2
84+
with:
85+
timeout_minutes: 5
86+
max_attempts: 5
87+
retry_wait_seconds: 30
88+
command: |
89+
composer update --optimize-autoloader --no-interaction --ansi --no-progress --prefer-dist ${{ matrix.composer-flags }}
90+
composer info -D
91+
92+
- name: Tests
93+
run: vendor/bin/phpunit --configuration phpunit.xml.dist

.php_cs.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ $finder = PhpCsFixer\Finder::create()
66

77
return PhpCsFixer\Config::create()
88
->setRules([
9-
'@PSR2' => true,
10-
'@PhpCsFixer' => true,
9+
'@Symfony' => true,
1110
'@PHP73Migration' => true,
1211
'array_syntax' => ['syntax' => 'short'],
1312
'combine_consecutive_issets' => true,

.travis.yml

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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"require-dev": {
1111
"phpunit/phpunit": "^9.5",
12-
"friendsofphp/php-cs-fixer": "^2.17"
12+
"friendsofphp/php-cs-fixer": "^2.18"
1313
},
1414
"authors": [
1515
{

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.5/phpunit.xsd"
5+
beStrictAboutTestsThatDoNotTestAnything="false"
56
colors="true"
67
bootstrap="vendor/autoload.php"
78
>

tests/PhpTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,57 +21,57 @@ protected function setUp(): void
2121
$this->syntax = new Php();
2222
}
2323

24-
public function testCheck()
24+
public function testCheck(): void
2525
{
2626
$result = $this->syntax->check('<?php echo 1; ?>');
2727

2828
self::assertEquals(['validity' => true, 'errors' => null], $result);
2929
}
3030

31-
public function testCheckFile()
31+
public function testCheckFile(): void
3232
{
3333
$result = $this->syntax->checkFile(__DIR__.'/fixtures/correct.php');
3434

3535
self::assertEquals(['validity' => true, 'errors' => null], $result);
3636
}
3737

38-
public function testCheckFail()
38+
public function testCheckFail(): void
3939
{
4040
$result = $this->syntax->check('<?php echo "; ?>');
4141

42-
self::assertTrue(\is_array($result));
42+
self::assertIsArray($result);
4343

4444
self::assertFalse($result['validity']);
45-
self::assertTrue(\is_array($result['errors']));
45+
self::assertIsArray($result['errors']);
4646
self::assertCount(1, $result['errors']);
4747

48-
self::assertTrue(\is_null($result['errors'][0]['file']));
49-
self::assertTrue(\is_int($result['errors'][0]['code']));
50-
self::assertTrue(\is_int($result['errors'][0]['line']));
51-
self::assertTrue(\is_string($result['errors'][0]['type']));
52-
self::assertTrue(\is_string($result['errors'][0]['message']));
48+
self::assertNull($result['errors'][0]['file']);
49+
self::assertIsInt($result['errors'][0]['code']);
50+
self::assertIsInt($result['errors'][0]['line']);
51+
self::assertIsString($result['errors'][0]['type']);
52+
self::assertIsString($result['errors'][0]['message']);
5353
}
5454

55-
public function testCheckFileFail()
55+
public function testCheckFileFail(): void
5656
{
5757
$result = $this->syntax->checkFile(__DIR__.'/fixtures/fail.php');
5858

59-
self::assertTrue(\is_array($result));
59+
self::assertIsArray($result);
6060

6161
self::assertFalse($result['validity']);
62-
self::assertTrue(\is_array($result['errors']));
62+
self::assertIsArray($result['errors']);
6363
self::assertCount(1, $result['errors']);
6464

65-
self::assertTrue(\is_string($result['errors'][0]['file']));
66-
self::assertTrue(\is_int($result['errors'][0]['code']));
67-
self::assertTrue(\is_int($result['errors'][0]['line']));
68-
self::assertTrue(\is_string($result['errors'][0]['type']));
69-
self::assertTrue(\is_string($result['errors'][0]['message']));
65+
self::assertIsString($result['errors'][0]['file']);
66+
self::assertIsInt($result['errors'][0]['code']);
67+
self::assertIsInt($result['errors'][0]['line']);
68+
self::assertIsString($result['errors'][0]['type']);
69+
self::assertIsString($result['errors'][0]['message']);
7070

7171
self::assertEquals(__DIR__.'/fixtures/fail.php', $result['errors'][0]['file']);
7272
}
7373

74-
public function testFormatOutputHelper()
74+
public function testFormatOutputHelper(): void
7575
{
7676
$result = Php::formatOutputHelper(
7777
'<?php echo ";'."\n".'echo 1; ?>',

0 commit comments

Comments
 (0)