Skip to content

Commit

Permalink
[TASK] Add phpstan, add GitHub workflows and add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Feb 24, 2024
1 parent 3d844ab commit c0cdb34
Show file tree
Hide file tree
Showing 26 changed files with 1,108 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
/.* export-ignore
/tests export-ignore
/behat.yml export-ignore
/phpunit.xml export-ignore
/rector.php export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
34 changes: 34 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
name: dependabot-auto-merge
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ github.actor == 'dependabot[bot]' }}
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
30 changes: 30 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/phpstan.yml
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'
- '.github/workflows/phpstan.yml'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: vendor/bin/phpstan --error-format=github
48 changes: 48 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/run-tests.yml
name: run-tests

on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
php: [ 8.3, 8.2, 8.1 ]
stability: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.stability }}

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

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

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
run: vendor/bin/phpunit --no-coverage
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/.idea/
/build/
/vendor/
/reports/
/.php-cs-fixer.cache
/.phpunit.result.cache
/composer.lock
/phpstan.neon
/phpunit.xml
File renamed without changes.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# PHP KML parser

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/simonschaufi/10)
[![Latest Stable Version](https://poser.pugx.org/simonschaufi/php-libkml/v/stable)](https://packagist.org/packages/simonschaufi/php-libkml)
[![Total Downloads](https://poser.pugx.org/simonschaufi/php-libkml/downloads)](https://packagist.org/packages/simonschaufi/php-libkml)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/simonschaufi/php-libkml.svg)](https://packagist.org/packages/simonschaufi/php-libkml)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/simonschaufi/php-libkml/run-tests.yml?branch=main&label=tests)](https://github.com/simonschaufi/php-libkml/actions?query=workflow%3Arun-tests+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/simonschaufi/php-libkml.svg)](https://packagist.org/packages/simonschaufi/php-libkml)
[![License](https://poser.pugx.org/simonschaufi/php-libkml/license)](https://packagist.org/packages/simonschaufi/php-libkml)

A php library to parse KML/KMZ files.
Expand Down Expand Up @@ -32,19 +33,24 @@ Future features:
* GeoJson
* WKT

## Usage

### Installation

The recommended way to install the extension is using [Composer][1].
## Installation

Run the following command within your Composer based TYPO3 project:
You can install the package via composer:

```bash
composer require simonschaufi/php-libkml
```

### Contribution
## Usage

```php
$kmlReader = new KmlReader();
$kmlDocument = $kmlReader->fromString($kml);
// or
$kmlDocument = $kmlReader->fromKmlFile($kmlFilePath);
```

## Contributing

**Pull Requests** are gladly welcome!

Expand All @@ -69,4 +75,11 @@ Execute acceptance tests:
composer local:tests:acceptance
```

[1]: https://getcomposer.org/
## Credits

- [Simon Schaufelberger](https://github.com/simonschaufi)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
"dvdoug/behat-code-coverage": "^5.3.2",
"ergebnis/composer-normalize": "^2.42.0",
"friendsofphp/php-cs-fixer": "^3.49.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.59",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpstan/phpstan-strict-rules": "^1.5.2",
"phpunit/phpunit": "^10.5.10",
"rector/rector": "^1.0.1",
"spaze/phpstan-disallowed-calls": "^3.1",
"squizlabs/php_codesniffer": "^3.9.0"
},
"minimum-stability": "dev",
Expand All @@ -39,20 +45,24 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
"ci:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix -v --dry-run --diff",
"ci:tests:acceptance": "XDEBUG_MODE=coverage vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
"ci:tests:unit": "vendor/bin/phpunit --colors=never",
"ci:php:stan": "vendor/bin/phpstan analyse --no-progress",
"ci:rector": "vendor/bin/rector process --dry-run",
"ci:tests:acceptance": "vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
"ci:tests:unit": "vendor/bin/phpunit --no-coverage --colors=never",
"fix:composer:normalize": "@composer normalize --no-check-lock",
"fix:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix",
"fix:rector": "vendor/bin/rector process",
"local:clean": "rm -Rf reports",
"local:tests:acceptance": "XDEBUG_MODE=coverage vendor/bin/behat --colors --no-snippets",
"local:tests:unit": "vendor/bin/phpunit --colors=always"
"local:clean": "rm -Rf build",
"local:tests:acceptance": "vendor/bin/behat --colors --no-snippets",
"local:tests:unit": "vendor/bin/phpunit --no-coverage",
"local:tests:unit-coverage": "vendor/bin/phpunit --coverage",
"phpstan:baseline": "vendor/bin/phpstan --generate-baseline --allow-empty-baseline"
}
}
Loading

0 comments on commit c0cdb34

Please sign in to comment.