Skip to content

Commit a36fb36

Browse files
authored
Use github actions for PHPUnit (#170)
* Use github actions * Use constant PHP_EOL * minor * Push on master * Push on master * Fixed branch alias
1 parent e3f55e4 commit a36fb36

8 files changed

+107
-69
lines changed

.github/workflows/bc.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
on: [push, pull_request]
1+
on:
2+
pull_request: ~
3+
push:
4+
branches:
5+
- "master"
6+
27
name: Roave
38
jobs:
49
roave_bc_check:

.github/workflows/branch-alias.yml

+11-20
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,14 @@ jobs:
5353
5454
composer config extra.branch-alias.dev-main ${{ steps.find_alias.outputs.alias }}-dev
5555
56-
- name: Commit & push the new files
57-
run: |
58-
echo "::group::git status"
59-
git status
60-
echo "::endgroup::"
61-
62-
git add -N .
63-
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then
64-
echo "No changes found. Exiting."
65-
exit 0;
66-
fi
67-
68-
git config --local user.email "[email protected]"
69-
git config --local user.name "GitHub"
70-
71-
echo "::group::git push"
72-
git add .
73-
git commit -m "Update branch alias"
74-
git push
75-
echo "::endgroup::"
56+
- name: Create Pull Request
57+
uses: peter-evans/create-pull-request@v3
58+
with:
59+
base: main
60+
branch: branch-alias-update
61+
author: GitHub <[email protected]>
62+
committer: GitHub <[email protected]>
63+
commit-message: Updating branch alias to ${{ steps.find_alias.outputs.alias }}
64+
title: Update branch alias
65+
body: |
66+
Since we just tagged a new version, we need to update composer.json branch alias.

.github/workflows/static.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
on: [push, pull_request]
1+
on:
2+
pull_request: ~
3+
push:
4+
branches:
5+
- "master"
6+
27
name: Static analysis
38
jobs:
49
phpstan:

.github/workflows/tests.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
on:
2+
pull_request: ~
3+
push:
4+
branches:
5+
- "master"
6+
7+
name: Tests
8+
9+
jobs:
10+
phpunit:
11+
name: PHPUnit with PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
operating-system:
16+
- 'ubuntu-latest'
17+
php-version:
18+
- '7.1'
19+
- '7.2'
20+
- '7.3'
21+
- '7.4'
22+
- '8.0'
23+
include:
24+
- operating-system: 'windows-latest'
25+
php-version: '7.4'
26+
27+
runs-on: ${{ matrix.operating-system }}
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v2
32+
33+
- name: Install PHP with extensions
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
coverage: none
37+
php-version: ${{ matrix.php-version }}
38+
39+
- name: Get composer cache directory
40+
id: composer-cache
41+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
42+
43+
- name: Cache dependencies
44+
uses: actions/cache@v2
45+
with:
46+
path: ${{ steps.composer-cache.outputs.dir }}
47+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
48+
restore-keys: |
49+
composer-${{ runner.os }}-${{ matrix.php-version }}-
50+
composer-${{ runner.os }}-
51+
composer-
52+
53+
- name: Download dependencies
54+
run: composer update --no-interaction --no-progress --optimize-autoloader
55+
56+
- name: Run PHPUnit
57+
run: ./vendor/bin/phpunit
58+
59+
phpunit-lowest:
60+
name: PHPUnit lowest dependencies
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v2
66+
67+
- name: Install PHP with extensions
68+
uses: shivammathur/setup-php@v2
69+
with:
70+
coverage: none
71+
php-version: 7.4
72+
73+
- name: Download dependencies
74+
run: composer update --no-interaction --no-progress --optimize-autoloader --prefer-stable --prefer-lowest
75+
76+
- name: Run PHPUnit
77+
run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
78+
79+
- name: Upload coverage
80+
run: |
81+
wget https://scrutinizer-ci.com/ocular.phar
82+
php ocular.phar code-coverage:upload --format=php-clover coverage.xml

.travis.yml

-40
This file was deleted.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"extra": {
4444
"branch-alias": {
45-
"dev-master": "1.0-dev"
45+
"dev-master": "1.4-dev"
4646
}
4747
}
4848
}

phpunit.xml.dist

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
83
<testsuites>
94
<testsuite name="Unit tests">
105
<directory>tests/</directory>

tests/UploadedFileTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function testGetStream()
134134
$upload = new UploadedFile(__DIR__.'/Resources/foo.txt', 0, UPLOAD_ERR_OK);
135135
$stream = $upload->getStream();
136136
$this->assertInstanceOf(StreamInterface::class, $stream);
137-
$this->assertEquals("Foobar\n", $stream->__toString());
137+
$this->assertEquals('Foobar'.PHP_EOL, $stream->__toString());
138138
}
139139

140140
public function testSuccessful()

0 commit comments

Comments
 (0)