-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implements a redesign of the Fernet base api. Focus on the redesign was to remove unneded abstractions, name methods and parameters more appropiately, improve unit testing and support PHP 8.0. BREAKING CHANGE: Unfortunately, this release breaks BC so make all this improvements. However, public api surface of this library is so small that migration should be effortless. Version 2.x will still be mantained for security patches and bugfixes only.
- Loading branch information
1 parent
91357dc
commit 8318956
Showing
44 changed files
with
5,921 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: "Code Integration Checks" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "master" | ||
- "2.x" | ||
|
||
env: | ||
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --ignore-platform-req=php" | ||
|
||
jobs: | ||
|
||
# PHP Checks (PHP CS Fixer, Psalm, PHPUnit) | ||
quality-checks: | ||
name: "Quality Checks" | ||
runs-on: ${{ matrix.operating-system }} | ||
timeout-minutes: 10 | ||
env: | ||
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --ignore-platform-req=php" | ||
strategy: | ||
matrix: | ||
dependencies: | ||
- "locked" | ||
- "highest" | ||
php-version: | ||
- "8.0" | ||
- "8.1" | ||
operating-system: | ||
- "ubuntu-latest" | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
- name: "Setup PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: "xdebug" | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
tools: composer:v2 | ||
- name: "Cache dependencies" | ||
uses: "actions/cache@v2" | ||
with: | ||
path: | | ||
~/.composer/cache | ||
vendor | ||
key: "${{ runner.os}}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}" | ||
restore-keys: "${{ runner.os}}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}" | ||
- name: "Install highest dependencies" | ||
if: ${{ matrix.dependencies == 'highest' }} | ||
run: "composer update ${{ env.COMPOSER_FLAGS }}" | ||
continue-on-error: true | ||
- name: "Install locked dependencies" | ||
if: ${{ matrix.dependencies == 'locked' }} | ||
run: "composer install ${{ env.COMPOSER_FLAGS }}" | ||
- name: "Run PHP CS Fixer" | ||
run: "php vendor/bin/php-cs-fixer fix --dry-run -vvv" | ||
- name: "Run Psalm" | ||
run: "php vendor/bin/psalm --stats --no-cache --show-info=true" | ||
- name: "Run PHPUnit" | ||
run: "php vendor/bin/phpunit --coverage-text --testsuite=unit" | ||
|
||
release: | ||
name: "Release" | ||
needs: | ||
- quality-checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Semantic Release | ||
uses: codfish/semantic-release-action@v1 | ||
with: | ||
branches: | | ||
[ | ||
'+([0-9])?(.{+([0-9]),x}).x', | ||
'master' | ||
] | ||
tag_format: '${version}' | ||
plugins: | | ||
['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github'] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
vendor | ||
composer.lock | ||
phpunit.xml | ||
build | ||
psalm.xml | ||
.php_cs | ||
.phpunit.result.cache | ||
.php_cs.cache | ||
.idea | ||
.vscode | ||
*.override.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
READY FOR PR! | ||
|
||
Don't forget to add only relevant files to the staging tree. | ||
|
||
Please follow conventional commits guidelines for your commit message. See: https://www.conventionalcommits.org/en/v1.0.0/ | ||
|
||
Describe your changes in the commit description accurately. | ||
|
||
Remember to rebase locally if main has had new commits since you created your branch. | ||
|
||
If possible, squash your changes into a single commit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
PROJECT SETUP COMPLETE! | ||
|
||
We recommend adding this alias to your shell: | ||
|
||
alias dc="docker-compose" | ||
|
||
After you have done it, you can quickly use "dc" to exec into a container: | ||
|
||
dc exec app php -v | ||
|
||
To open an alpine shell into the app service, run: | ||
|
||
dc exec app ash | ||
|
||
Don't forget to run "make pr" before pushing code for a Pull Request. | ||
|
||
Happy coding! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM alpine:3.15 as base | ||
|
||
ARG UID=1000 | ||
ARG COMPOSER_VERSION=2.3.0 | ||
ARG USER=mnavarro | ||
|
||
# Create a development user | ||
RUN adduser $USER --disabled-password --home /$USER --uid $UID | ||
|
||
# Install PHP Extensions | ||
RUN apk add --no-cache \ | ||
php8-cli \ | ||
php8-phar \ | ||
php8-mbstring \ | ||
php8-json \ | ||
php8-zip \ | ||
php8-openssl \ | ||
php8-dom \ | ||
php8-xml \ | ||
php8-soap \ | ||
php8-session \ | ||
php8-xmlwriter \ | ||
php8-sockets \ | ||
php8-simplexml \ | ||
php8-bcmath \ | ||
php8-xmlreader \ | ||
php8-tokenizer \ | ||
php8-iconv \ | ||
php8-sodium \ | ||
php8-fileinfo \ | ||
php8-curl \ | ||
php8-ctype \ | ||
php8-pdo \ | ||
php8-pcntl \ | ||
php8-posix \ | ||
php8-pdo_pgsql | ||
|
||
# Link PHP | ||
RUN ln -s /usr/bin/php8 /usr/bin/php | ||
|
||
# Add wget to make requests | ||
RUN apk add --no-cache wget | ||
|
||
# Download and install composer | ||
RUN wget -O /usr/bin/composer https://github.com/composer/composer/releases/download/$COMPOSER_VERSION/composer.phar && \ | ||
chmod +x /usr/bin/composer | ||
|
||
FROM base as dev | ||
|
||
# Install and Configure XDebug | ||
RUN apk add --no-cache php8-pecl-xdebug | ||
COPY ./lib/xdebug.ini /etc/php8/conf.d/60_xdebug.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
zend_extension=xdebug.so | ||
|
||
[xdebug] | ||
xdebug.mode=debug,develop,coverage | ||
xdebug.client_host=host.docker.internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
$header = <<<EOF | ||
@project MNC Fernet | ||
@link https://github.com/mnavarrocarter/fernet | ||
@project mnavarrocarter/fernet | ||
@author Matias Navarro-Carter [email protected] | ||
@license MIT | ||
@copyright 2022 Matias Navarro-Carter | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setCacheFile('var/php-cs-fixer.cache') | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PhpCsFixer' => true, | ||
'declare_strict_types' => true, | ||
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc'], | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->in(__DIR__ . '/tests') | ||
->exclude(__DIR__.'/var') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
META_FOLDER=.mnavarro | ||
MAIN_SERVICE_NAME=lib | ||
|
||
setup: build dependencies boot | ||
cat $(META_FOLDER)/assets/msg/setup.txt | ||
|
||
# Builds docker images needed for this project | ||
build: | ||
docker-compose build | ||
|
||
# Rebuilds docker images needed for this project without using the cache | ||
rebuild: | ||
docker-compose build --no-cache --pull | ||
docker-compose up -d --remove-orphans --force-recreate | ||
|
||
# Installs dependencies with composer | ||
dependencies: | ||
docker-compose run --rm $(MAIN_SERVICE_NAME) composer install | ||
|
||
# Boots all the services in the docker-compose stack | ||
boot: | ||
docker-compose up -d --remove-orphans | ||
|
||
# Formats the code according to php-cs-fixer rules | ||
fmt: | ||
docker-compose exec $(MAIN_SERVICE_NAME) vendor/bin/php-cs-fixer fix | ||
|
||
# Run static analysis on the code | ||
analyze: | ||
docker-compose exec $(MAIN_SERVICE_NAME) vendor/bin/psalm --stats --no-cache --show-info=true | ||
|
||
# Runs the test suite | ||
test: | ||
docker-compose exec $(MAIN_SERVICE_NAME) vendor/bin/phpunit --coverage-text | ||
|
||
# Stops all services and destroys all the containers. | ||
# NOTE: Named kill to convey the more accurate meaning that the containers are destroyed. | ||
kill: | ||
docker-compose down | ||
|
||
# Stops the services. Use this when you are done with development for a while. | ||
stop: | ||
docker-compose stop | ||
|
||
# Prepares a PR | ||
pr: fmt analyze test | ||
cat $(META_FOLDER)/assets/msg/pr.txt |
Oops, something went wrong.