Update ci.yml

This commit is contained in:
2025-12-18 16:24:20 -06:00
parent 3047868cbb
commit ea30e82068

View File

@@ -1,183 +1,195 @@
name: Continuous Integration Pipeline name: Continuous Integration Pipeline
on: on:
push: push:
branches: branches:
- main - main
- "version/*" - "version/*"
pull_request: pull_request:
branches: branches:
- main - main
permissions: permissions:
contents: read contents: read
jobs: jobs:
formatting-fixes: formatting-fixes:
name: Run formatting fix scripts name: Run formatting fix scripts
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python - name: Ensure script executability
uses: actions/setup-python@v5 shell: bash
with: run: |
python-version: "3.11" set -euo pipefail
chmod +x scripts/*.sh 2>/dev/null || true
- name: Run fix_tabs.py if present - name: Run fix_tabs.sh if present
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
cd "${GITHUB_WORKSPACE}" cd "${GITHUB_WORKSPACE}"
if [ -f "scripts/fix_tabs.py" ]; then if [ -f "scripts/fix_tabs.sh" ]; then
echo "Running scripts/fix_tabs.py" echo "Running scripts/fix_tabs.sh"
python scripts/fix_tabs.py bash scripts/fix_tabs.sh
else else
echo "scripts/fix_tabs.py not found. Skipping." echo "scripts/fix_tabs.sh not found. Skipping."
fi fi
- name: Run fix_paths.py if present - name: Run fix_paths.sh if present
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
cd "${GITHUB_WORKSPACE}" cd "${GITHUB_WORKSPACE}"
if [ -f "scripts/fix_paths.py" ]; then if [ -f "scripts/fix_paths.sh" ]; then
echo "Running scripts/fix_paths.py" echo "Running scripts/fix_paths.sh"
python scripts/fix_paths.py bash scripts/fix_paths.sh
else else
echo "scripts/fix_paths.py not found. Skipping." echo "scripts/fix_paths.sh not found. Skipping."
fi fi
fi
- name: Fail if formatting scripts modified files - name: Fail if formatting scripts modified files
run: | shell: bash
set -e run: |
if ! git diff --quiet; then set -euo pipefail
echo "Formatting scripts introduced changes." if ! git diff --quiet; then
echo "Run fix_tabs.py and fix_paths.py locally and commit the results." echo "Formatting scripts introduced changes."
git diff echo "Run fix_tabs.sh and fix_paths.sh locally and commit the results."
exit 1 git diff
fi exit 1
fi
php-lint: php-lint:
name: PHP lint name: PHP lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: formatting-fixes needs: formatting-fixes
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up PHP - name: Set up PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: "8.2" php-version: "8.2"
coverage: none coverage: none
- name: Lint PHP files under src - name: Lint PHP files under src
run: | shell: bash
if [ -d "src" ]; then run: |
echo "Running php -l against PHP files in src/" set -euo pipefail
find src -type f -name "*.php" -print0 | xargs -0 -n 1 -P 4 php -l if [ -d "src" ]; then
else echo "Running php -l against PHP files in src/"
echo "No src directory found. Skipping PHP lint." find src -type f -name "*.php" -print0 | xargs -0 -n 1 -P 4 php -l
fi else
echo "No src directory found. Skipping PHP lint."
fi
composer-tests: composer-tests:
name: Composer install and tests name: Composer install and tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: php-lint needs: php-lint
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up PHP - name: Set up PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: "8.2" php-version: "8.2"
coverage: none coverage: none
- name: Install dependencies if composer.json exists - name: Install dependencies if composer.json exists
run: | shell: bash
if [ -f "composer.json" ]; then run: |
composer install --no-interaction --no-progress --prefer-dist set -euo pipefail
else if [ -f "composer.json" ]; then
echo "No composer.json found. Skipping dependency install and tests." composer install --no-interaction --no-progress --prefer-dist
fi else
echo "No composer.json found. Skipping dependency install and tests."
fi
- name: Run Composer tests when defined - name: Run Composer tests when defined
run: | shell: bash
if [ ! -f "composer.json" ]; then run: |
echo "No composer.json. Nothing to test." set -euo pipefail
exit 0 if [ ! -f "composer.json" ]; then
fi echo "No composer.json. Nothing to test."
exit 0
fi
if composer run -q | grep -q "^ test"; then if composer run -q | grep -q "^ test"; then
echo "Detected composer script 'test'. Running composer test." echo "Detected composer script 'test'. Running composer test."
composer test composer test
else else
echo "No 'test' script defined in composer.json. Skipping tests." echo "No 'test' script defined in composer.json. Skipping tests."
fi fi
validate-manifest-and-changelog: validate-manifest-and-changelog:
name: Validate manifest and changelog via scripts name: Validate manifest and changelog via scripts
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:
- php-lint - php-lint
- composer-tests - composer-tests
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Run manifest validation script if present - name: Ensure script executability
run: | shell: bash
set -e run: |
echo "Checking for manifest validation scripts" set -euo pipefail
chmod +x scripts/*.sh 2>/dev/null || true
if [ -x "scripts/validate_manifest.sh" ]; then - name: Run manifest validation script if present
echo "Running scripts/validate_manifest.sh" shell: bash
scripts/validate_manifest.sh run: |
elif [ -f "scripts/validate_manifest.php" ]; then set -euo pipefail
echo "Running scripts/validate_manifest.php" echo "Checking for manifest validation scripts"
php scripts/validate_manifest.php
elif [ -f "scripts/validate_manifest.py" ]; then
echo "Running scripts/validate_manifest.py"
python scripts/validate_manifest.py
else
echo "No manifest validation script found (scripts/validate_manifest.*). Skipping manifest validation step."
fi
- name: Run changelog update or verification script if present if [ -f "scripts/validate_manifest.sh" ]; then
run: | echo "Running scripts/validate_manifest.sh"
set -e bash scripts/validate_manifest.sh
echo "Checking for changelog update or verification scripts" elif [ -f "scripts/validate_manifest.php" ]; then
echo "Running scripts/validate_manifest.php"
php scripts/validate_manifest.php
else
echo "No manifest validation script found (scripts/validate_manifest.sh or scripts/validate_manifest.php). Skipping manifest validation step."
fi
if [ -x "scripts/update_changelog.sh" ]; then - name: Run changelog update or verification script if present
echo "Running scripts/update_changelog.sh --ci" shell: bash
scripts/update_changelog.sh --ci run: |
elif [ -f "scripts/update_changelog.py" ]; then set -euo pipefail
echo "Running scripts/update_changelog.py --ci" echo "Checking for changelog update or verification scripts"
python scripts/update_changelog.py --ci
elif [ -x "scripts/verify_changelog.sh" ]; then
echo "Running scripts/verify_changelog.sh"
scripts/verify_changelog.sh
else
echo "No changelog script found (scripts/update_changelog.* or scripts/verify_changelog.sh). Skipping changelog enforcement."
exit 0
fi
echo "Checking for uncommitted changes after changelog script" if [ -f "scripts/update_changelog.sh" ]; then
if ! git diff --quiet; then echo "Running scripts/update_changelog.sh --ci"
echo "Changelog or related files were modified by the script." bash scripts/update_changelog.sh --ci
echo "Please run the changelog script locally and commit the changes before pushing." elif [ -f "scripts/verify_changelog.sh" ]; then
git diff echo "Running scripts/verify_changelog.sh"
exit 1 bash scripts/verify_changelog.sh
fi elif [ -f "scripts/verify_changelog.php" ]; then
echo "Running scripts/verify_changelog.php"
php scripts/verify_changelog.php
else
echo "No changelog script found (scripts/update_changelog.sh, scripts/verify_changelog.sh, or scripts/verify_changelog.php). Skipping changelog enforcement."
exit 0
fi
echo "Checking for uncommitted changes after changelog script"
if ! git diff --quiet; then
echo "Changelog or related files were modified by the script."
echo "Please run the changelog script locally and commit the changes before pushing."
git diff
exit 1
fi