Skip to content

Commit e675e40

Browse files
Add psalm and use github actions
1 parent 0ac84bc commit e675e40

File tree

9 files changed

+201
-44
lines changed

9 files changed

+201
-44
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
/phpstan.src.neon.dist export-ignore
99
/phpstan.tests.neon.dist export-ignore
1010
/phpunit.xml.dist export-ignore
11+
/psalm.xml export-ignore
1112
/README.md export-ignore
1213
/vendor-bin export-ignore

.github/CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We accept contributions via pull requests on Github. Please review these guideli
66

77
## Guidelines
88

9-
* Please follow the [PSR-2 Coding Style Guide](https://www.php-fig.org/psr/psr-2/)..
9+
* Please follow the [PSR-2 Coding Style Guide](https://www.php-fig.org/psr/psr-2/).
1010
* Ensure that the current tests pass, and if you've added something new, add the tests where relevant.
1111
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
1212
* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
@@ -18,13 +18,13 @@ We accept contributions via pull requests on Github. Please review these guideli
1818
First, install the dependencies using [Composer](https://getcomposer.org/):
1919

2020
```bash
21-
$ composer install
21+
$ make install
2222
```
2323

2424
Then run [PHPUnit](https://phpunit.de/):
2525

2626
```bash
27-
$ vendor/bin/phpunit
27+
$ make test
2828
```
2929

30-
The tests will be automatically run by [Travis CI](https://travis-ci.org/) against pull requests.
30+
These will also be automatically run by [Travis CI](https://travis-ci.org/) and [GitHub Actions](https://github.com/features/actions) against pull requests.

.github/workflows/static.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
phpstan_src:
9+
name: PHPStan Source
10+
runs-on: ubuntu-20.04
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: 7.4
20+
tools: composer:v2
21+
coverage: none
22+
23+
- name: Install Dependencies
24+
uses: nick-invision/retry@v1
25+
with:
26+
timeout_minutes: 5
27+
max_attempts: 5
28+
command: composer update --no-interaction --no-progress
29+
30+
- name: Install PHPStan
31+
uses: nick-invision/retry@v1
32+
with:
33+
timeout_minutes: 5
34+
max_attempts: 5
35+
command: composer bin phpstan update --no-interaction --no-progress
36+
37+
- name: Execute PHPStan
38+
run: vendor/bin/phpstan analyze src -c phpstan.src.neon.dist --no-progress
39+
40+
phpstan_tests:
41+
name: PHPStan Tests
42+
runs-on: ubuntu-20.04
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v2
47+
48+
- name: Setup PHP
49+
uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: 7.4
52+
tools: composer:v2
53+
coverage: none
54+
55+
- name: Install Dependencies
56+
uses: nick-invision/retry@v1
57+
with:
58+
timeout_minutes: 5
59+
max_attempts: 5
60+
command: composer update --no-interaction --no-progress
61+
62+
- name: Install PHPStan
63+
uses: nick-invision/retry@v1
64+
with:
65+
timeout_minutes: 5
66+
max_attempts: 5
67+
command: composer bin phpstan update --no-interaction --no-progress
68+
69+
- name: Execute PHPStan
70+
run: vendor/bin/phpstan analyze tests -c phpstan.tests.neon.dist --no-progress
71+
72+
psalm:
73+
name: Psalm
74+
runs-on: ubuntu-20.04
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v2
79+
80+
- name: Setup PHP
81+
uses: shivammathur/setup-php@v2
82+
with:
83+
php-version: 7.4
84+
tools: composer:v2
85+
coverage: none
86+
87+
- name: Install Dependencies
88+
uses: nick-invision/retry@v1
89+
with:
90+
timeout_minutes: 5
91+
max_attempts: 5
92+
command: composer update --no-interaction --no-progress
93+
94+
- name: Install Psalm
95+
uses: nick-invision/retry@v1
96+
with:
97+
timeout_minutes: 5
98+
max_attempts: 5
99+
command: composer bin psalm update --no-interaction --no-progress
100+
101+
- name: Execute Psalm
102+
run: vendor/bin/psalm --no-progress --output-format=github

.github/workflows/tests.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
name: PHP ${{ matrix.php }}
10+
runs-on: ubuntu-20.04
11+
12+
strategy:
13+
matrix:
14+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
tools: composer:v2
25+
coverage: none
26+
27+
- name: Setup Problem Matchers
28+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
29+
30+
- name: Install PHP 5/7 Dependencies
31+
uses: nick-invision/retry@v1
32+
with:
33+
timeout_minutes: 5
34+
max_attempts: 5
35+
command: composer update --no-interaction --no-progress
36+
if: "matrix.php < 8"
37+
38+
- name: Install PHP 8 Dependencies
39+
uses: nick-invision/retry@v1
40+
with:
41+
timeout_minutes: 5
42+
max_attempts: 5
43+
command: composer update --no-interaction --no-progress --ignore-platform-reqs
44+
if: "matrix.php >= 8"
45+
46+
- name: Execute PHPUnit
47+
run: vendor/bin/phpunit

.travis.yml

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,13 @@ jobs:
44
dist: trusty
55
language: php
66
php: 5.5.9
7-
install: travis_retry composer update -n -o
7+
before_install: travis_retry composer self-update --2
8+
install: travis_retry composer update --no-interaction --no-progress
89
script: vendor/bin/phpunit
910
- name: PHP 5.5
1011
dist: trusty
1112
language: php
1213
php: 5.5
13-
install: travis_retry composer update -n -o
14+
before_install: travis_retry composer self-update --2
15+
install: travis_retry composer update --no-interaction --no-progress
1416
script: vendor/bin/phpunit
15-
- name: PHP 5.6
16-
dist: bionic
17-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:5.6 update -n -o
18-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:5.6
19-
- name: PHP 7.0
20-
dist: bionic
21-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.0 update -n -o
22-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.0
23-
- name: PHP 7.1
24-
dist: bionic
25-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.1 update -n -o
26-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.1
27-
- name: PHP 7.2
28-
dist: bionic
29-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.2 update -n -o
30-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.2
31-
- name: PHP 7.3
32-
dist: bionic
33-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.3 update -n -o
34-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.3
35-
- name: PHP 7.4
36-
dist: bionic
37-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.4 update -n -o
38-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.4
39-
- name: PHP 8.0
40-
dist: bionic
41-
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:8.0 update -n -o --ignore-platform-reqs
42-
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:8.0
43-
- name: PHPStan
44-
dist: bionic
45-
install:
46-
- travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.4 update -n -o
47-
- travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.4 bin phpstan update --prefer-dist -n -o
48-
script:
49-
- docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan registry.gitlab.com/grahamcampbell/php:7.4 analyse src
50-
- docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan registry.gitlab.com/grahamcampbell/php:7.4 analyse tests -c phpstan.tests.neon.dist

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
install:
2+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base update
3+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base bin all update
4+
5+
phpunit:
6+
@rm -f bootstrap/cache/*.php && docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
7+
8+
phpstan-analyze-src:
9+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze src -c phpstan.src.neon.dist
10+
11+
phpstan-analyze-tests:
12+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze tests -c phpstan.tests.neon.dist
13+
14+
psalm-analyze:
15+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
16+
17+
psalm-show-info:
18+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --show-info=true
19+
20+
test: phpunit phpstan-analyze-src phpstan-analyze-tests psalm-analyze
21+
22+
clean:
23+
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ This package implements the Option type for PHP!
55
![Banner](https://user-images.githubusercontent.com/2829600/71564011-3077bf00-2a91-11ea-9083-905702cc262b.png)
66

77
<p align="center">
8-
<a href="https://travis-ci.org/schmittjoh/php-option"><img src="https://img.shields.io/travis/schmittjoh/php-option/master?style=flat-square" alt="Build Status"></img></a>
9-
<a href="https://scrutinizer-ci.com/g/schmittjoh/php-option"><img src="https://img.shields.io/scrutinizer/g/schmittjoh/php-option.svg?style=flat-square" alt="Quality Score"></img></a>
108
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg?style=flat-square" alt="Software License"></img></a>
119
<a href="https://packagist.org/packages/phpoption/phpoption"><img src="https://img.shields.io/packagist/dt/phpoption/phpoption.svg?style=flat-square" alt="Total Downloads"></img></a>
1210
<a href="https://github.com/schmittjoh/php-option/releases"><img src="https://img.shields.io/github/release/schmittjoh/php-option.svg?style=flat-square" alt="Latest Version"></img></a>

psalm.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
</projectFiles>
12+
</psalm>

vendor-bin/psalm/composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"require": {
3+
"vimeo/psalm": "~3.12.2"
4+
},
5+
"config": {
6+
"preferred-install": "dist"
7+
}
8+
}

0 commit comments

Comments
 (0)