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

Realllow usage of php 7.2+, CI using github actions, demoprojects and other improvements #65

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f3b7e5e
Remove phpunit-result-cache from repository
Feb 9, 2022
eecc0dd
Add missing requirement to doctrine/annotations
Feb 9, 2022
8e198c5
No longer skip working test
Feb 9, 2022
3de1105
Add dev-requirement for failing test
Feb 9, 2022
e9a3a42
Make tests run with paragonie/sodium-compat installed
Feb 9, 2022
3879939
Refactor HaliteEncryptor::encrypt a bit
Feb 9, 2022
1d43a6b
Use proper return-values for succesfull command execution
Feb 9, 2022
f963b58
Add phpstan and readd support for php 7.4
Feb 10, 2022
a8431fb
Make library work in php 7.2 again
Feb 10, 2022
cfae79f
Add doctrine-bundle as requirement
Feb 10, 2022
b40e45a
Add symfony 4.4 as demo-project
Feb 10, 2022
3ad3e0b
Add simple unittest
Feb 10, 2022
6a5a07f
Make adjustments to use with php 8.0
Feb 10, 2022
11991c4
Include sqlite-database in symfony4.4-demo-project
Feb 10, 2022
1bad2a0
Rename Tests to tests
Feb 10, 2022
9cae1f1
Avoid including unnecessarry files in export to composer
Feb 10, 2022
c024b13
Demo/symfony4.4: add entity using attributes
Feb 11, 2022
9e3a6e4
Add README for demo-project
Feb 11, 2022
9d9709f
Demo/symfony4.4 Refactored the SecretRepositories to avoid code dupli…
Feb 11, 2022
6b2c19c
Add demo-project using symfony 6.0
Feb 12, 2022
e47c90f
Use proper name for phpunit-config in symfony4.4
Feb 12, 2022
d67cb14
Add CI
Feb 12, 2022
acfa3f3
Use prefix to run phpunit
Feb 12, 2022
61b6378
List vendor-dir
Feb 12, 2022
fb2f746
use proper executable for general unittests
Feb 12, 2022
2046987
Fix missed change for moving Tests to tests
Feb 12, 2022
f805459
Use ramsey/composer install@v2
Feb 12, 2022
ef639e1
Only test symfony 6.x using php 8.x
Feb 12, 2022
2968dc7
Use symlinks only from demo-package - not symfony-packages
Feb 12, 2022
860f27b
Use full matrix as seen in SymfonyCasts/verify-email-bundle
Feb 12, 2022
6672885
demo/symfony4.4 - use simpler commands im composer.json on post-updat…
Feb 12, 2022
0be22e1
Remove unused extra job and make CI-job-names more clear
Feb 12, 2022
a69ec09
Add statistical analysis-job and test using phpCompatibility
Feb 12, 2022
5b4163a
Restrict CI-run to to main and master-branch
Feb 12, 2022
564c439
Add failing test for updates of children of abstract entities
Zombaya Sep 25, 2020
a09b76c
Fix bug where touching without modifying a child of abstract entity w…
Zombaya Sep 25, 2020
e82f2b2
Port tests of MR#42 by sh41: Prevent update when nothing change on En…
Zombaya Sep 25, 2020
a912646
Reallow ci-actions on all branches
Feb 13, 2022
7c9c711
Add compatibilityTrait to allow both old and new versions of doctrine
Feb 13, 2022
69bdd18
Only run unittests after statistical-analysis has ran
Feb 13, 2022
1b19c8b
Add more files to export-ignore-list and only use CI on master/main
Feb 13, 2022
c2ceb18
Remove composer.lock from symfony6-demo and update README.md to point…
Feb 13, 2022
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
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://php.watch/articles/composer-gitattributes
/.github export-ignore
/demo export-ignore
/tests export-ignore

/.gitignore export-ignore
/.gitattributes export-ignore
/.travis.yml export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
113 changes: 113 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This file was heavily based on the ci-file from SymfonyCasts/verify-email-bundle
#
# See https://github.com/SymfonyCasts/verify-email-bundle
# https://github.com/SymfonyCasts/verify-email-bundle/blob/main/.github/workflows/ci.yml

name: CI
on:
push:
branches: ['main','master']
pull_request:

jobs:
static-analysis:
name: Static Analysis
runs-on: ubuntu-18.04

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"

- name: "Validate composer.json"
run: "composer validate --strict --no-check-lock"

- name: "Validate php-files"
run: "php -l src && php -l tests"

- name: "Composer install"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-stable"
dependency-versions: 'highest'

- name: "PHPStan"
run: "vendor/bin/phpstan analyze"

- name: "PHPCompatibility"
run: "vendor/bin/phpcs src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 7.2-8.1"

tests:
name: "Tests ${{ matrix.php-version }} ${{ matrix.dependency-versions }}"
runs-on: ubuntu-18.04
needs: static-analysis

strategy:
fail-fast: false
matrix:
# normal, highest, non-dev installs
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1']
composer-options: ['--prefer-stable']
dependency-versions: ['highest']
include:
# testing lowest PHP version with lowest dependencies
- php-version: '7.2.5'
dependency-versions: 'lowest'
composer-options: '--prefer-lowest'

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

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

# - name: Install Global Dependencies
# run: |
# composer global require --no-progress --no-scripts --no-plugins symfony/flex >=1.x

- name: "Composer install"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependency-versions }}"
composer-options: "--prefer-dist --no-progress"

- name: Unit Tests
run: vendor/bin/phpunit

- name: Install symlinks for demo's
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependency-versions }}"
composer-options: "--prefer-dist --no-progress"
working-directory: "demo"

- name: Demo symfony4.4 - Install dependencies
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependency-versions }}"
composer-options: "--prefer-dist --no-progress"
working-directory: "demo/symfony4.4"

- name: Demo symfony4.4 - Unit Tests
run: demo/symfony4.4/vendor/bin/simple-phpunit -c demo/symfony4.4/phpunit.xml.dist

- name: Demo symfony6.x - Install dependencies
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependency-versions }}"
composer-options: "--prefer-dist --no-progress"
working-directory: "demo/symfony6.x"
if: ${{ startsWith(matrix.php-version , '8.') }}

- name: Demo symfony6.x - Unit Tests
run: demo/symfony6.x/vendor/bin/simple-phpunit -c demo/symfony6.x/phpunit.xml.dist
if: ${{ startsWith(matrix.php-version , '8.') }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/
/composer.lock
/vendor
.phpunit.result.cache
.phpstan-cache/
1 change: 0 additions & 1 deletion .phpunit.result.cache

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ Filename example: `.DefuseEncryptor.key` or `.HaliteEncryptor.key`
* [Usage](src/Resources/doc/usage.md)
* [Console commands](src/Resources/doc/commands.md)
* [Custom encryption class](src/Resources/doc/custom_encryptor.md)

### Demo

Two demo-installations, one using symfony 4.4 and one using symfony 6.x, can be found in this repository in [`demo`](demo). This demonstrates how to use
the application using both annotations and, when using php > 8.0, attributes.
19 changes: 15 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
"license": "MIT",
"description": "Encrypted symfony entity's by verified and standardized libraries",
"require": {
"php": "^8.0",
"php": "^7.2|^8.0",
"paragonie/halite": "^4.6",
"paragonie/sodium_compat": "^1.5",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^2.0",
"symfony/property-access": "^4.1|^5.0|^6.0",
"symfony/dependency-injection": "^4.1|^5.0|^6.0",
"symfony/yaml": "^4.1|^5.0|^6.0",
"symfony/http-kernel": "^4.1|^5.0|^6.0",
"symfony/config": "^4.1|^5.0|^6.0"
"symfony/config": "^4.1|^5.0|^6.0",
"doctrine/annotations": "^1.13"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.0",
"defuse/php-encryption": "^2.1"
"defuse/php-encryption": "^2.1",
"doctrine/cache": "^1.11",
"phpstan/phpstan": "^1.4",
"jetbrains/phpstorm-attributes": "^1.0",
"phpcompatibility/php-compatibility": "^9.3"
},
"suggest": {
"defuse/php-encryption": "Alternative for halite for use with older php-versions",
Expand All @@ -28,9 +34,14 @@
"Ambta\\DoctrineEncryptBundle\\": "src/"
}
},
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"phpcs-compatibility-test" : "vendor/bin/phpcs src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 7.2-8.1"
},
"autoload-dev": {
"psr-4": {
"Ambta\\DoctrineEncryptBundle\\Tests\\": "Tests/"
"Ambta\\DoctrineEncryptBundle\\Tests\\": "tests/"
}
},
"config": {
Expand Down
5 changes: 5 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
/composer.lock
/vendor
.phpunit.result.cache
.phpstan-cache/
3 changes: 3 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Run `composer.install` in this directory to create symlinks for the shared files to the demo-projects

If you prefer a copy, use `composer install --no-dev`.
26 changes: 26 additions & 0 deletions demo/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "absolute-quantum/doctrine-encrypt-bundle-demo",
"description": "Symlinks shared directories",
"type": "metapackage",
"require": {
"kporras07/composer-symlinks": "^1.1"
},
"scripts": {
"post-install-cmd": [
"Kporras07\\ComposerSymlinks\\ScriptHandler::createSymlinks"
],
"post-update-cmd": [
"Kporras07\\ComposerSymlinks\\ScriptHandler::createSymlinks"
]
},
"extra": {
"symlinks": {
"shared/templates": "symfony4.4/templates",
"./shared/templates": "symfony6.x/templates",
"shared/var/data.db": "symfony4.4/var/data.db",
"./shared/var/data.db": "symfony6.x/var/data.db",
"shared/.Halite.key": "symfony4.4/.Halite.key",
"./shared/.Halite.key": "symfony6.x/.Halite.key"
}
}
}
1 change: 1 addition & 0 deletions demo/shared/.Halite.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
31400400ce550006e6a149298ed2a9d78d94d9a5aaac68e4b2d86ee0174c4e25ad03983e03d6d958d8f51636cbe221dd21ae6c186058af6b998001a7a04954a14ffc675595ccbdb04602b76dabe84b33d023974e8b8e689a1d03a9affe5abadad18a8861
51 changes: 51 additions & 0 deletions demo/shared/templates/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<style>
table {
font-size:16px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
}

td, th {
border: 1px solid #ddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2}

th {
padding-top: 11px;
padding-bottom: 11px;
background-color: #04AA6D;
color: white;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Symfony {{ appVersion }} using php{{ constant('PHP_MAJOR_VERSION')~'.'~constant('PHP_MINOR_VERSION') }}</h2>
<table>
<tr>
<th>Type</th>
<th>Name</th>
<th>Secret</th>
<th>Raw Secret (as stored in DB)</th>
</tr>
{% for secret in secrets %}
<tr>
<td>{{ secret.type }}</td>
<td>{{ secret.name }}</td>
<td>{{ secret.secret }}</td>
<td>{{ secret.rawSecret }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
Binary file added demo/shared/var/data.db
Binary file not shown.
31 changes: 31 additions & 0 deletions demo/symfony4.4/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=50710977b1177353fb0c574b9ce67051
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
DATABASE_PATH="var/data.db"
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
###< doctrine/doctrine-bundle ###
16 changes: 16 additions & 0 deletions demo/symfony4.4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ignore symlinks
/templates
/var/data.db
/.Halite.key

# Ignore locked versions of composer
composer.lock
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
1 change: 1 addition & 0 deletions demo/symfony4.4/.phpversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
72
26 changes: 26 additions & 0 deletions demo/symfony4.4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
This demo-installation demonstrates a simple symfony 4.4-application using both annotations and, when using php > 8.0, attributes.

# How to use
```shell
# run `composer install` in parent-directory to create symlinks for shared files
cd ../
composer install
cd -

# Install packages
composer install

# Serve the application
## Using symfony-cli
symfony serve
## Using php-builtin-server ()
php -S localhost:8000 -t public
## Other possibility
### Use a webserver like apache or nginx


# Run unittests
vendor/bin/simple-phpunit
```


Loading