Skip to content

Commit 8415e76

Browse files
authored
Use GitHub Actions (#416)
* Use GitHub Actions * updates * phpcbf * use xdebug for coverage * update tests for php 7.4 * update method signatures * update setUp/tearDown method signatures * replace assertInternalType * replace assertContains * replace readAttribute usage * fix strpos assertions * update phpcs * exclude phpunit result cache * phpcbf * add laravel/framework to dev
1 parent 19fcbc5 commit 8415e76

32 files changed

+238
-86
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
* text=auto
22

3-
/tests export-ignore
3+
/.github export-ignore
44
/.gitattributes export-ignore
55
/.gitignore export-ignore
66
/.travis.yml export-ignore
77
/phpunit.xml export-ignore
8+
/tests export-ignore

.github/workflows/ci.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
fail-fast: true
13+
matrix:
14+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
15+
laravel: [ '5.5', '5.6', '5.7', '5.8', '6', '7', '8' ]
16+
exclude:
17+
- php: '7.2'
18+
laravel: '8'
19+
- php: '8.0'
20+
laravel: '5.5'
21+
- php: '8.0'
22+
laravel: '5.6'
23+
- php: '8.0'
24+
laravel: '5.7'
25+
- php: '8.0'
26+
laravel: '5.8'
27+
- php: '8.1'
28+
laravel: '5.5'
29+
- php: '8.1'
30+
laravel: '5.6'
31+
- php: '8.1'
32+
laravel: '5.7'
33+
- php: '8.1'
34+
laravel: '5.8'
35+
- php: '8.1'
36+
laravel: '6'
37+
- php: '8.1'
38+
laravel: '7'
39+
40+
name: PHP ${{ matrix.php }}; Laravel ${{ matrix.laravel }}
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v2
45+
46+
- name: Setup PHP
47+
uses: shivammathur/setup-php@v2
48+
with:
49+
php-version: ${{ matrix.php }}
50+
tools: composer:v2
51+
coverage: xdebug
52+
53+
- name: Setup Problem Matchers
54+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
55+
56+
- name: Select Laravel 5.5
57+
uses: nick-invision/retry@v1
58+
with:
59+
timeout_minutes: 5
60+
max_attempts: 5
61+
command: composer require "laravel/framework:5.5.*" "phpunit/phpunit:^6.5.14" --no-update --no-interaction
62+
if: "matrix.laravel == '5.5'"
63+
64+
- name: Select Laravel 5.6
65+
uses: nick-invision/retry@v1
66+
with:
67+
timeout_minutes: 5
68+
max_attempts: 5
69+
command: composer require "laravel/framework:5.6.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
70+
if: "matrix.laravel == '5.6'"
71+
72+
- name: Select Laravel 5.7
73+
uses: nick-invision/retry@v1
74+
with:
75+
timeout_minutes: 5
76+
max_attempts: 5
77+
command: composer require "laravel/framework:5.7.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
78+
if: "matrix.laravel == '5.7'"
79+
80+
- name: Select Laravel 5.8
81+
uses: nick-invision/retry@v1
82+
with:
83+
timeout_minutes: 5
84+
max_attempts: 5
85+
command: composer require "laravel/framework:5.8.*" "phpunit/phpunit:^7.5.20|^8.5.8" --no-update --no-interaction
86+
if: "matrix.laravel == '5.8'"
87+
88+
- name: Select Laravel 6
89+
uses: nick-invision/retry@v1
90+
with:
91+
timeout_minutes: 5
92+
max_attempts: 5
93+
command: composer require "laravel/framework:6.*" "phpunit/phpunit:^8.5.8|^9.3.7" --no-update --no-interaction
94+
if: "matrix.laravel == '6'"
95+
96+
- name: Select Laravel 7
97+
uses: nick-invision/retry@v1
98+
with:
99+
timeout_minutes: 5
100+
max_attempts: 5
101+
command: composer require "laravel/framework:7.*" "phpunit/phpunit:^8.5.8|^9.3.7" --no-update --no-interaction
102+
if: "matrix.laravel == '7'"
103+
104+
- name: Select Laravel 8
105+
uses: nick-invision/retry@v1
106+
with:
107+
timeout_minutes: 5
108+
max_attempts: 5
109+
command: composer require "laravel/framework:8.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
110+
if: "matrix.laravel == '8'"
111+
112+
- name: Install PHP Dependencies
113+
uses: nick-invision/retry@v1
114+
with:
115+
timeout_minutes: 5
116+
max_attempts: 5
117+
command: composer update --no-interaction --no-progress
118+
119+
- name: Execute tests
120+
run: ./vendor/bin/phpunit --coverage-clover clover.xml
121+
122+
- name: Execute code style checks
123+
run: ./vendor/bin/phpcs --standard=PSR2 -p --ignore=./tests/storage/* --report=full --report-checkstyle=build/logs/checkstyle.xml src/ tests/
124+
125+
- name: Check code coverage
126+
if: ${{ matrix.php == '8.1' }}
127+
uses: codecov/codecov-action@v2.1.0

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ vendor
2323
build/
2424

2525
#storage folder for twig compilation tests
26-
tests/storage
26+
tests/storage
27+
28+
# phpunit
29+
/.phpunit.result.cache

.travis.yml

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

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.2.5",
17+
"php": "^7.2.5 || ^8.0",
1818
"twig/twig": "~3.0",
19-
"illuminate/support": "^5.5|^6|^7|^8",
20-
"illuminate/view": "^5.5|^6|^7|^8"
19+
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0",
20+
"illuminate/view": "^5.5 || ^6.0 || ^7.0 || ^8.0"
2121
},
2222
"require-dev": {
2323
"ext-json": "*",
24-
"laravel/framework": "5.5.*",
25-
"mockery/mockery": "0.9.*",
26-
"phpunit/phpunit": "~6.0",
27-
"squizlabs/php_codesniffer": "~1.5",
28-
"satooshi/php-coveralls": "~0.6"
24+
"laravel/framework": "^5.5 || ^6.0 || ^7.0 || ^8.0",
25+
"mockery/mockery": "^1.3.1",
26+
"phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.7",
27+
"squizlabs/php_codesniffer": "^3.6"
2928
},
3029
"suggest": {
3130
"twig/extensions": "~1.0",

src/Extension/Laravel/Legacy/Facades.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ public function getShortcut($name)
160160
public function getAliasParts($name)
161161
{
162162
if (strpos($name, '_') !== false) {
163-
164163
$parts = explode('_', $name);
165164
$parts = array_filter($parts); // Remove empty elements
166165

@@ -234,7 +233,6 @@ public function getFunction($name)
234233

235234
// Does that alias exist
236235
if (array_key_exists($class, $this->aliases)) {
237-
238236
$class = $this->aliases[$class];
239237
$function = new TwigFunction($name, $class.'::'.$method);
240238

src/Node/GetAttrNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public function compile(Compiler $compiler): void
4242
$env = $compiler->getEnvironment();
4343

4444
// optimize array calls
45-
if (
46-
$this->getAttribute('optimizable')
45+
if ($this->getAttribute('optimizable')
4746
&& (!$env->isStrictVariables() || $this->getAttribute('ignore_strict_check'))
4847
&& !$this->getAttribute('is_defined_test')
4948
&& Template::ARRAY_CALL === $this->getAttribute('type')
@@ -129,7 +128,9 @@ public static function attribute(
129128
$sandboxed = false,
130129
int $lineno = -1
131130
) {
132-
if (Template::METHOD_CALL !== $type and (is_a($object, 'Illuminate\Database\Eloquent\Model') || is_a($object, 'Livewire\Component'))) {
131+
if (Template::METHOD_CALL !== $type
132+
&& (is_a($object, 'Illuminate\Database\Eloquent\Model') || is_a($object, 'Livewire\Component'))
133+
) {
133134
// We can't easily find out if an attribute actually exists, so return true
134135
if ($isDefinedTest) {
135136
return true;

tests/Bridge/LintTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99

1010
class LintTest extends Base
1111
{
12-
public function tearDown()
12+
public function tearDown(): void
1313
{
1414
m::close();
1515
}
1616

1717
/**
18-
* @expectedException InvalidArgumentException
18+
* @expectedException \InvalidArgumentException
1919
*/
2020
public function testUnknownFile()
2121
{
22+
$this->expectException(\InvalidArgumentException::class);
2223
$finder = m::mock('TwigBridge\Twig\Loader');
2324
$bridge = new Bridge($finder);
2425
$app = $this->getApplication();

tests/Command/Lint/ContentTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public function testInstance()
2222
*/
2323
public function testEmpty()
2424
{
25+
$this->expectException(\RuntimeException::class);
26+
2527
$command = new Lint;
2628
$app = $this->getApplication();
2729

tests/Command/Lint/FinderTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class FinderTest extends Base
1111
{
1212
public function testGet()
1313
{
14-
$this->assertInstanceOf('Symfony\Component\Finder\Finder', (new Lint)->getFinder([__DIR__]));
14+
$app = $this->getApplication();
15+
$command = new Lint;
16+
$command->setLaravel($app);
17+
$this->assertInstanceOf('Symfony\Component\Finder\Finder', $command->getFinder([__DIR__]));
1518
}
1619

1720
public function testSet()
@@ -23,7 +26,9 @@ public function testSet()
2326
$finder->shouldReceive('in')->andReturn($finder);
2427
$finder->shouldReceive('name')->andReturn($data);
2528

29+
$app = $this->getApplication();
2630
$command = new Lint;
31+
$command->setLaravel($app);
2732
$command->setFinder($finder);
2833
$command->setFinder($finder);
2934

0 commit comments

Comments
 (0)