110 lines
3.1 KiB
YAML
110 lines
3.1 KiB
YAML
name: ✅ Continuous Integration
|
|
|
|
run-name: CI Checks - ${{ github.ref_name || github.head_ref }}
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- main
|
|
- staging
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'docs/**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- staging
|
|
|
|
env:
|
|
CACHE_DIR: /tmp/composer-cache
|
|
|
|
jobs:
|
|
tests:
|
|
name: Run Tests & Quality Checks
|
|
runs-on: php-ci
|
|
steps:
|
|
- name: Download CI helpers
|
|
shell: bash
|
|
env:
|
|
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
REF="${{ github.sha }}"
|
|
if [ -z "$REF" ]; then
|
|
REF="${{ github.ref_name }}"
|
|
fi
|
|
if [ -z "$REF" ]; then
|
|
REF="${{ github.head_ref }}"
|
|
fi
|
|
if [ -z "$REF" ]; then
|
|
REF="${{ github.base_ref || 'develop' }}"
|
|
fi
|
|
URL="https://git.michaelschiemer.de/${{ github.repository }}/raw/${REF}/scripts/ci/clone_repo.sh"
|
|
mkdir -p /tmp/ci-tools
|
|
if [ -n "$CI_TOKEN" ]; then
|
|
curl -sfL -u "$CI_TOKEN:x-oauth-basic" "$URL" -o /tmp/ci-tools/clone_repo.sh
|
|
else
|
|
curl -sfL "$URL" -o /tmp/ci-tools/clone_repo.sh
|
|
fi
|
|
chmod +x /tmp/ci-tools/clone_repo.sh
|
|
|
|
- name: Checkout code
|
|
env:
|
|
REF_NAME_GITHUB: ${{ github.ref_name }}
|
|
HEAD_REF: ${{ github.head_ref }}
|
|
BASE_REF: ${{ github.base_ref }}
|
|
run: |
|
|
REF_NAME="$REF_NAME_GITHUB"
|
|
if [ -z "$REF_NAME" ]; then
|
|
REF_NAME="$HEAD_REF"
|
|
fi
|
|
if [ -z "$REF_NAME" ]; then
|
|
REF_NAME="$BASE_REF"
|
|
fi
|
|
if [ -z "$REF_NAME" ]; then
|
|
REF_NAME="develop"
|
|
fi
|
|
|
|
export CI_REPOSITORY="${{ github.repository }}"
|
|
export CI_TOKEN="${{ secrets.CI_TOKEN }}"
|
|
export CI_REF_NAME="$REF_NAME"
|
|
export CI_INPUT_BRANCH="$HEAD_REF"
|
|
export CI_DEFAULT_BRANCH="develop"
|
|
export CI_TARGET_DIR="/workspace/repo"
|
|
export CI_FETCH_DEPTH="1"
|
|
|
|
/tmp/ci-tools/clone_repo.sh
|
|
|
|
cd /workspace/repo
|
|
|
|
- name: Restore Composer cache
|
|
run: |
|
|
if [ -d "$CACHE_DIR/vendor" ]; then
|
|
echo "📦 Restore composer dependencies"
|
|
cp -r "$CACHE_DIR/vendor" /workspace/repo/vendor || true
|
|
fi
|
|
|
|
- name: Install PHP dependencies
|
|
run: |
|
|
cd /workspace/repo
|
|
composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php
|
|
|
|
- name: Save Composer cache
|
|
run: |
|
|
mkdir -p "$CACHE_DIR"
|
|
cp -r /workspace/repo/vendor "$CACHE_DIR/vendor" || true
|
|
|
|
- name: PHPStan (baseline)
|
|
run: |
|
|
cd /workspace/repo
|
|
make phpstan || echo "⚠️ phpstan skipped/failed"
|
|
|
|
- name: Lint PHP (dry run)
|
|
run: |
|
|
cd /workspace/repo
|
|
make cs || echo "⚠️ php-cs-fixer dry run issues detected"
|
|
|
|
- name: Tests temporarily skipped
|
|
run: |
|
|
echo "⚠️ Tests temporarily skipped due to PHP 8.5 compatibility issues"
|