Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v3.0 api redesign #3

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/integration.yml
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 }}
111 changes: 0 additions & 111 deletions .github/workflows/pr.yml

This file was deleted.

9 changes: 3 additions & 6 deletions .gitignore
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.*
11 changes: 11 additions & 0 deletions .mnavarro/assets/msg/pr.txt
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.
17 changes: 17 additions & 0 deletions .mnavarro/assets/msg/setup.txt
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!
52 changes: 52 additions & 0 deletions .mnavarro/docker/lib/Dockerfile
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
5 changes: 5 additions & 0 deletions .mnavarro/docker/lib/xdebug.ini
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
28 changes: 28 additions & 0 deletions .php-cs-fixer.dist.php
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 mnavarrocarter@gmail.com
@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')
);
47 changes: 47 additions & 0 deletions Makefile
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
Loading