Skip to content

Commit

Permalink
Merge pull request #1 from OS2Forms/os2forms_get_organized
Browse files Browse the repository at this point in the history
Added module code
  • Loading branch information
jekuaitk authored Mar 29, 2023
2 parents e679d19 + b52728c commit 78e167d
Show file tree
Hide file tree
Showing 21 changed files with 1,484 additions and 1 deletion.
140 changes: 140 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
on: pull_request
name: PR 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: [ '7.4', '8.0', '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-check-coding-standards:
name: PHP - Check Coding Standards
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.4', '8.0', '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: 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: [ '7.4', '8.0', '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, gd
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: drupal-check
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:^9 --stability=dev drupal
# Copy our module source code into the Drupal module folder.
mkdir -p drupal/web/modules/contrib/os2forms_get_organized
cp -r os2forms_get_organized.* composer.json src drupal/web/modules/contrib/os2forms_get_organized
# Add our module as a composer repository.
composer --no-interaction --working-dir=drupal config repositories.os2forms/os2forms_get_organized path web/modules/contrib/os2forms_get_organized
# Restore Drupal composer repository.
composer --no-interaction --working-dir=drupal config repositories.drupal composer https://packages.drupal.org/8
composer --no-interaction --working-dir=drupal config --no-plugins allow-plugins.cweagans/composer-patches true
# @see https://getcomposer.org/doc/03-cli.md#modifying-extra-values
composer --no-interaction --working-dir=drupal config --no-plugins --json extra.enable-patching true
# Require our module.
composer --no-interaction --working-dir=drupal require 'os2forms/os2forms_get_organized:*'
# Check code
composer --no-interaction --working-dir=drupal require --dev drupal/core-dev
cd drupal/web/modules/contrib/os2forms_get_organized
# 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_get_organized/os2forms_get_organized/drupal/web/modules/contrib/os2forms_get_organized/vendor/drupal/core/includes/bootstrap.inc:190) in /home/runner/work/os2forms_get_organized/os2forms_get_organized/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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
composer.lock
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- markdownlint-disable MD024 -->
# Changelog

All notable changes to this project will be documented in this file.

See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information
about writing changes to this log.

## [Unreleased]

[Unreleased]: https://github.com/OS2Forms/os2forms_get_organized/
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# os2forms_get_organized
# OS2Forms GetOrganized

Adds [GetOrganized](https://www.getorganized.net/) handler for archiving purposes.

## Installation

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

## Settings

Set GetOrganized `username`, `password` and `base url`
on `/admin/os2forms_get_organized/settings`.

You can also test that the provided
details work on `/admin/os2forms_get_organized/settings`.

## Coding standards

Check coding standards:

```sh
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer install
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer coding-standards-check
```

Apply coding standards:

```shell
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer coding-standards-apply
docker run --rm --interactive --tty --volume ${PWD}:/app node:18 yarn --cwd /app coding-standards-apply
```
57 changes: 57 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "os2forms/os2forms_get_organized",
"description": "OS2Forms GetOrganized integration",
"type": "drupal-module",
"license": "MIT",
"authors": [
{
"name": "Jeppe Kuhlmann Andersen",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"itk-dev/getorganized-api-client-php": "^1.2",
"drupal/webform": "^6.1",
"drupal/advancedqueue": "^1.0",
"symfony/options-resolver": "^5.4"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"drupal/coder": "^8.3",
"mglaman/drupal-check": "^1.4"
},
"scripts": {
"code-analysis/drupal-check": [
"# @see https://github.com/mglaman/drupal-check/issues/261#issuecomment-1030141772 for details on exclude-dir value",
"drupal-check --deprecations --analysis --exclude-dir='vendor,*/Client/*' *.* src"
],
"code-analysis": [
"@code-analysis/drupal-check"
],
"coding-standards-check/phpcs": [
"vendor/bin/phpcs --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"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
langcode: da
status: true
dependencies: { }
id: get_organized_queue
label: 'Get Organized Queue'
backend: database
backend_configuration:
lease_time: 300
processor: cron
processing_time: 90
locked: false
10 changes: 10 additions & 0 deletions os2forms_get_organized.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'OS2Forms GetOrganized'
type: module
description: 'GetOrganized integration'
package: OS2Forms
core_version_requirement: ^9
dependencies:
- drupal:webform
- drupal:advancedqueue
- drupal:webform_entity_print_attachment
configure: os2forms_get_organized.admin.settings
5 changes: 5 additions & 0 deletions os2forms_get_organized.links.menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
os2forms_get_organized.admin.settings:
title: OS2Forms Get Organized
description: Configure the OS2Forms GetOrganized module
parent: system.admin_config_system
route_name: os2forms_get_organized.admin.settings
7 changes: 7 additions & 0 deletions os2forms_get_organized.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
os2forms_get_organized.admin.settings:
path: '/admin/os2forms_get_organized/settings'
defaults:
_form: '\Drupal\os2forms_get_organized\Form\SettingsForm'
_title: 'GetOrganized settings'
requirements:
_permission: 'administer site configuration'
9 changes: 9 additions & 0 deletions os2forms_get_organized.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
Drupal\os2forms_get_organized\Helper\Settings:
arguments:
- "@keyvalue"

Drupal\os2forms_get_organized\Helper\ArchiveHelper:
arguments:
- '@entity_type.manager'
- '@Drupal\os2forms_get_organized\Helper\Settings'
23 changes: 23 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>The coding standard.</description>

<file>.</file>

<exclude-pattern>vendor/</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">
<!-- <exclude name="Drupal.Files.TxtFileLineLength.TooLong"/> -->
<!-- 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>
9 changes: 9 additions & 0 deletions src/Exception/ArchivingMethodException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Drupal\os2forms_get_organized\Exception;

/**
* Archiving method Exception.
*/
class ArchivingMethodException extends \Exception {
}
9 changes: 9 additions & 0 deletions src/Exception/CitizenArchivingException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Drupal\os2forms_get_organized\Exception;

/**
* Citizen archiving Exception.
*/
class CitizenArchivingException extends \Exception {
}
9 changes: 9 additions & 0 deletions src/Exception/GetOrganizedCaseIdException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Drupal\os2forms_get_organized\Exception;

/**
* GetOrganized case id Exception.
*/
class GetOrganizedCaseIdException extends \Exception {
}
9 changes: 9 additions & 0 deletions src/Exception/GetOrganizedQueueException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Drupal\os2forms_get_organized\Exception;

/**
* GetOrganized queue Exception.
*/
class GetOrganizedQueueException extends \Exception {
}
10 changes: 10 additions & 0 deletions src/Exception/InvalidSettingException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_get_organized\Exception;

/**
* Invalid setting exception.
*/
class InvalidSettingException extends \Exception {

}
Loading

0 comments on commit 78e167d

Please sign in to comment.