Skip to content

Commit 7e35a12

Browse files
authored
Merge pull request #13 from itk-dev/feature/os2web_key
os2web_key
2 parents acf22ed + 721fdc4 commit 7e35a12

16 files changed

+442
-79
lines changed

.github/workflows/pr.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php-versions: [ '8.1' ]
26+
php-versions: [ '8.3' ]
2727
dependency-version: [ prefer-lowest, prefer-stable ]
2828
steps:
2929
- uses: actions/checkout@master
@@ -39,7 +39,7 @@ jobs:
3939
id: composer-cache
4040
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
4141
- name: Cache dependencies
42-
uses: actions/cache@v2
42+
uses: actions/cache@v4
4343
with:
4444
path: ${{ steps.composer-cache.outputs.dir }}
4545
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -49,13 +49,16 @@ jobs:
4949
composer validate --strict composer.json
5050
# Check that dependencies resolve.
5151
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
52+
- name: Check that composer file is normalized
53+
run: |
54+
composer normalize --dry-run
5255
5356
php-coding-standards:
5457
name: PHP coding standards
5558
runs-on: ubuntu-latest
5659
strategy:
5760
matrix:
58-
php-versions: [ '8.1' ]
61+
php-versions: [ '8.3' ]
5962
steps:
6063
- uses: actions/checkout@master
6164
- name: Setup PHP, with composer and extensions
@@ -70,7 +73,7 @@ jobs:
7073
id: composer-cache
7174
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
7275
- name: Cache dependencies
73-
uses: actions/cache@v2
76+
uses: actions/cache@v4
7477
with:
7578
path: ${{ steps.composer-cache.outputs.dir }}
7679
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor/

.markdownlintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// @see https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
3+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
4+
"MD013": {
5+
// Exclude code blocks
6+
"code_blocks": false,
7+
"line_length": 120
8+
},
9+
10+
// Prevent complaining on duplicated headings in CHANGELOG.md
11+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
12+
"MD024": {
13+
"siblings_only": true
14+
}
15+
}
16+
17+
// Local Variables:
18+
// mode: json
19+
// End:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
* [PR-13](https://github.com/OS2web/os2web_datalookup/pull/13)
11+
Added support for [os2web_key](https://github.com/OS2web/os2web_key)
12+
1013
## [2.0.4] 2025-01-29
1114

1215
* Ensure postal code is only added to city if `CVRAdresse_postdistrikt` is not set.

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ if ($cprPlugin->isReady()) {
7474

7575
## New services/features
7676

77-
### Datafordeler integration (https://datafordeler.dk)
77+
### Datafordeler integration (<https://datafordeler.dk>)
7878

7979
In the scope of os2forms project already implemented light integration with
8080
Danmarks Adresseregister (DAR) via fetching data for form elements autocomplete.
@@ -98,3 +98,37 @@ will be exposed for third persons.
9898
To avoid/prevent this behavior, we recommend use `Config ignore` module, where
9999
you can add all settings you do not want to export/import via the configuration
100100
management system.
101+
102+
## Coding standards
103+
104+
Our coding are checked by GitHub Actions (cf.
105+
[.github/workflows/pr.yml](.github/workflows/pr.yml)). Use the commands below to
106+
run the checks locally.
107+
108+
### PHP
109+
110+
```shell
111+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install
112+
# Fix (some) coding standards issues
113+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-apply
114+
# Check that code adheres to the coding standards
115+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check
116+
```
117+
118+
### Markdown
119+
120+
```shell
121+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix
122+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
123+
```
124+
125+
## Code analysis
126+
127+
We use [PHPStan](https://phpstan.org/) for static code analysis.
128+
129+
Running statis code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the
130+
analysis:
131+
132+
```shell
133+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis
134+
```

composer.json

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
22
"name": "os2web/os2web_datalookup",
3-
"type": "drupal-module",
43
"description": "Provides integration with Danish data lookup services such as Service platformen or Datafordeler.",
5-
"minimum-stability": "dev",
6-
"prefer-stable": true,
74
"license": "EUPL-1.2",
5+
"type": "drupal-module",
86
"require": {
9-
"ext-soap": "*"
7+
"ext-soap": "*",
8+
"os2web/os2web_key": "^1.0"
9+
},
10+
"require-dev": {
11+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
12+
"drupal/coder": "^8.3",
13+
"ergebnis/composer-normalize": "^2.45",
14+
"os2web/os2web_audit": "^0.1",
15+
"phpunit/phpunit": "^9.5"
1016
},
1117
"repositories": {
1218
"drupal": {
@@ -18,29 +24,27 @@
1824
"url": "https://asset-packagist.org"
1925
}
2026
},
21-
"require-dev": {
22-
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
23-
"drupal/coder": "^8.3",
24-
"phpunit/phpunit": "^9.5",
25-
"os2web/os2web_audit": "^0.1"
27+
"minimum-stability": "dev",
28+
"prefer-stable": true,
29+
"config": {
30+
"allow-plugins": {
31+
"dealerdirect/phpcodesniffer-composer-installer": true,
32+
"ergebnis/composer-normalize": true
33+
},
34+
"sort-packages": true
2635
},
2736
"scripts": {
28-
"coding-standards-check/phpcs": [
29-
"phpcs --standard=phpcs.xml.dist"
30-
],
31-
"coding-standards-check": [
32-
"@coding-standards-check/phpcs"
37+
"coding-standards-apply": [
38+
"@coding-standards-apply/phpcs"
3339
],
3440
"coding-standards-apply/phpcs": [
3541
"phpcbf --standard=phpcs.xml.dist"
3642
],
37-
"coding-standards-apply": [
38-
"@coding-standards-apply/phpcs"
43+
"coding-standards-check": [
44+
"@coding-standards-check/phpcs"
45+
],
46+
"coding-standards-check/phpcs": [
47+
"phpcs --standard=phpcs.xml.dist"
3948
]
40-
},
41-
"config": {
42-
"allow-plugins": {
43-
"dealerdirect/phpcodesniffer-composer-installer": true
44-
}
4549
}
4650
}

os2web_datalookup.info.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ type: module
33
description: 'Provides integration with Danish data lookup services such as Service platformen or Datafordeler.'
44
package: 'OS2web'
55
core_version_requirement: ^8 || ^9 || ^10
6+
67
dependencies:
78
- 'os2web:os2web_audit'
9+
- 'os2web_key:os2web_key'

os2web_datalookup.install

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ function os2web_datalookup_update_9003(): void {
3333
$config->set("pnumber_lookup.default_plugin", 'datafordeler_pnumber');
3434
$config->save();
3535
}
36+
37+
/**
38+
* Implements hook_update_N().
39+
*/
40+
function os2web_datalookup_update_9004() {
41+
\Drupal::service('module_installer')->install([
42+
'os2web_key',
43+
], TRUE);
44+
}

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
6+
ignoreErrors:
7+
- "#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ has parameter \\$[a-zA-Z0-9_]+ with no value type specified in iterable type array#"
8+
- "#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ return type has no value type specified in iterable type array#"
9+
- '#Unsafe usage of new static\(\).#'
10+
11+
# Local Variables:
12+
# mode: yaml
13+
# End:

scripts/code-analysis

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
script_dir=$(pwd)
3+
module_name=$(basename "$script_dir")
4+
drupal_dir=vendor/drupal-module-code-analysis
5+
# Relative to $drupal_dir
6+
module_path=web/modules/contrib/$module_name
7+
8+
cd "$script_dir" || exit
9+
10+
drupal_composer() {
11+
composer --working-dir="$drupal_dir" --no-interaction "$@"
12+
}
13+
14+
# # Create new Drupal 9 project
15+
# if [ ! -f "$drupal_dir/composer.json" ]; then
16+
# composer --no-interaction create-project drupal/recommended-project:^9 "$drupal_dir"
17+
# fi
18+
# # Copy our code into the modules folder
19+
20+
# # Clean up
21+
# rm -fr "${drupal_dir:?}/$module_path"
22+
23+
# # https://stackoverflow.com/a/15373763
24+
# # rsync --archive --compress . --filter=':- .gitignore' --exclude "$drupal_dir" --exclude .git "$drupal_dir/$module_path"
25+
26+
# # The rsync command in not available in itkdev/php8.1-fpm
27+
28+
# git config --global --add safe.directory /app
29+
# # Copy module files into module path
30+
# for f in $(git ls-files); do
31+
# mkdir -p "$drupal_dir/$module_path/$(dirname "$f")"
32+
# cp "$f" "$drupal_dir/$module_path/$f"
33+
# done
34+
35+
# drupal_composer config minimum-stability dev
36+
37+
# # Allow ALL plugins
38+
# # https://getcomposer.org/doc/06-config.md#allow-plugins
39+
# drupal_composer config --no-plugins allow-plugins true
40+
41+
# drupal_composer require wikimedia/composer-merge-plugin
42+
# drupal_composer config extra.merge-plugin.include "$module_path/composer.json"
43+
# # https://www.drupal.org/project/drupal/issues/3220043#comment-14845434
44+
# drupal_composer require --dev symfony/phpunit-bridge
45+
46+
# Run PHPStan
47+
(cd "$drupal_dir" && vendor/bin/phpstan --configuration="$module_path/phpstan.neon")

0 commit comments

Comments
 (0)