Skip to content

ci: add Fluxer.app notifications to codestyle-and-unittest workflow #50

ci: add Fluxer.app notifications to codestyle-and-unittest workflow

ci: add Fluxer.app notifications to codestyle-and-unittest workflow #50

name: Codestyle and Unittest

Check failure on line 1 in .github/workflows/codestyle-and-unittest.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/codestyle-and-unittest.yml

Invalid workflow file

(Line: 95, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.WEBHOOK_DISCORD_URL, (Line: 96, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.WEBHOOK_FLUXER_URL, (Line: 118, Col: 13): Unrecognized named-value: 'secrets'. Located at position 14 within expression: success() && secrets.FLUXER_WEBHOOK_URL != '', (Line: 125, Col: 13): Unrecognized named-value: 'secrets'. Located at position 14 within expression: failure() && secrets.FLUXER_WEBHOOK_URL != ''
on:
push:
branches:
- '*'
- '!master'
- '!develop'
paths:
- "**.php"
workflow_dispatch:
jobs:
# 1. Job: Statische Analyse (Lint, Stan, CodeSniffer)
# Diese laufen zusammen, da sie keine Datenbank benötigen.
static-analysis:
name: PHP Quality Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Setup PHP and Composer
uses: ./.github/actions/setup-php-composer
- name: Run PHP Linter
run: composer run-script phplint
- name: Run PHP Stan
run: composer run-script phpstan
- name: Run PHP Codesniffer
run: composer run-script phpcs
- name: Notify Failure
if: failure()
uses: rjstone/discord-webhook-notify@v1.0.4
with:
severity: error
details: Static Analysis (Lint/Stan/CS) failed.
webhookUrl: ${{ secrets.WEBHOOK_DISCORD_URL }}
# 2. Job: Tests (Unit & Functional)
# Dieser Job benötigt die MariaDB Service-Container
tests:
name: PHP Tests
needs: static-analysis
runs-on: ubuntu-latest
services:
database-testing:
image: mariadb:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: dev
MYSQL_PASSWORD: dev
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
env:
DB_DATABASE: db
DB_USERNAME: dev
DB_PASSWORD: dev
DB_HOST: 127.0.0.1
DB_PORT: 3306
APP_ENV: action
steps:
- uses: actions/checkout@v6.0.2
- name: Setup PHP and Composer
uses: ./.github/actions/setup-php-composer
- name: Run Tests
run: ./vendor/bin/pest --configuration=phpunit.xml --compact
env:
APP_ENV: action
DB_HOST: 127.0.0.1
- name: Notify Failure
if: failure()
uses: rjstone/discord-webhook-notify@v1.0.4
with:
severity: error
details: Integration Tests failed.
webhookUrl: ${{ secrets.WEBHOOK_DISCORD_URL }}
# 3. Job: Abschluss-Benachrichtigung
final-status:
name: Final Status Message
needs: [ static-analysis, tests ]
if: always()
runs-on: ubuntu-latest
strategy:
matrix:
webhook:
- ${{ secrets.WEBHOOK_DISCORD_URL }}
- ${{ secrets.WEBHOOK_FLUXER_URL }}
steps:
- name: Check Info Success
if: ${{ needs.static-analysis.result == 'success' && needs.tests.result == 'success' }}
uses: rjstone/discord-webhook-notify@v1.0.4
with:
severity: info
details: Checks successfully executed on API.
webhookUrl: ${{ matrix.webhook }}
- name: Check Info Failure
if: ${{ needs.static-analysis.result != 'success' || needs.tests.result != 'success' }}
uses: rjstone/discord-webhook-notify@v1.0.4
with:
severity: error
details: >-
${{ format('❌ Incorrect checks during the API check. [View Logs](https://github.com/{0}/actions/runs/{1})',
github.repository,
github.run_id) }}
webhookUrl: ${{ matrix.webhook }}
# --- Schritt 2: Separate Benachrichtigung an Fluxer.app ---
- name: Notify Fluxer.app Success
if: ${{ success() && secrets.FLUXER_WEBHOOK_URL != '' }}
run: |
curl -X POST -H "Content-Type: application/json" \
-d '{"text": "✅ Checks successfully executed on API for ${{ github.repository }}."}' \
${{ secrets.FLUXER_WEBHOOK_URL }}
- name: Notify Fluxer.app Failure
if: ${{ failure() && secrets.FLUXER_WEBHOOK_URL != '' }}
run: |
LINK="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
MESSAGE="❌ Incorrect checks during the API check for ${{ github.repository }}. View Logs: $LINK"
# Das JSON muss korrekt escaped sein.
JSON_PAYLOAD=$(printf '{"text": "%s"}' "$MESSAGE")
curl -X POST -H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
${{ secrets.FLUXER_WEBHOOK_URL }}