Skip to content

Commit

Permalink
Use github actions for PHPUnit (#170)
Browse files Browse the repository at this point in the history
* Use github actions

* Use constant PHP_EOL

* minor

* Push on master

* Push on master

* Fixed branch alias
  • Loading branch information
Nyholm committed Feb 10, 2021
1 parent e3f55e4 commit a36fb36
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 69 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
on: [push, pull_request]
on:
pull_request: ~
push:
branches:
- "master"

name: Roave
jobs:
roave_bc_check:
Expand Down
31 changes: 11 additions & 20 deletions .github/workflows/branch-alias.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,14 @@ jobs:
composer config extra.branch-alias.dev-main ${{ steps.find_alias.outputs.alias }}-dev
- name: Commit & push the new files
run: |
echo "::group::git status"
git status
echo "::endgroup::"
git add -N .
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then
echo "No changes found. Exiting."
exit 0;
fi
git config --local user.email "noreply@github.com"
git config --local user.name "GitHub"
echo "::group::git push"
git add .
git commit -m "Update branch alias"
git push
echo "::endgroup::"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
base: main
branch: branch-alias-update
author: GitHub <noreply@github.com>
committer: GitHub <noreply@github.com>
commit-message: Updating branch alias to ${{ steps.find_alias.outputs.alias }}
title: Update branch alias
body: |
Since we just tagged a new version, we need to update composer.json branch alias.
7 changes: 6 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
on: [push, pull_request]
on:
pull_request: ~
push:
branches:
- "master"

name: Static analysis
jobs:
phpstan:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
on:
pull_request: ~
push:
branches:
- "master"

name: Tests

jobs:
phpunit:
name: PHPUnit with PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }}

strategy:
matrix:
operating-system:
- 'ubuntu-latest'
php-version:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
include:
- operating-system: 'windows-latest'
php-version: '7.4'

runs-on: ${{ matrix.operating-system }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Download dependencies
run: composer update --no-interaction --no-progress --optimize-autoloader

- name: Run PHPUnit
run: ./vendor/bin/phpunit

phpunit-lowest:
name: PHPUnit lowest dependencies
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: 7.4

- name: Download dependencies
run: composer update --no-interaction --no-progress --optimize-autoloader --prefer-stable --prefer-lowest

- name: Run PHPUnit
run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Upload coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.xml
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.4-dev"
}
}
}
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit tests">
<directory>tests/</directory>
Expand Down
2 changes: 1 addition & 1 deletion tests/UploadedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function testGetStream()
$upload = new UploadedFile(__DIR__.'/Resources/foo.txt', 0, UPLOAD_ERR_OK);
$stream = $upload->getStream();
$this->assertInstanceOf(StreamInterface::class, $stream);
$this->assertEquals("Foobar\n", $stream->__toString());
$this->assertEquals('Foobar'.PHP_EOL, $stream->__toString());
}

public function testSuccessful()
Expand Down

0 comments on commit a36fb36

Please sign in to comment.