Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
98 changes: 25 additions & 73 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,102 +18,54 @@ 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
strategy:
matrix:
php-versions: [ '8.3' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@v4
- 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
run: |
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
# The --strict flag on validate has been removed 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
composer validate composer.json
# Check that dependencies resolve.
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
# 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: |
composer normalize --dry-run
docker compose run --rm php composer install
docker compose run --rm php composer normalize --dry-run

php-coding-standards:
name: PHP coding standards
test-composer-files:
name: Test composer files
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.3' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@v4
- name: Check that dependencies resolve.
run: |
# 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
steps:
- uses: actions/checkout@v4
- 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: 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.3' ]
steps:
- uses: actions/checkout@v4
- 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: Code analysis
run: |
./scripts/code-analysis
Expand All @@ -127,4 +79,4 @@ jobs:

- name: Coding standards
run: |
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md'
docker compose run --rm markdownlint markdownlint '**/*.md'
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,27 @@ run the checks locally.
### PHP

```sh
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install
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.3-fpm composer coding-standards-apply
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check
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 pull peterdavehello/markdownlint
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md' --fix
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md'
docker compose pull
docker compose run --rm markdownlint markdownlint '**/*.md' --fix
docker compose run --rm markdownlint markdownlint '**/*.md'
```

## Code analysis
Expand All @@ -143,7 +152,7 @@ Running statis code analysis on a standalone Drupal module is a bit tricky, so w
analysis:

```shell
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"mglaman/composer-drupal-lenient": true,
"phpstan/extension-installer": true,
"simplesamlphp/composer-module-installer": true,
"simplesamlphp/composer-xmlprovider-installer": true,
"vaimo/composer-patches": true,
"zaporylie/composer-drupal-optimizations": true
},
Expand Down