Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API cleanup #429

Merged
merged 5 commits into from
Jan 10, 2025
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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

two uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

- 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
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": 80,
"code_blocks": false,
"tables": false
},
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"no-duplicate-heading": {
"siblings_only": true
}
}
12 changes: 0 additions & 12 deletions .markdownlintrc

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-429](https://github.com/itk-dev/hoeringsportal/pull/429)
Removed outdated (and unused) API endpoints. Cleaned up.
* [PR-427](https://github.com/itk-dev/hoeringsportal/pull/427)
Updated docker compose setup. Updated composer packages.
* [PR-425](https://github.com/itk-dev/hoeringsportal/pull/425)
Expand Down Expand Up @@ -162,6 +164,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
* [PR-371](https://github.com/itk-dev/hoeringsportal/pull/371)
Cleaned up archiving of citizen proposals

## [3.5.1] - 2023-09-01

## [3.5.0] - 2023-08-30

* [PR-363](https://github.com/itk-dev/hoeringsportal/pull/363)
Expand Down
82 changes: 82 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tasks:
composer:
cmds:
- task compose -- exec phpfpm composer {{.CLI_ARGS}}
silent: true

composer-install:
cmds:
Expand Down Expand Up @@ -129,3 +130,84 @@ tasks:
sh: task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix --tuples-only --csv <<< "SELECT token FROM pretixbase_teamapitoken WHERE name = 'hoeringsportal'"
cmds:
- "task compose -- exec phpfpm curl --header 'Authorization: Token {{.API_TOKEN}}' {{.PRETIX_URL}}/api/v1/organizers/"

coding-standards:apply:
desc: "Apply coding standards"
cmds:
- 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:assets:check
- task: coding-standards:markdown:check
- task: coding-standards:php:check
- task: coding-standards:twig:check
silent: true

coding-standards:assets:apply:
desc: "Apply coding standards for assets"
cmds:
# Prettier does not (yet, fcf.
# 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 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 run --rm --volume "$PWD:/work" jauderho/prettier --check playwright

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

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'

coding-standards:php:apply:
desc: "Apply coding standards for PHP"
cmds:
- 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/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
16 changes: 14 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,14 @@
"@coding-standards-apply/phpcs",
"@coding-standards-apply/twig-cs-fixer"
],
"coding-standards-apply/php": [
"@coding-standards-apply/phpcs"
],
"coding-standards-apply/phpcs": [
"scripts/phpcbf --standard=phpcs.xml.dist"
"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"
Expand All @@ -278,8 +284,14 @@
"@coding-standards-check/phpcs",
"@coding-standards-check/twig-cs-fixer"
],
"coding-standards-check/php": [
"@coding-standards-check/phpcs"
],
"coding-standards-check/phpcs": [
"vendor/bin/phpcs --standard=phpcs.xml.dist"
"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
22 changes: 5 additions & 17 deletions documentation/localDevelopment.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,24 @@ All code must follow the [Drupal coding standards](https://www.drupal.org/docs/d

#### Coding standards

```sh
docker compose exec phpfpm composer coding-standards-check
```

Apply automatic coding standard fixes by running
Apply and check coding standard by running

```sh
docker compose exec phpfpm composer coding-standards-apply
task coding-standards:check
```

#### Code analysis

```sh
docker compose exec phpfpm composer code-analysis
task code-analysis
```

#### Markdown

```sh
docker compose run --rm node yarn install
```

```sh
docker compose run --rm node yarn coding-standards-check
```

Apply automatic coding standard fixes by running
Apply and check Markdown coding standards:

```sh
docker compose run --rm node yarn coding-standards-apply
task coding-standards:markdown:check
```

## About translations
Expand Down
Loading
Loading