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

Upgrade to Symfony 7 and PHP 8.2 #67

Merged
merged 49 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ce0861f
Add files to build a docker image
quartje Apr 8, 2024
97915d6
Make the default config file work with the devconf setup
quartje Apr 8, 2024
58b6fff
Docker compose for tests: Move to the container from the base contain…
quartje Apr 8, 2024
8ae9076
Add workflow file to build and publish a docker container
quartje Apr 8, 2024
d5e196f
Upgrade Sf7 / PHP8
parijke Apr 25, 2024
47d6170
Upgrade Sf7 / PHP8
parijke Apr 25, 2024
960b930
Upgrade Sf7 / PHP8
parijke Apr 25, 2024
69b6deb
Ran phpcbf
parijke Apr 25, 2024
449635d
Ran phpcbf
parijke Apr 25, 2024
e81a2ee
Fix paths
parijke Apr 26, 2024
27ca1d7
Add db creation
parijke Apr 26, 2024
490234e
Remove obsolete test
parijke Apr 26, 2024
8836856
Add Typing
parijke Apr 26, 2024
563f5d6
Add Typing and delete obsolete tests
parijke Apr 26, 2024
98f0716
Remove obsolete config and add typing
parijke Apr 26, 2024
6b2713f
Remove obsolete config
parijke Apr 26, 2024
40188d6
Move to central config
parijke Apr 26, 2024
7da7a12
Override getLogDir
parijke Apr 29, 2024
76e82bb
Correct spelling error in comment
parijke Apr 29, 2024
79589b3
Make Classname and File name identical
parijke Apr 29, 2024
d5fc2b2
Remove CompilerPass for TaggedIterator
parijke Apr 29, 2024
a07352d
Composer: Update lockfile, add name and description to composer.json
quartje May 7, 2024
ab61163
Docker: Upgrade docker image to PHP82
quartje May 7, 2024
4b3a8c6
Add workflow_dispatch to the release workflow in GHA
quartje May 7, 2024
c91954f
GHA: Bring docker build workflow in line with other apps
quartje May 7, 2024
0094c84
Docker: Bring dockerfile in line with the other apps
quartje May 7, 2024
61c8884
Docker: Rename apache config file
quartje May 7, 2024
3ff2c2b
Revert "Remove CompilerPass for TaggedIterator"
parijke May 8, 2024
8817817
Remove parameters from git
parijke May 18, 2024
2ac4dc2
Set phpstan baseline
parijke May 18, 2024
d0e2732
Update phpunit recipe
parijke May 20, 2024
9e1fdca
Update phpstan recipe
parijke May 20, 2024
bbe8cc0
Update symfony/flex recipe
parijke May 20, 2024
9f57d37
Update squizlabs/php_codesniffer
parijke May 20, 2024
daa5f15
Updates from recipe
parijke May 20, 2024
48c484e
Update recipe update with correct controller path
parijke May 20, 2024
cf0d330
Update composer lock
parijke May 20, 2024
294496c
Symplify Service config
parijke May 20, 2024
9b096e9
Disable esi and fragments
parijke May 20, 2024
3db4f9d
Further simplify services
parijke May 20, 2024
c00c7f0
Re-add monitor routes
parijke May 20, 2024
0636591
Document the api endpoints you are required to implement
thijskh Feb 23, 2024
8b1f7be
Remove /app from gitignore (file does not exists anymore)
parijke May 21, 2024
d14f270
Remove obsolete comments
parijke May 21, 2024
8904c93
Remove XDEBUG_MODE from command line
parijke May 21, 2024
6d7ec2e
Remove 3rd party assertion
parijke May 21, 2024
8a23843
Sort bundles alphabetically
parijke May 21, 2024
6c4a849
README: Remove /dev/log logging weirdness. We log to stdout in docker
quartje May 30, 2024
fe4a303
Docker compose: Not longer used
quartje May 30, 2024
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
67 changes: 67 additions & 0 deletions .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: build-push-docker-image

on:
push:
branches: feature/docker_configs
workflow_dispatch:

jobs:
build-push-docker-image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: get the latest release
id: release
uses: robinraju/[email protected]
with:
filename: "*.tar.bz2"
tag: "${{ github.ref_name }}"

- name: Get commit details for the tag from the latest release
id: commit_details
run: |
echo "sha=$(git rev-list -n 1 ${{ steps.release.outputs.tag_name }})" >> $GITHUB_OUTPUT
echo "commit_time=$(git show -s --format=%ci ${{ steps.release.outputs.tag_name }})" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set docker metadata for the container
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/openconext/openconext-user-lifecycle/user-lifecycle
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=sha
type=raw,value=prod

- name: Build and push the Production image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
APP_VERSION=${{ steps.release.outputs.tag_name }}
GIT_SHA=${{ steps.commit_details.outputs.sha }}
GIT_COMMIT_TIME=${{ steps.commit_details.outputs.commit_time }}
file: docker/Dockerfile.prod
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
51 changes: 51 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: tag-release
on:
push:
tags:
- "*.*.*"
workflow_dispatch:

jobs:
build:
permissions:
contents: write

runs-on: ubuntu-latest
timeout-minutes: 30
env:
COMPONENT_NAME: OpenConext-user-lifecycle
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: OpenConext/Stepup-Build
- name: Output the semver tag to the tag variable
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Run release script
run: ./stepup-build.sh ${COMPONENT_NAME} --tag ${{ steps.vars.outputs.tag }}
- name: Grab the archive filename
id: archive
run: |
echo "archive=$(find . -maxdepth 1 -name "$COMPONENT_NAME*.tar.bz2" -printf '%f\n')" >> $GITHUB_OUTPUT
echo "shasum=$(find . -maxdepth 1 -name "$COMPONENT_NAME*.sha" -printf '%f\n')" >> $GITHUB_OUTPUT

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.archive.outputs.archive }}
${{ steps.archive.outputs.shasum }}
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true
generate_release_notes: true

after_build:
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger Docker container build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: build-push-docker-image.yml
42 changes: 19 additions & 23 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: test-integration
on:
pull_request:
push:
branches: [ master, develop ]
name: Run QA tests (static analysis, lint and unit tests)
on: [pull_request]

jobs:
build:
run-qa-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
working-directory: /var/www/html/
container:
image: ghcr.io/openconext/openconext-basecontainers/php82-apache2-node20-composer2:latest
volumes:
- .:/var/www/html

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Init environment
run: |
docker-compose up -d
- name: Install dependencies
run: docker-compose exec -T php-fpm sh -c 'composer install'
- name: Run tests
run: docker-compose exec -T php-fpm sh -c 'composer test'
uses: actions/checkout@v4

- name: Composer install
run: composer install

- name: Run QA tests
run: composer check
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/.vagrant/
/ansible/*.retry
/config/legacy/parameters.yml
/config/openconext/parameters.yaml
/var/*
!/var/cache
/var/cache/*
Expand All @@ -14,7 +12,6 @@
!var/SymfonyRequirements.php
/vendor/
/web/bundles/
/app/bootstrap.php.cache
/.idea
.env
docker-compose.override.yml
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.0
MKodde marked this conversation as resolved.
Show resolved Hide resolved
- Upgrade to Symfony 7
- Upgrade to PHP8.2
- Upgrade dependencies
- Introduce type safety where possible

## 0.1.3
- Log using stream handler by default #57
- Creating an error message with multiple messages causes fatal error #62
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,5 @@ A great log solution, but this did not fit for UserLifecyle. Here we log data we
the fingers crossed strategy here was not practical. So the regular `stream` log strategy is used, logging everything
surpassing the configured log level (`notice`).

### Docker logging
When using the provided docker container for test or development. Logs are forwarded to the /dev/log (syslog) of the
host machine. This diverges from the industry standard of outputting to `stderr`, that way you can lever the docker log
mechanism.

If you want to view the dev logs: check the syslog on your own machine.

## For developers
See the `/docs` folder for more details information about the application.
42 changes: 11 additions & 31 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
#!/usr/bin/env php
<?php

use OpenConext\UserLifecycle\Kernel;
use OpenConext\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;

if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
require_once dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
return new Application($kernel);
};
30 changes: 17 additions & 13 deletions bin/phpunit
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/usr/bin/env php
<?php

if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
}
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}

require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}
2 changes: 1 addition & 1 deletion ci/qa/docheader
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cd $(dirname $0)/../../

./vendor/bin/docheader check src/ tests/
./vendor/bin/docheader check src tests
6 changes: 6 additions & 0 deletions ci/qa/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

cd $(dirname $0)/../../

# https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically
./vendor/bin/phpcbf --standard=ci/qa/phpcs.xml $1
11 changes: 11 additions & 0 deletions ci/qa/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@
<property name="absoluteLineLimit" value="150" />
</properties>
</rule>
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/DeclareStrictTypesSniff.php" />
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly" />-->
<!-- <rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/UnusedUsesSniff.php" />-->
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
<properties>
<property name="minLineLength" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration" />
</ruleset>
2 changes: 1 addition & 1 deletion ci/qa/phplint
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh

vendor/bin/parallel-lint --exclude vendor . -j 10
vendor/bin/phplint --exclude vendor . -j 10
5 changes: 5 additions & 0 deletions ci/qa/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd $(dirname $0)/../../

vendor/bin/phpstan analyze --memory-limit=-1 --no-ansi -c ./ci/qa/phpstan.neon
Loading