Skip to content

Commit f7b88c2

Browse files
committed
Added support for os2web_key
1 parent abd45a2 commit f7b88c2

18 files changed

+385
-457
lines changed

.github/workflows/pr.yaml

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,9 @@ jobs:
4949
composer validate --strict composer.json
5050
# Check that dependencies resolve.
5151
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
52-
53-
markdown-coding-standards:
54-
name: Yarn - Check Coding Standards (Node ${{ matrix.node }})
55-
runs-on: ubuntu-latest
56-
strategy:
57-
matrix:
58-
node: [ '20' ]
59-
steps:
60-
- uses: actions/checkout@v2
61-
- name: Setup node
62-
uses: actions/setup-node@v2
63-
with:
64-
node-version: ${{ matrix.node }}
65-
- run: |
66-
yarn install
67-
yarn coding-standards-check
52+
- name: Check that composer file is normalized
53+
run: |
54+
composer normalize --dry-run
6855
6956
php-check-coding-standards:
7057
name: PHP - Check Coding Standards
@@ -125,34 +112,17 @@ jobs:
125112
path: ${{ steps.composer-cache.outputs.dir }}
126113
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
127114
restore-keys: ${{ runner.os }}-composer-
128-
- name: drupal-check
115+
- name: Code analysis
129116
run: |
130-
# We need a Drupal project to run drupal-check (cf. https://github.com/mglaman/drupal-check#usage)
131-
# Install Drupal
132-
composer --no-interaction create-project drupal/recommended-project:^9 --stability=dev drupal
133-
# Copy our module source code into the Drupal module folder.
134-
mkdir -p drupal/web/modules/contrib/os2forms_fasit
135-
cp -r os2forms_fasit.* composer.json src drupal/web/modules/contrib/os2forms_fasit
136-
# Add our module as a composer repository.
137-
composer --no-interaction --working-dir=drupal config repositories.os2forms/os2forms_fasit path web/modules/contrib/os2forms_fasit
138-
# Restore Drupal composer repository.
139-
composer --no-interaction --working-dir=drupal config repositories.drupal composer https://packages.drupal.org/8
140-
141-
composer --no-interaction --working-dir=drupal config --no-plugins allow-plugins.cweagans/composer-patches true
142-
composer --no-interaction --working-dir=drupal config --no-plugins allow-plugins.zaporylie/composer-drupal-optimizations true
143-
composer --no-interaction --working-dir=drupal config --no-plugins allow-plugins.simplesamlphp/composer-module-installer true
144-
# @see https://getcomposer.org/doc/03-cli.md#modifying-extra-values
145-
composer --no-interaction --working-dir=drupal config --no-plugins --json extra.enable-patching true
117+
./scripts/code-analysis
146118
147-
# Require our module.
148-
composer --no-interaction --working-dir=drupal require 'os2forms/os2forms_fasit:*'
119+
coding-standards-markdown:
120+
name: Markdown coding standards
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@master
149125

150-
# Check code
151-
composer --no-interaction --working-dir=drupal require --dev drupal/core-dev
152-
cd drupal/web/modules/contrib/os2forms_fasit
153-
# Remove our non-dev dependencies to prevent duplicated Drupal installation
154-
# PHP Fatal error: Cannot redeclare drupal_get_filename() (previously declared in /home/runner/work/os2forms_fasit/os2forms_fasit/drupal/web/modules/contrib/os2forms_fasit/vendor/drupal/core/includes/bootstrap.inc:190) in /home/runner/work/os2forms_fasit/os2forms_fasit/drupal/web/core/includes/bootstrap.inc on line 190
155-
# Use sed to remove the "require" property in composer.json
156-
sed -i '/^\s*"require":/,/^\s*}/d' composer.json
157-
composer --no-interaction install
158-
composer code-analysis
126+
- name: Coding standards
127+
run: |
128+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
/vendor/
22
composer.lock
3-
/node_modules/
4-
yarn.lock

.markdownlint.jsonc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
4+
"line-length": {
5+
"line_length": 120,
6+
"code_blocks": false,
7+
"tables": false
8+
},
9+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
10+
"no-duplicate-heading": {
11+
"siblings_only": true
12+
}
13+
}

.markdownlintrc

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

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ about writing changes to this log.
77

88
## [Unreleased]
99

10+
* [PR-7](https://github.com/itk-dev/os2forms_fasit/pull/7)
11+
Added support for os2web_key
12+
1013
## [1.0.2] 2024-04-22
1114

12-
- Fixed `Content-Type` header.
15+
* Fixed `Content-Type` header.
1316

1417
## [1.0.1] 2024-04-04
1518

16-
- Fixed queue install configuration.
19+
* Fixed queue install configuration.
1720

1821
## [1.0.0]
1922

20-
- Initial module base.
23+
* Initial module base.
2124

2225
[Unreleased]: https://github.com/itk-dev/os2forms_fasit/compare/1.0.1...HEAD
2326
[1.0.1]: https://github.com/itk-dev/os2forms_fasit/compare/1.0.0...1.0.1

README.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
11
# OS2Forms Fasit
22

3-
Adds [Fasit Schultz](https://schultz.dk/loesninger/schultz-fasit/)
4-
handler for archiving purposes.
3+
Adds [Fasit Schultz](https://schultz.dk/loesninger/schultz-fasit/) handler for archiving purposes.
54

65
## Installation
76

8-
```sh
7+
```shell
98
composer require os2forms/os2forms_fasit
109
vendor/bin/drush pm:enable os2forms_fasit
1110
```
1211

1312
## Settings
1413

15-
Configure Fasit API `base url` and a way of getting
16-
certificate on `/admin/os2forms_fasit/settings`.
14+
Go to `/admin/os2forms_fasit/settings` and configure the module.
1715

1816
### Certificate
1917

20-
The certificate must be in `pem` or `cer` format and
21-
must be whitelisted by Fasit Schultz.
22-
For this the certificate thumbprint,
23-
in lowercase and without colons, is needed.
18+
The certificate must be in `pem` or `cer` format and must be whitelisted by Fasit Schultz. For this the certificate
19+
thumbprint, in lowercase and without colons, is needed.
20+
2421
To get the thumbprint in the correct format from the command line run
2522

26-
```sh
23+
```shell
2724
openssl x509 -in SOME_CERTIFICATE.pem -noout -fingerprint | cut -d= -f2 | sed 's/://g' | tr '[:upper:]' '[:lower:]'
2825
```
2926

30-
Example output
27+
Example output:
3128

32-
```sh
29+
```shell
3330
6acb261f393172d87fa3997cec86569759a8528a
3431
```
3532

3633
## Queue
3734

38-
Archiving is done via an
39-
[Advanced Queue](https://www.drupal.org/project/advancedqueue)
40-
called `fasit_queue`.
35+
Archiving is done via an [Advanced Queue](https://www.drupal.org/project/advancedqueue) called `fasit_queue`.
4136

4237
The queue should be processed with `drush`:
4338

44-
```sh
39+
```shell
4540
drush advancedqueue:queue:process fasit_queue
4641
```
4742

4843
List the queue (and all other queues) with
4944

50-
```sh
45+
```shell
5146
drush advancedqueue:queue:list
5247
```
5348

@@ -64,21 +59,33 @@ Consider running the queue via a cronjob.
6459

6560
## Coding standards
6661

67-
Check coding standards:
62+
Our coding are checked by GitHub Actions (cf. [.github/workflows/pr.yml](.github/workflows/pr.yml)). Use the commands
63+
below to run the checks locally.
6864

69-
```sh
70-
// PHP CS Fixer
71-
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
72-
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check
65+
### PHP
7366

74-
// Markdownlint
75-
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app install
76-
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app coding-standards-check
67+
```shell
68+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install
69+
# Fix (some) coding standards issues
70+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply
71+
# Check that code adheres to the coding standards
72+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check
7773
```
7874

79-
Apply coding standards:
75+
### Markdown
76+
77+
```shell
78+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix
79+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
80+
```
81+
82+
## Code analysis
83+
84+
We use [PHPStan](https://phpstan.org/) for static code analysis.
85+
86+
Running statis code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the
87+
analysis:
8088

8189
```shell
82-
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply
83-
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app coding-standards-apply
90+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm ./scripts/code-analysis
8491
```

composer.json

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
11
{
22
"name": "os2forms/os2forms_fasit",
33
"description": "OS2Forms Fasit integration",
4-
"type": "drupal-module",
54
"license": "MIT",
5+
"type": "drupal-module",
66
"authors": [
77
{
88
"name": "Jeppe Kuhlmann Andersen",
99
"email": "[email protected]"
1010
}
1111
],
12-
"minimum-stability": "dev",
13-
"prefer-stable": true,
14-
"repositories": [
15-
{
16-
"type": "composer",
17-
"url": "https://packages.drupal.org/8"
18-
}
19-
],
2012
"require": {
2113
"php": "^8.1",
2214
"ext-dom": "*",
2315
"drupal/advancedqueue": "^1.0",
2416
"drupal/webform": "^6.1",
2517
"os2forms/os2forms": "^3.13",
18+
"os2web/os2web_key": "dev-os2web_key",
2619
"symfony/options-resolver": "^5.4 || ^6.0"
2720
},
2821
"require-dev": {
2922
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
3023
"drupal/coder": "^8.3",
31-
"mglaman/drupal-check": "^1.4"
24+
"ergebnis/composer-normalize": "^2.42",
25+
"mglaman/phpstan-drupal": "^1.2",
26+
"phpstan/extension-installer": "^1.3",
27+
"phpstan/phpstan-deprecation-rules": "^1.1"
28+
},
29+
"repositories": [
30+
{
31+
"type": "vcs",
32+
"url": "https://github.com/itk-dev/os2web_key"
33+
},
34+
{
35+
"type": "composer",
36+
"url": "https://packages.drupal.org/8"
37+
}
38+
],
39+
"minimum-stability": "dev",
40+
"prefer-stable": true,
41+
"config": {
42+
"allow-plugins": {
43+
"cweagans/composer-patches": true,
44+
"dealerdirect/phpcodesniffer-composer-installer": true,
45+
"ergebnis/composer-normalize": true,
46+
"phpstan/extension-installer": true,
47+
"simplesamlphp/composer-module-installer": true,
48+
"zaporylie/composer-drupal-optimizations": true
49+
},
50+
"sort-packages": true
3251
},
3352
"scripts": {
34-
"code-analysis/drupal-check": [
35-
"drupal-check --deprecations --analysis --exclude-dir='vendor' *.* src"
36-
],
37-
"code-analysis": [
38-
"@code-analysis/drupal-check"
53+
"coding-standards-apply": [
54+
"@coding-standards-apply/phpcs"
3955
],
40-
"coding-standards-check/phpcs": [
41-
"vendor/bin/phpcs --standard=phpcs.xml.dist"
56+
"coding-standards-apply/phpcs": [
57+
"phpcbf --standard=phpcs.xml.dist"
4258
],
4359
"coding-standards-check": [
4460
"@coding-standards-check/phpcs"
4561
],
46-
"coding-standards-apply/phpcs": [
47-
"vendor/bin/phpcbf --standard=phpcs.xml.dist"
48-
],
49-
"coding-standards-apply": [
50-
"@coding-standards-apply/phpcs"
62+
"coding-standards-check/phpcs": [
63+
"phpcs --standard=phpcs.xml.dist"
5164
]
52-
},
53-
"config": {
54-
"allow-plugins": {
55-
"dealerdirect/phpcodesniffer-composer-installer": true,
56-
"zaporylie/composer-drupal-optimizations": true,
57-
"cweagans/composer-patches": true,
58-
"simplesamlphp/composer-module-installer": true
59-
}
6065
}
6166
}

drush.services.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
Drupal\os2forms_fasit\Drush\Commands\FasitTestCommands:
3+
arguments:
4+
- '@Drupal\os2forms_fasit\Helper\FasitHelper'
5+
tags:
6+
- { name: drush.command }

os2forms_fasit.info.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ description: 'Fasit integration'
44
package: OS2Forms
55
core_version_requirement: ^9 || ^10
66
dependencies:
7-
- drupal:webform
87
- drupal:advancedqueue
8+
- drupal:webform
99
- os2forms:os2forms_attachment
10+
- os2web_key:os2web_key
11+
1012
configure: os2forms_fasit.admin.settings

os2forms_fasit.services.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
services:
22
Drupal\os2forms_fasit\Helper\Settings:
33
arguments:
4-
- "@keyvalue"
5-
6-
Drupal\os2forms_fasit\Helper\CertificateLocatorHelper:
7-
arguments:
8-
- "@Drupal\\os2forms_fasit\\Helper\\Settings"
4+
- "@config.factory"
5+
- "@key.repository"
96

107
Drupal\os2forms_fasit\Helper\FasitHelper:
118
arguments:
129
- '@http_client'
1310
- '@entity_type.manager'
1411
- "@Drupal\\os2forms_fasit\\Helper\\Settings"
15-
- "@Drupal\\os2forms_fasit\\Helper\\CertificateLocatorHelper"
12+
- "@file_system"

0 commit comments

Comments
 (0)