Skip to content

Commit

Permalink
3534: Action! 🎬
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Jan 9, 2025
1 parent eaef2e9 commit 9d51e37
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 97 deletions.
134 changes: 46 additions & 88 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
on: pull_request

# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#defining-environment-variables-for-a-single-workflow
# (cf. services.phpfpm.user in ../../docker-compose.yml)
env:
COMPOSE_USER: root

name: PR Review
jobs:
fail-for-do-not-merge:
Expand Down Expand Up @@ -58,112 +63,65 @@ jobs:
composer install --no-interaction --no-progress
composer normalize composer.json --dry-run
coding-standards-phpcs:
name: PHP - Check Coding Standards
coding-standards-assets:
name: Assets - Check 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: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
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 --no-scripts
# @see https://github.com/Dealerdirect/phpcodesniffer-composer-installer#calling-the-plugin-directly
composer run-script install-codestandards
- name: PHPCS
run: |
composer coding-standards-check/phpcs
- uses: pnorton5432/setup-task@v1
- run: task coding-standards:assets:check
# Check for any changes (task …:check runs task …:apply)
- run: git diff --exit-code

coding-standards-twig-cs-fixer:
name: Twig - Check Coding Standards
coding-standards-markdown:
name: Markdown - Check 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: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
coverage: none
tools: composer:v2
- 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 --no-scripts
# @see https://github.com/Dealerdirect/phpcodesniffer-composer-installer#calling-the-plugin-directly
composer run-script install-codestandards
- name: TwigCS
run: |
composer coding-standards-check/twig-cs-fixer
- uses: pnorton5432/setup-task@v1
- run: task coding-standards:markdown:check
# Check for any changes (task …:check runs task …:apply)
- run: git diff --exit-code

coding-standards-markdown:
name: Yarn - Check Coding Standards (Node ${{ matrix.node }})
coding-standards-php:
name: PHP - Check Coding Standards
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '16' ]
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- uses: pnorton5432/setup-task@v1
- run: |
yarn install
yarn coding-standards-check
docker network create frontend
task compose -- up --detach
task composer -- install
task coding-standards:php:check
# Check for any changes (task …:check runs task …:apply)
- run: git diff --exit-code

coding-standards-twig:
name: Twig - Check Coding Standards
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnorton5432/setup-task@v1
- run: |
docker network create frontend
task compose -- up --detach
task composer -- install
task coding-standards:twig:check
# Check for any changes (task …:check runs task …:apply)
- run: git diff --exit-code

code-analysis:
name: PHP - Code analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
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: |
# Using `--no-scripts` breaks something with mglaman/drupal-check.
composer install --no-interaction --no-progress --no-scripts
- name: code-analysis
run: |
composer code-analysis
- uses: pnorton5432/setup-task@v1
- run: |
docker network create frontend
task compose -- up --detach
task composer -- install
task code-analysis
coding-standards-custom-themes:
name: Yarn - Check Coding Standards in custom themes
Expand Down
33 changes: 24 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ tasks:
coding-standards:apply:
desc: "Apply coding standards"
cmds:
- task: coding-standards:markdown:apply
- task: coding-standards:assets:apply
- task: coding-standards:markdown:apply
- task: coding-standards:php:apply
- task: coding-standards:twig:apply
silent: true

coding-standards:check:
desc: "Apply coding standards"
cmds:
- task: coding-standards:markdown:check
- task: coding-standards:assets:check
- task: coding-standards:markdown:check
- task: coding-standards:php:check
- task: coding-standards:twig:check
silent: true
Expand All @@ -156,43 +156,58 @@ tasks:
# https://github.com/prettier/prettier/issues/15206) have an official
# docker image.
# https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc)
- docker pull jauderho/prettier
- docker run --rm --volume "$PWD:/work" jauderho/prettier --write playwright

coding-standards:assets:check:
desc: "Apply and check coding standards for assets"
cmds:
- task: coding-standards:assets:apply
- docker pull jauderho/prettier
- docker run --rm --volume "$PWD:/work" jauderho/prettier --check playwright

coding-standards:markdown:apply:
desc: "Apply coding standards for Markdown"
cmds:
- docker pull peterdavehello/markdownlint
- docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore '**/node_modules/**' --ignore '**/vendor/**' '*.md' 'web/*/custom/**/*.md' 'documentation/*.md' --fix
silent: true

coding-standards:markdown:check:
desc: "Apply and check coding standards for Markdown"
cmds:
- task: coding-standards:markdown:apply
- docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore '**/node_modules/**' --ignore '**/vendor/**' '*.md' 'web/*/custom/**/*.md' 'documentation/*.md'
silent: true

coding-standards:php:apply:
desc: "Apply coding standards for PHP"
cmds:
- task composer -- coding-standards-apply
- task composer -- coding-standards-apply/php
silent: true

coding-standards:php:check:
desc: "Apply and check coding standards for PHP"
cmds:
- task: coding-standards:php:apply
- task composer -- coding-standards-check
- task composer -- coding-standards-check/php
silent: true

coding-standards:twig:apply:
desc: "Apply coding standards for Twig"
cmds:
- task composer -- coding-standards-apply/twig
silent: true

coding-standards:twig:check:
desc: "Apply and check coding standards for Twig"
cmds:
- task: coding-standards:twig:apply
- task composer -- coding-standards-check/twig
silent: true

code-analysis:
cmds:
- task composer -- code-analysis

docker-pull:
desc: "Pull all development docker images"
cmds:
- docker pull jauderho/prettier
- docker pull peterdavehello/markdownlint
- task compose -- pull
12 changes: 12 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,31 @@
"@coding-standards-apply/phpcs",
"@coding-standards-apply/twig-cs-fixer"
],
"coding-standards-apply/php": [
"@coding-standards-apply/phpcs"
],
"coding-standards-apply/phpcs": [
"phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-apply/twig": [
"@coding-standards-apply/twig-cs-fixer"
],
"coding-standards-apply/twig-cs-fixer": [
"twig-cs-fixer lint web/themes/custom/hoeringsportal/templates --fix"
],
"coding-standards-check": [
"@coding-standards-check/phpcs",
"@coding-standards-check/twig-cs-fixer"
],
"coding-standards-check/php": [
"@coding-standards-check/phpcs"
],
"coding-standards-check/phpcs": [
"phpcs --standard=phpcs.xml.dist"
],
"coding-standards-check/twig": [
"@coding-standards-check/twig-cs-fixer"
],
"coding-standards-check/twig-cs-fixer": [
"twig-cs-fixer lint web/themes/custom/hoeringsportal/templates"
],
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ services:

phpfpm:
image: itkdev/php8.3-fpm:latest
# https://docs.docker.com/reference/compose-file/services/#user
# https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#interpolation-syntax
# (used in .github/workflows/pr.yaml to run service as root)
user: ${COMPOSE_USER:-deploy}
networks:
- app
extra_hosts:
Expand Down

0 comments on commit 9d51e37

Please sign in to comment.