Skip to content

Commit c2c44b9

Browse files
authored
Upgrade symfony to 5.4 & separate EntityMapper (#174)
* Update to Symfony 5.4 * Switch to lexik_jwt_bundle * Milliner needs islandora-fedora-entity-mapper but not Crayfish-Commons * Fix tests * Update dependencies to tagged versions * Remove unused imports * Github actions workflow * Update defaults to include the `user_identify_field` configuration parameter * Add upgrade docs * Update nodejs actions for workflows
1 parent d4bc375 commit c2c44b9

90 files changed

Lines changed: 1052 additions & 874 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-3.x.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
steps:
3030
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3131
- name: Checkout code
32-
uses: actions/checkout@v2
32+
uses: actions/checkout@v3
3333
with:
3434
path: build_dir
3535

3636
- name: Checkout islandora_ci
37-
uses: actions/checkout@v2
37+
uses: actions/checkout@v3
3838
with:
3939
repository: islandora/islandora_ci
4040
ref: github-actions
@@ -50,11 +50,18 @@ jobs:
5050
run: |
5151
echo "SCRIPT_DIR=$GITHUB_WORKSPACE/islandora_ci" >> $GITHUB_ENV
5252
53+
- name: Get composer cache directory
54+
id: composer-cache
55+
run: |
56+
cd $GITHUB_WORKSPACE/build_dir/Milliner
57+
echo "composer-cache-dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
58+
5359
- name: Cache Composer dependencies
54-
uses: actions/cache@v2
60+
uses: actions/cache@v3
5561
with:
56-
path: /tmp/composer-cache
57-
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
62+
path: ${{ env.composer-cache-dir }}
63+
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
64+
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-version }}
5865

5966
- name: composer install
6067
run: |
@@ -70,5 +77,5 @@ jobs:
7077
.scripts/tester
7178
7279
- name: codecov
73-
uses: codecov/codecov-action@v1
80+
uses: codecov/codecov-action@v3
7481

.github/workflows/build-4.x.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI - 4.x
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the 7.x branch
8+
push:
9+
branches: [ 4.x ]
10+
pull_request:
11+
branches: [ 4.x ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
php-versions: ["7.4", "8.0", "8.1"]
25+
26+
name: PHP ${{ matrix.php-versions }}
27+
28+
# Steps represent a sequence of tasks that will be executed as part of the job
29+
steps:
30+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
with:
34+
path: build_dir
35+
36+
- name: Checkout islandora_ci
37+
uses: actions/checkout@v3
38+
with:
39+
repository: islandora/islandora_ci
40+
ref: github-actions
41+
path: islandora_ci
42+
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php-versions }}
47+
tools: composer:v2
48+
49+
- name: Set environment variables
50+
run: |
51+
echo "SCRIPT_DIR=$GITHUB_WORKSPACE/islandora_ci" >> $GITHUB_ENV
52+
53+
- name: Get composer cache directory
54+
id: composer-cache
55+
run: |
56+
cd $GITHUB_WORKSPACE/build_dir/Milliner
57+
echo "composer-cache-dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
58+
59+
- name: Cache Composer dependencies
60+
uses: actions/cache@v3
61+
with:
62+
path: ${{ env.composer-cache-dir }}
63+
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
64+
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-version }}
65+
66+
- name: composer install
67+
run: |
68+
cd $GITHUB_WORKSPACE/build_dir
69+
for D in */; do (cd $D; composer install) done
70+
71+
- name: line endings
72+
run: $SCRIPT_DIR/line_endings.sh $GITHUB_WORKSPACE
73+
74+
- name: test scripts
75+
run: |
76+
cd $GITHUB_WORKSPACE/build_dir
77+
.scripts/tester
78+
79+
- name: codecov
80+
uses: codecov/codecov-action@v3
81+

Homarus/.env

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@
99
# Real environment variables win over .env files.
1010
#
1111
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/5.4/configuration/secrets.html
1213
#
1314
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14-
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
15+
# https://symfony.com/doc/5.4/best_practices.html#use-environment-variables-for-infrastructure-configuration
1516

1617
###> symfony/framework-bundle ###
1718
APP_ENV=dev
1819
APP_SECRET=2debbf0f3bc4a9484b577b8952dc3477
1920
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
2021
#TRUSTED_HOSTS='^(localhost|example\.com)$'
2122
###< symfony/framework-bundle ###
23+
24+
###> lexik/jwt-authentication-bundle ###
25+
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
26+
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
27+
JWT_PASSPHRASE=900bcb1e6df36b802204915dbe1c2f6a
28+
###< lexik/jwt-authentication-bundle ###

Homarus/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ the `app.executable` parameter in [`/path/to/Homarus/config/services.yaml`](./co
4949
You also need to set your Fedora Base Url to allow the Fedora Resource to be pulled in automatically.
5050
This is done in the `/path/to/Homarus/config/packages/crayfish_commons.yaml`.
5151

52-
Also in the `/path/to/Homarus/config/packages/crayfish_commons.yaml` file you can point to the location of your `syn-settings.xml`.
53-
If you don't have a `syn-settings.xml` look at the [Syn](http://github.com/Islandora/Syn) documentation.
54-
5552
### Logging
5653

5754
To change your log settings, edit the `/path/to/Homarus/config/packages/monolog.yaml` file.
@@ -62,10 +59,13 @@ environment directory will take precedence over those in the `/path/to/Homarus/c
6259

6360
The location specified in the configuration file for the log must be writable by the web server.
6461

65-
### Disabling Syn
62+
### Enabling JWT authentication
6663

6764
There are instructions in the `/path/to/Homarus/config/packages/security.yaml` file describing what to change and what lines
68-
to comment out to disable Syn.
65+
to comment out to enable authentication.
66+
67+
We use the Lexik JWT Authentication Bundle for Symfony, more information here
68+
https://github.com/lexik/LexikJWTAuthenticationBundle
6969

7070
## Usage
7171
This will return the an AVI file for the test video file in Fedora.

Homarus/UPGRADE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
This document guides you through the process of upgrading Homarus. First, check if a section named "Upgrade to x.x.x" exists, with x.x.x being the version you are planning to upgrade to.
22

3+
## Upgrade to 4.0.0
4+
5+
4.0.0 uses Symfony 5.4, which has differences from 3.x.x which used Symfony 4.4.
6+
This makes it non-backwards compatible and requires testing of any custom changes you
7+
may have made.
8+
9+
Homarus relies on Crayfish-Commons `^4.0` which no longer includes our own JWT authentication,
10+
to perform JWT authentication we use the [Lexik JWT Bundle](https://github.com/lexik/LexikJWTAuthenticationBundle).
11+
12+
### Upgrade from version 3.x.x
13+
14+
You can remove the `syn_config:` line from the `./config/packages/crayfish_commons.yaml` file.
15+
16+
You can add a line like `apix_middleware_enabled: false` to the `./config/packages/crayfish_commons.yaml` file.
17+
This disables the ApixMiddleware as we pass the full URL to ffmpeg instead of downloading the file and passing
18+
it directly.
19+
20+
You will need to make a file in `./config/packages` called `lexik_jwt_authentication.yaml`.
21+
22+
The file needs to contain (at a minimum) or you can copy the file from the Github repository:
23+
```yaml
24+
lexik_jwt_authentication:
25+
# This is the public key from the pair generated by Drupal and is required to validate the JWTs
26+
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
27+
# By default lexik_jwt looks for the username key in the payload, we use sub
28+
user_identity_field: sub
29+
```
30+
31+
You can either:
32+
* define an [environment variables](https://symfony.com/doc/5.4/configuration.html#configuration-based-on-environment-variables) for
33+
the `JWT_PUBLIC_KEY` variable defined above and pointed to the Drupal public key file
34+
35+
_or_
36+
* explicitly overwrite the `'%env(resolve:JWT_PUBLIC_KEY)%'` in
37+
the above file and specify the path to the Drupal public key
38+
39+
340
## Upgrade to 3.0.0
441

542
Homarus (and all of Crayfish) adheres to [semantic versioning](https://semver.org), which makes a distinction between "major", "minor", and "patch" versions. The upgrade path will be different depending on which previous version from which you are migrating.

Homarus/composer.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@
66
"require": {
77
"ext-ctype": "*",
88
"ext-iconv": "*",
9-
"islandora/crayfish-commons": "^3.0",
10-
"symfony/dotenv": "4.4.*",
9+
"islandora/crayfish-commons": "^4.0",
10+
"lexik/jwt-authentication-bundle": "^2.18",
11+
"symfony/dotenv": "5.4.*",
1112
"symfony/flex": "^1.3.1",
12-
"symfony/framework-bundle": "4.4.*",
13-
"symfony/yaml": "4.4.*"
13+
"symfony/framework-bundle": "5.4.*",
14+
"symfony/runtime": "5.4.*",
15+
"symfony/string": "5.4.*",
16+
"symfony/translation": "5.4.*",
17+
"symfony/yaml": "5.4.*"
1418
},
1519
"require-dev": {
1620
"phpspec/prophecy-phpunit": "^2.0",
1721
"phpunit/phpunit": "^9.5",
1822
"sebastian/phpcpd": "^6.0",
1923
"squizlabs/php_codesniffer": "^3.0",
20-
"symfony/var-dumper": "4.4.*",
21-
"symfony/browser-kit": "4.4.*",
22-
"symfony/css-selector": "4.4.*",
24+
"symfony/var-dumper": "5.4.*",
25+
"symfony/browser-kit": "5.4.*",
26+
"symfony/css-selector": "5.4.*",
2327
"symfony/maker-bundle": "^1.0",
24-
"symfony/phpunit-bridge": "4.4.*"
28+
"symfony/phpunit-bridge": "5.4.*"
2529
},
2630
"minimum-stability": "dev",
2731
"prefer-stable": true,
@@ -31,7 +35,8 @@
3135
},
3236
"sort-packages": true,
3337
"allow-plugins": {
34-
"symfony/flex": true
38+
"symfony/flex": true,
39+
"symfony/runtime": true
3540
}
3641
},
3742
"autoload": {
@@ -68,7 +73,7 @@
6873
"extra": {
6974
"symfony": {
7075
"allow-contrib": false,
71-
"require": "4.4.*"
76+
"require": "5.4.*"
7277
}
7378
},
7479
"authors": [

Homarus/config/bootstrap.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

Homarus/config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
Islandora\Crayfish\Commons\CrayfishCommonsBundle::class => ['all' => true],
66
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
77
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
8+
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
89
];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
crayfish_commons:
22
fedora_base_uri: 'http://localhost:8080/fcrepo/rest'
3-
#syn_config: '/path/to/syn-settings.xml'
3+
apix_middleware_enabled: false
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
# see https://symfony.com/doc/current/reference/configuration/framework.html
1+
# see https://symfony.com/doc/5.4/reference/configuration/framework.html
22
framework:
33
secret: '%env(APP_SECRET)%'
44
#csrf_protection: true
5-
#http_method_override: true
5+
http_method_override: false
66

77
# Enables session support. Note that the session will ONLY be started if you read or write from it.
88
# Remove or comment this section to explicitly disable session support.
99
session:
1010
handler_id: null
1111
cookie_secure: auto
1212
cookie_samesite: lax
13+
storage_factory_id: session.storage.factory.native
1314

1415
#esi: true
1516
#fragments: true
1617
php_errors:
1718
log: true
19+
20+
when@test:
21+
framework:
22+
test: true
23+
session:
24+
storage_factory_id: session.storage.factory.mock_file

0 commit comments

Comments
 (0)