Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 14 additions & 49 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,9 @@ jobs:
composer validate --strict composer.json
# Check that dependencies resolve.
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

markdown-coding-standards:
name: Yarn - Check Coding Standards (Node ${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '20' ]
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: |
yarn install
yarn coding-standards-check
- name: Check that composer file is normalized
run: |
composer normalize --dry-run

php-check-coding-standards:
name: PHP - Check Coding Standards
Expand Down Expand Up @@ -125,39 +112,17 @@ jobs:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: drupal-check
- name: Code analysis
run: |
# We need a Drupal project to run drupal-check (cf. https://github.com/mglaman/drupal-check#usage)
# Install Drupal
composer --no-interaction create-project drupal/recommended-project:^10 drupal
# Copy our module source code into the Drupal module folder.
mkdir -p drupal/web/modules/contrib/os2forms_fasit
cp -r os2forms_fasit.* composer.json src drupal/web/modules/contrib/os2forms_fasit

composer --working-dir=drupal --no-interaction config minimum-stability dev
./scripts/code-analysis

# Allow all plugins
composer --working-dir=drupal config --no-plugins allow-plugins true

# Add our module as a composer repository.
composer --working-dir=drupal --no-interaction config --append repositories.os2forms/os2forms_fasit path web/modules/contrib/os2forms_fasit
# Restore Drupal composer repository.
# composer --working-dir=drupal --no-interaction config --append repositories.drupal composer https://packages.drupal.org/8

# Make Drupal 10 compatible
composer --working-dir=drupal --no-interaction require psr/http-message:^1.0
composer --working-dir=drupal --no-interaction require 'mglaman/composer-drupal-lenient'
composer --working-dir=drupal config --no-plugins --merge --json extra.drupal-lenient.allowed-list '["drupal/coc_forms_auto_export", "drupal/webform_node_element"]'

# Require our module.
composer --working-dir=drupal --no-interaction require 'os2forms/os2forms_fasit:*'
coding-standards-markdown:
name: Markdown coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

# Check code
composer --working-dir=drupal --no-interaction require --dev drupal/core-dev
cd drupal/web/modules/contrib/os2forms_fasit
# Remove our non-dev dependencies to prevent duplicated Drupal installation
# 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
# Use sed to remove the "require" property in composer.json
sed -i '/^\s*"require":/,/^\s*}/d' composer.json
composer --no-interaction install
composer code-analysis
- name: Coding standards
run: |
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/vendor/
composer.lock
/node_modules/
yarn.lock
13 changes: 13 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"default": true,
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
"line-length": {
"line_length": 120,
"code_blocks": false,
"tables": false
},
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"no-duplicate-heading": {
"siblings_only": true
}
}
9 changes: 0 additions & 9 deletions .markdownlintrc

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ about writing changes to this log.

## [Unreleased]

* [PR-7](https://github.com/itk-dev/os2forms_fasit/pull/7)
Added support for os2web_key

## [1.2.0] 2024-09-24

* Upgrade `os2forms/os2forms` requirement.
Expand Down
63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,48 @@
# OS2Forms Fasit

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

## Installation

```sh
```shell
composer require os2forms/os2forms_fasit
vendor/bin/drush pm:enable os2forms_fasit
```

## Settings

Configure Fasit API `base url` and a way of getting
certificate on `/admin/os2forms_fasit/settings`.
Go to `/admin/os2forms_fasit/settings` and configure the module.

### Certificate

The certificate must be in `pem` or `cer` format and
must be whitelisted by Fasit Schultz.
For this the certificate thumbprint,
in lowercase and without colons, is needed.
The certificate must be in `pem` or `cer` format and must be whitelisted by Fasit Schultz. For this the certificate
thumbprint, in lowercase and without colons, is needed.

To get the thumbprint in the correct format from the command line run

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

Example output
Example output:

```sh
```shell
6acb261f393172d87fa3997cec86569759a8528a
```

## Queue

Archiving is done via an
[Advanced Queue](https://www.drupal.org/project/advancedqueue)
called `fasit_queue`.
Archiving is done via an [Advanced Queue](https://www.drupal.org/project/advancedqueue) called `fasit_queue`.

The queue should be processed with `drush`:

```sh
```shell
drush advancedqueue:queue:process fasit_queue
```

List the queue (and all other queues) with

```sh
```shell
drush advancedqueue:queue:list
```

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

## Coding standards

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

```sh
// PHP CS Fixer
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer install
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-check
### PHP

// Markdownlint
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app install
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app coding-standards-check
```shell
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install
# Fix (some) coding standards issues
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-apply
# Check that code adheres to the coding standards
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check
```

Apply coding standards:
### Markdown

```shell
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
```

## Code analysis

We use [PHPStan](https://phpstan.org/) for static code analysis.

Running static code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the
analysis:

```shell
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-apply
docker run --rm --interactive --tty --volume ${PWD}:/app node:20 yarn --cwd /app coding-standards-apply
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis
```
63 changes: 32 additions & 31 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
{
"name": "os2forms/os2forms_fasit",
"description": "OS2Forms Fasit integration",
"type": "drupal-module",
"license": "MIT",
"type": "drupal-module",
"authors": [
{
"name": "Jeppe Kuhlmann Andersen",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"php": "^8.3",
"ext-dom": "*",
"drupal/advancedqueue": "^1.0",
"drupal/webform": "^6.1",
"os2forms/os2forms": "^3.16",
"os2web/os2web_key": "^1.0",
"symfony/options-resolver": "^5.4 || ^6.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"drupal/coder": "^8.3",
"mglaman/drupal-check": "^1.4"
"ergebnis/composer-normalize": "^2.42",
"mglaman/phpstan-drupal": "^1.2",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"mglaman/composer-drupal-lenient": true,
"phpstan/extension-installer": true,
"simplesamlphp/composer-module-installer": true,
"zaporylie/composer-drupal-optimizations": true
},
"sort-packages": true
},
"scripts": {
"code-analysis/drupal-check": [
"drupal-check --deprecations --analysis --exclude-dir='vendor' *.* src"
],
"code-analysis": [
"@code-analysis/drupal-check"
"coding-standards-apply": [
"@coding-standards-apply/phpcs"
],
"coding-standards-check/phpcs": [
"vendor/bin/phpcs --standard=phpcs.xml.dist"
"coding-standards-apply/phpcs": [
"phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-check": [
"@coding-standards-check/phpcs"
],
"coding-standards-apply/phpcs": [
"vendor/bin/phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-apply": [
"@coding-standards-apply/phpcs"
"coding-standards-check/phpcs": [
"phpcs --standard=phpcs.xml.dist"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"zaporylie/composer-drupal-optimizations": true,
"cweagans/composer-patches": true,
"simplesamlphp/composer-module-installer": true,
"mglaman/composer-drupal-lenient": true
}
}
}
6 changes: 6 additions & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
Drupal\os2forms_fasit\Drush\Commands\FasitTestCommands:
arguments:
- '@Drupal\os2forms_fasit\Helper\FasitHelper'
tags:
- { name: drush.command }
4 changes: 3 additions & 1 deletion os2forms_fasit.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ description: 'Fasit integration'
package: OS2Forms
core_version_requirement: ^9 || ^10
dependencies:
- drupal:webform
- drupal:advancedqueue
- drupal:webform
- os2forms:os2forms_attachment
- os2web_key:os2web_key

configure: os2forms_fasit.admin.settings
15 changes: 15 additions & 0 deletions os2forms_fasit.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/**
* @file
* Install hooks for os2forms_fasit.
*/

/**
* Implements hook_update_N().
*/
function os2forms_fasit_update_9001(): void {
\Drupal::service('module_installer')->install([
'key',
], TRUE);
}
9 changes: 3 additions & 6 deletions os2forms_fasit.services.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
services:
Drupal\os2forms_fasit\Helper\Settings:
arguments:
- "@keyvalue"

Drupal\os2forms_fasit\Helper\CertificateLocatorHelper:
arguments:
- "@Drupal\\os2forms_fasit\\Helper\\Settings"
- "@config.factory"
- "@key.repository"

Drupal\os2forms_fasit\Helper\FasitHelper:
arguments:
- '@http_client'
- '@entity_type.manager'
- "@Drupal\\os2forms_fasit\\Helper\\Settings"
- "@Drupal\\os2forms_fasit\\Helper\\CertificateLocatorHelper"
- "@file_system"
13 changes: 0 additions & 13 deletions package.json

This file was deleted.

Loading
Loading