-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
320 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
on: pull_request | ||
name: Review | ||
jobs: | ||
changelog: | ||
runs-on: ubuntu-latest | ||
name: Changelog should be updated | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Git fetch | ||
run: git fetch | ||
|
||
- name: Check that changelog has been updated. | ||
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 | ||
|
||
test-composer-files: | ||
name: Validate composer | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: [ '8.1' ] | ||
dependency-version: [ prefer-lowest, prefer-stable ] | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: json | ||
coverage: none | ||
tools: composer:v2 | ||
# https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Validate composer files | ||
run: | | ||
composer validate --strict composer.json | ||
# Check that dependencies resolve. | ||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction | ||
php-coding-standards: | ||
name: PHP coding standards | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: [ '8.1' ] | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: json | ||
coverage: none | ||
tools: composer:v2 | ||
# https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install Dependencies | ||
run: | | ||
composer install --no-interaction --no-progress | ||
- name: PHPCS | ||
run: | | ||
composer coding-standards-check/phpcs | ||
php-code-analysis: | ||
name: PHP code analysis | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: [ '8.1' ] | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: json | ||
coverage: none | ||
tools: composer:v2 | ||
# https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Code analysis | ||
run: | | ||
./scripts/code-analysis | ||
markdownlint: | ||
runs-on: ubuntu-latest | ||
name: markdownlint | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- name: Cache yarn packages | ||
uses: actions/cache@v2 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Yarn install | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
- run: yarn install | ||
- name: markdownlint | ||
run: yarn coding-standards-check/markdownlint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
composer.lock | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- markdownlint-disable MD024 --> | ||
# OS2 Audit Change Log | ||
|
||
All notable changes to this project should be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
See ["how do I make a good changelog record?"](https://keepachangelog.com/en/1.0.0/#how) | ||
before starting to add changes. Use example [placed in the end of the page](#example-of-change-log-record) | ||
|
||
## [Unreleased] | ||
|
||
- First version of the module | ||
|
||
[Unreleased]: https://github.com/OS2web/os2web_audit/compare/develop...HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"name": "os2web/os2web_audit", | ||
"type": "drupal-module", | ||
"description": "Drupal OS2 module that provides audit logging for Danish Municipalities", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"license": "EUPL-1.2", | ||
"repositories": { | ||
"drupal": { | ||
"type": "composer", | ||
"url": "https://packages.drupal.org/8" | ||
}, | ||
"assets": { | ||
"type": "composer", | ||
"url": "https://asset-packagist.org" | ||
} | ||
}, | ||
"require": { | ||
"php": "^8.1" | ||
}, | ||
"require-dev": { | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", | ||
"drupal/coder": "^8.3", | ||
"mglaman/phpstan-drupal": "^1.1", | ||
"phpstan/extension-installer": "^1.3", | ||
"phpstan/phpstan-deprecation-rules": "^1.1", | ||
"phpunit/phpunit": "^9.5" | ||
}, | ||
"extra" : { | ||
"composer-exit-on-patch-failure": false, | ||
"enable-patching" : true, | ||
"patches": { | ||
} | ||
}, | ||
"scripts": { | ||
"code-analysis/phpstan": [ | ||
"phpstan analyse" | ||
], | ||
"code-analysis": [ | ||
"@code-analysis/phpstan" | ||
], | ||
"coding-standards-check/phpcs": [ | ||
"phpcs --standard=phpcs.xml.dist" | ||
], | ||
"coding-standards-check": [ | ||
"@coding-standards-check/phpcs" | ||
], | ||
"coding-standards-apply/phpcs": [ | ||
"phpcbf --standard=phpcs.xml.dist" | ||
], | ||
"coding-standards-apply": [ | ||
"@coding-standards-apply/phpcs" | ||
] | ||
}, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"phpstan/extension-installer": true, | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"license": "UNLICENSED", | ||
"private": true, | ||
"devDependencies": { | ||
"markdownlint-cli": "^0.32.2" | ||
}, | ||
"scripts": { | ||
"coding-standards-check/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md'", | ||
"coding-standards-check": "yarn coding-standards-check/markdownlint", | ||
"coding-standards-apply/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md' --fix", | ||
"coding-standards-apply": "yarn coding-standards-apply/markdownlint" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="PHP_CodeSniffer"> | ||
<description>OS2Forms PHP Code Sniffer configuration</description> | ||
|
||
<file>.</file> | ||
<exclude-pattern>vendor/</exclude-pattern> | ||
<exclude-pattern>node_modules/</exclude-pattern> | ||
<!-- Exclude our copy of the abandoned https://www.drupal.org/project/webform_embed --> | ||
<exclude-pattern>modules/webform_embed/</exclude-pattern> | ||
<!-- Exclude our copy of the abandoned https://www.drupal.org/project/field_color --> | ||
<exclude-pattern>modules/os2forms_webform_maps/modules/field_color/</exclude-pattern> | ||
|
||
<!-- Show progress of the run --> | ||
<arg value="p"/> | ||
|
||
<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/> | ||
<config name="drupal_core_version" value="9"/> | ||
|
||
|
||
<rule ref="Drupal"> | ||
<!-- We want to be able to use "package" and "version" in our custom modules --> | ||
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/> | ||
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/> | ||
</rule> | ||
|
||
<rule ref="DrupalPractice"/> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
parameters: | ||
level: 6 | ||
paths: | ||
- modules/os2forms_digital_post/ | ||
excludePaths: | ||
# @see https://github.com/mglaman/drupal-check/issues/261#issuecomment-1030141772/ | ||
- vendor | ||
- '*/node_modules/*' | ||
ignoreErrors: | ||
- | ||
# Ignore some weird errors reported by PHPStan | ||
# @todo Investigate further | ||
messages: | ||
# These errors may be related to classes that don't add anything to their base class (e.g. `class BrugerFlerRelationType extends FlerRelationType {}`) | ||
- '#expects (DataGovDk\\Model\\Core\\)(.+)(\|null)?, \1\2\\\2AType given.#' | ||
- '#expects (DigitalPost\\MeMo\\)(.+)(\|null)?, \1\2\\\2AType given.#' | ||
- '#expects (Oio\\(?:.+\\)*)(.+)(\|null)?, \1\2Type given.#' | ||
- '#expects array<(DigitalPost\\MeMo\\)(.+)>(\|null)?, array<int, \1\2\\\2AType> given.#' | ||
- '#should return (DigitalPost\\MeMo\\)(.+) but returns \1\2\\\2AType.#' | ||
- '#should return (Oio\\Fjernprint\\)(.+) but returns \1\2Type.#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
script_dir=$(pwd) | ||
module_name=$(basename "$script_dir") | ||
drupal_dir=vendor/drupal-module-code-analysis | ||
# Relative to $drupal_dir | ||
module_path=web/modules/contrib/$module_name | ||
|
||
cd "$script_dir" || exit | ||
|
||
drupal_composer() { | ||
composer --working-dir="$drupal_dir" --no-interaction "$@" | ||
} | ||
|
||
# Create new Drupal 9 project | ||
if [ ! -f "$drupal_dir/composer.json" ]; then | ||
composer --no-interaction create-project drupal/recommended-project:^9 "$drupal_dir" | ||
fi | ||
# Copy our code into the modules folder | ||
mkdir -p "$drupal_dir/$module_path" | ||
# https://stackoverflow.com/a/15373763 | ||
rsync --archive --compress . --filter=':- .gitignore' --exclude "$drupal_dir" --exclude .git "$drupal_dir/$module_path" | ||
|
||
drupal_composer config minimum-stability dev | ||
|
||
# Allow ALL plugins | ||
# https://getcomposer.org/doc/06-config.md#allow-plugins | ||
drupal_composer config --no-plugins allow-plugins true | ||
|
||
drupal_composer require wikimedia/composer-merge-plugin | ||
drupal_composer config extra.merge-plugin.include "$module_path/composer.json" | ||
# https://www.drupal.org/project/drupal/issues/3220043#comment-14845434 | ||
drupal_composer require --dev symfony/phpunit-bridge | ||
|
||
# Run PHPStan | ||
(cd "$drupal_dir" && vendor/bin/phpstan --configuration="$module_path/phpstan.neon") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters