Skip to content

fix(#175): convert_urls per Default auf false, Release 8.10.5 #70

fix(#175): convert_urls per Default auf false, Release 8.10.5

fix(#175): convert_urls per Default auf false, Release 8.10.5 #70

name: Static Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
issue_comment:
types: [created]
workflow_dispatch:
jobs:
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
if: github.event_name != 'issue_comment' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
- name: Lint PHP files
run: |
find . -path ./vendor -prune -o -type f -name '*.php' -print0 \
| xargs -0 -n1 -P4 php -l > /tmp/lint.log
if grep -v "^No syntax errors" /tmp/lint.log | grep -q .; then
echo "::error::Syntax errors detected"
cat /tmp/lint.log
exit 1
fi
php-cs-fixer:
name: PHP-CS-Fixer (dry-run)
runs-on: ubuntu-latest
if: github.event_name != 'issue_comment' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
steps:
- uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
tools: php-cs-fixer
- name: Run PHP-CS-Fixer
run: |
if [ -f .php-cs-fixer.dist.php ] || [ -f .php-cs-fixer.php ] || [ -f .php_cs.dist ] || [ -f .php_cs ]; then
php-cs-fixer fix --dry-run --diff --ansi --config=.php-cs-fixer.php
else
echo "Kein .php-cs-fixer-Konfig vorhanden, fallback @PSR12"
php-cs-fixer fix --dry-run --diff --ansi --rules=@PSR12 --config=.php-cs-fixer.php
fi
rexstan:
name: rexstan
runs-on: ubuntu-latest
if: github.event_name != 'issue_comment' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
permissions:
contents: read
env:
ADDON_KEY: ${{ github.event.repository.name }}
steps:
- uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: gd, intl, pdo_mysql
coverage: none
- name: Download latest REDAXO release
run: |
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
REDAXO_VERSION=$(echo "$LATEST_RELEASE" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
echo "Downloaded REDAXO $REDAXO_VERSION"
curl -Ls -o redaxo.zip "https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip"
unzip -oq redaxo.zip -d redaxo_cms
rm redaxo.zip
- name: Init database
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
- name: Setup REDAXO
run: |
php redaxo_cms/redaxo/bin/console setup:run -n \
--lang=de_de --agree-license \
--db-host=127.0.0.1 --db-name=redaxo5 --db-password=root \
--db-createdb=no --db-setup=normal \
--admin-username=admin --admin-password=adminpassword \
--error-email=test@redaxo.invalid --ansi
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true
- name: Copy and install Addons
run: |
rsync -av \
--exclude='./vendor' \
--exclude='.github' \
--exclude='.git' \
--exclude='redaxo_cms' \
'./' "redaxo_cms/redaxo/src/addons/${ADDON_KEY}"
redaxo_cms/redaxo/bin/console install:download 'yform' '^4.2'
redaxo_cms/redaxo/bin/console package:install 'yform'
redaxo_cms/redaxo/bin/console install:download 'rexstan' '^3.0'
redaxo_cms/redaxo/bin/console package:install 'rexstan'
redaxo_cms/redaxo/bin/console package:install "${ADDON_KEY}"
- name: Configure rexstan (phpVersion + scan paths)
run: |
mkdir -p redaxo_cms/redaxo/data/addons/rexstan
cat > redaxo_cms/redaxo/data/addons/rexstan/user-config.neon <<'NEON'
# CI auto-generated rexstan user-config
includes: { }
parameters:
level: 5
phpVersion: 80300
scanDirectories:
- ../../../../redaxo/src/addons/yform/lib/
- ../../../../redaxo/src/addons/yform/vendor/
reportUnmatchedIgnoredErrors: false
NEON
- name: Execute addon rexstan bootstrap (optional)
run: |
if [ -f "redaxo/src/addons/${ADDON_KEY}/.tools/rexstan.php" ]; then
php -f "redaxo/src/addons/${ADDON_KEY}/.tools/rexstan.php"
else
echo "Kein .tools/rexstan.php vorhanden, Schritt uebersprungen."
fi
working-directory: redaxo_cms
- name: Run rexstan
run: redaxo_cms/redaxo/bin/console rexstan:analyze "redaxo/src/addons/${ADDON_KEY}"
php-cs-fixer-autofix:
name: PHP-CS-Fixer (autofix via /fix-cs)
runs-on: ubuntu-latest
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/fix-cs') &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Read PR context
id: pr
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const pull_number = context.payload.issue.number;
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
core.setOutput('number', String(pr.number));
core.setOutput('headRef', pr.head.ref);
core.setOutput('headRepo', pr.head.repo.full_name);
- name: Abort for fork pull requests
if: steps.pr.outputs.headRepo != github.repository
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.issue.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: 'Auto-Fix wurde nicht ausgefuehrt: Fork-PRs werden aus Sicherheitsgruenden nicht automatisch gepusht. Bitte local php-cs-fixer ausfuehren und committen.'
});
- name: Checkout PR branch
if: steps.pr.outputs.headRepo == github.repository
uses: actions/checkout@v5
with:
ref: ${{ steps.pr.outputs.headRef }}
fetch-depth: 0
- name: Setup PHP
if: steps.pr.outputs.headRepo == github.repository
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
tools: php-cs-fixer
- name: Run PHP-CS-Fixer (write mode)
if: steps.pr.outputs.headRepo == github.repository
run: |
if [ -f .php-cs-fixer.dist.php ] || [ -f .php-cs-fixer.php ]; then
php-cs-fixer fix --ansi --config=.php-cs-fixer.php
elif [ -f .php_cs.dist ] || [ -f .php_cs ]; then
php-cs-fixer fix --ansi
else
echo "Kein php-cs-fixer-Konfig vorhanden, verwende @PSR12"
php-cs-fixer fix --ansi --rules=@PSR12
fi
- name: Commit and push fixes
if: steps.pr.outputs.headRepo == github.repository
id: commit
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "style: apply php-cs-fixer"
git push origin "HEAD:${{ steps.pr.outputs.headRef }}"
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Comment result (fixed)
if: steps.pr.outputs.headRepo == github.repository && steps.commit.outputs.changed == 'true'
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.issue.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: 'php-cs-fixer wurde ausgefuehrt und die Aenderungen wurden auf den PR-Branch gepusht.'
});
- name: Comment result (clean)
if: steps.pr.outputs.headRepo == github.repository && steps.commit.outputs.changed == 'false'
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.issue.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: 'php-cs-fixer wurde ausgefuehrt. Keine Aenderungen erforderlich.'
});