Skip to content

Commit

Permalink
Setup library
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent4vx committed Aug 1, 2023
0 parents commit 17247dc
Show file tree
Hide file tree
Showing 19 changed files with 1,415 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
name: PHP ${{ matrix.php-versions }}

steps:
- uses: actions/checkout@v2

- name: Set Timezone
uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Paris"

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json
ini-values: date.timezone=Europe/Paris
- name: Check PHP Version
run: php -v

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: make tests-unit

analysis:
name: Analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set Timezone
uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Paris"

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: json
ini-values: date.timezone=Europe/Paris

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run type coverage
run: make psalm-ci

- name: Run Infection
run: |
git fetch --depth=1 origin $GITHUB_BASE_REF
make infection-ci
- name: Run PHPCS
run: make phpcs
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea
vendor/
infection.log
infection.phar
infection.phar.asc
.phpunit.result.cache
composer.lock
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 b2pweb

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ROOT_DIR=$(shell pwd)/
TESTDIR=$(ROOT_DIR)/tests
PHPUNIT=vendor/bin/phpunit
INFECTION_VERSION=0.15.3
INFECTION_ARGS=

all: install tests

install:
composer update

tests: run-phpunit psalm run-infection phpcs

coverage: PUARGS="--coverage-clover=coverage.xml"
coverage: tests-unit

tests-unit: run-phpunit

run-phpunit:
@$(PHPUNIT) $(PUARGS)

psalm:
vendor/bin/psalm

psalm-ci:
vendor/bin/psalm --shepherd

infection.phar:
wget --no-check-certificate "https://github.com/infection/infection/releases/download/$(INFECTION_VERSION)/infection.phar"
wget --no-check-certificate "https://github.com/infection/infection/releases/download/$(INFECTION_VERSION)/infection.phar.asc"
chmod +x infection.phar

infection: infection.phar test-server run-infection kill-test-server

infection-ci: INFECTION_ARGS=--logger-github --git-diff-filter=AM
infection-ci: INFECTION_VERSION=0.23.0
infection-ci: infection

phpcs:
vendor/bin/phpcs src/ --standard=psr12 --runtime-set ignore_warnings_on_exit true

run-infection: infection.phar
./infection.phar $(INFECTION_ARGS)

.PHONY: tests test-server clean install infection infection-ci psalm psalm-ci phpcs
41 changes: 41 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "b2pweb/jwt",
"description": "Simple library for parse JWT token",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"B2pweb\\Jwt\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"B2pweb\\Jwt\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Vincent Quatrevieux",
"email": "vquatrevieux@b2pweb.com"
}
],
"minimum-stability": "stable",
"require": {
"php": "~7.1 | ~8.0.0 | ~8.1.0 | ~8.2.0",
"ext-json": "*",
"spomky-labs/base64url": "~2.0",
"web-token/jwt-signature": "~1.3|~2.0|~3.0",
"web-token/jwt-checker": "~1.3|~2.0|~3.0",
"web-token/jwt-key-mgmt": "~1.3|~2.0|~3.0",
"web-token/jwt-signature-algorithm-ecdsa": "~1.3|~2.0|~3.0",
"web-token/jwt-signature-algorithm-eddsa": "~1.3|~2.0|~3.0",
"web-token/jwt-signature-algorithm-hmac": "~1.3|~2.0|~3.0",
"web-token/jwt-signature-algorithm-none": "~1.3|~2.0|~3.0",
"web-token/jwt-signature-algorithm-rsa": "~1.3|~2.0|~3.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0 | ~8.5",
"vimeo/psalm": "~4.9",
"squizlabs/php_codesniffer": "~3.6"
}
}
14 changes: 14 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"timeout": 10,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "infection.log"
},
"mutators": {
"@default": true
}
}
26 changes: 26 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<php>
<ini name="error_reporting" value="-1" />
<ini name="zend.enable_gc" value="false" />
<ini name="memory_limit" value="-1" />
</php>

<testsuites>
<testsuite name="All Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
Loading

0 comments on commit 17247dc

Please sign in to comment.