Skip to content
Merged
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
123 changes: 33 additions & 90 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,122 +18,65 @@ jobs:
- 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:
validate-composer-files:
name: Validate composer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate composer files
run: |
# Note that we don't use the --strict flag on validate due to the
# package drupal/config_entity_revisions 2.0.x-dev being considered a
# version cf.
# https://getcomposer.org/doc/articles/versions.md#branches
docker compose run --rm php composer validate composer.json
- name: Check that composer file is normalized
run: |
docker compose run --rm php composer install
docker compose run --rm php composer normalize --dry-run

test-composer-files:
name: Test composer files
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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer files
- uses: actions/checkout@v4
- name: Check that dependencies resolve.
run: |
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
composer validate --strict composer.json
# Check that dependencies resolve.
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
# Clean up before update (cf. https://www.drupal.org/project/simplesamlphp_auth/issues/3350773)
rm -fr vendor/
docker compose run --rm php 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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
composer install --no-interaction --no-progress
docker compose run --rm php composer install
- name: PHPCS
run: |
composer coding-standards-check/phpcs
docker compose run --rm php 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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- uses: actions/checkout@v4
- name: Code analysis
run: |
./scripts/code-analysis

markdownlint:
coding-standards-markdown:
name: Markdown coding standards
runs-on: ubuntu-latest
name: markdownlint
steps:
- name: Checkout
uses: actions/checkout@v4
- 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@v4
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

- name: Coding standards
run: |
docker compose run --rm markdownlint markdownlint '**/*.md'
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
composer.lock
vendor

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
}
}
2 changes: 2 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files
vendor/
18 changes: 0 additions & 18 deletions .markdownlintrc

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- [PR-168](https://github.com/OS2Forms/os2forms/pull/168)
Cleaned up code
- [PR-166](https://github.com/OS2Forms/os2forms/pull/166)
- Fix digital post commands
- Updated versions in GitHub Actions `uses` steps
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,38 @@ run the checks locally.
### PHP

```sh
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check

docker compose pull
docker compose run --rm php composer install
# Fix (some) coding standards issues.
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply
docker compose run --rm php composer coding-standards-apply
docker compose run --rm php composer coding-standards-check
```

> [!TIP]
> If the `composer install` commands fails with
>
> > Unable to install module simplesamlphp/simplesamlphp-assets-base, package name must be on the form "VENDOR/simplesamlphp-module-MODULENAME".
>
> you can remove the `vendor` folder and rerun the `composer install` command (cf.
> <https://www.drupal.org/project/simplesamlphp_auth/issues/3350773>).

Comment on lines +131 to +138
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

### Markdown

```sh
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn install
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-check/markdownlint

# Fix (some) coding standards issues.
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-apply/markdownlint
docker compose pull
docker compose run --rm markdownlint markdownlint '**/*.md' --fix
docker compose run --rm markdownlint markdownlint '**/*.md'
```

## Code analysis

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

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

```sh
./scripts/code-analysis
```shell
docker compose run --rm php ./scripts/code-analysis
```

**Note**: Currently the code analysis is only run on the `os2forms_digital_post` sub-module (cf. [`phpstan.neon`](./phpstan.neon)).
17 changes: 17 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://hub.docker.com/r/ddev/ddev-php-base

services:
php:
image: ddev/ddev-php-base
profiles:
- dev
working_dir: /app
volumes:
- ./:/app

markdownlint:
image: itkdev/markdownlint
# The default working dir is `/md`
working_dir: /app
volumes:
- ./:/app
Loading