PHP Check update
This commit is contained in:
@@ -18,8 +18,7 @@ jobs:
|
||||
source-directory: './src'
|
||||
disable-phan: ${{ vars.DISABLE_PHAN_CHECK == 'true' || false }}
|
||||
secrets:
|
||||
opj-package-user: ${{ secrets.OPJ_PACKAGE_USER }}
|
||||
opj-package-api-key: ${{ secrets.OPJ_PACKAGE_API_KEY }}
|
||||
opj-package-registry: "${{ secrets.OPJ_PACKAGE_USER }}|${{ secrets.OPJ_PACKAGE_API_KEY }}|${{ vars.OPJ_PACKAGE_URL }}"
|
||||
|
||||
call-check-and-build-remote:
|
||||
# call remote workflow if repository name is Composer.corelibs-composer-all
|
||||
@@ -32,6 +31,5 @@ jobs:
|
||||
source-directory: './src'
|
||||
disable-phan: ${{ vars.DISABLE_PHAN_CHECK == 'true' || false }}
|
||||
secrets:
|
||||
opj-package-user: ${{ secrets.OPJ_PACKAGE_USER }}
|
||||
opj-package-api-key: ${{ secrets.OPJ_PACKAGE_API_KEY }}
|
||||
opj-package-registry: "${{ secrets.OPJ_PACKAGE_USER }}|${{ secrets.OPJ_PACKAGE_API_KEY }}|${{ vars.OPJ_PACKAGE_URL }}"
|
||||
|
||||
|
||||
@@ -36,12 +36,9 @@ on:
|
||||
default: './src'
|
||||
description: 'Directory where the PHP source code is located, relative to the repository root'
|
||||
secrets:
|
||||
opj-package-user:
|
||||
required: true
|
||||
description: 'Username for private package repository'
|
||||
opj-package-api-key:
|
||||
required: true
|
||||
description: 'API key for private package repository'
|
||||
opj-package-registry:
|
||||
required: false
|
||||
description: 'Package registry login infos: user|token|url[:user|token|url:...]'
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
@@ -50,13 +47,24 @@ jobs:
|
||||
php-version: ${{ steps.set-matrix.outputs.php-version }}
|
||||
phpunit-version: ${{ steps.set-matrix.outputs.phpunit-version }}
|
||||
operating-system: ${{ steps.set-matrix.outputs.operating-system }}
|
||||
opj-package-registry: ${{ steps.set-matrix.outputs.opj-package-registry }}
|
||||
steps:
|
||||
- name: Set matrix values
|
||||
id: set-matrix
|
||||
env:
|
||||
OPJ_PACKAGE_REGISTRY: ${{ secrets.opj-package-registry }}
|
||||
run: |
|
||||
echo "php-version=$(echo '${{ inputs.php-version }}' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
|
||||
echo "phpunit-version=$(echo '${{ inputs.phpunit-version }}' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
|
||||
echo "operating-system=$(echo '${{ inputs.operating-system }}' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
|
||||
# take the secrets opj-package-registry, split by ":" for each entry
|
||||
# then split by "|" for each entry to get user, token, url
|
||||
# then create a JSON array of objects with user, token, url
|
||||
if [ -n "$OPJ_PACKAGE_REGISTRY" ]; then
|
||||
echo "opj-package-registry=$(echo "$OPJ_PACKAGE_REGISTRY" | tr ':' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | jq -R 'split("|") | {user: .[0], token: .[1], url: .[2]}' | jq -cs .)" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "opj-package-registry=[]" >> $GITHUB_OUTPUT
|
||||
fi;
|
||||
|
||||
php-check-and-test-matrix:
|
||||
needs: setup
|
||||
@@ -82,17 +90,6 @@ jobs:
|
||||
tools: composer, ${{ inputs.disable-phan == false && 'phan, ' || '' }}phpstan, phpcs, phpunit:${{ matrix.phpunit-version }}, cs2pr
|
||||
# coverage: pcov
|
||||
coverage: xdebug
|
||||
# env:
|
||||
# # Does not work, hast to be set in dependencies step, see below in "install dependencies"
|
||||
# COMPOSER_AUTH: |
|
||||
# {
|
||||
# "http-basic": {
|
||||
# "packages.omnicomproduction.jp": {
|
||||
# "username": "${{ secrets.OPJ_PACKAGE_USER }}",
|
||||
# "password": "${{ secrets.OPJ_PACKAGE_API_KEY }}"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
- name: Check Tools setup
|
||||
id: check-tools
|
||||
run: |
|
||||
@@ -151,9 +148,23 @@ jobs:
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Authenticate to private package repository
|
||||
env:
|
||||
OPJ_PACKAGE_REGISTRY: ${{ needs.setup.outputs.opj-package-registry }}
|
||||
run: |
|
||||
composer config http-basic.packages.omnicomproduction.jp "${{ secrets.opj-package-user }}" "${{ secrets.opj-package-api-key }}"
|
||||
# opj-package-registry is a JSON array of objects with user, token, url
|
||||
for entry in $(echo "$OPJ_PACKAGE_REGISTRY" | jq -c '.[]'); do
|
||||
user=$(echo "$entry" | jq -r '.user')
|
||||
token=$(echo "$entry" | jq -r '.token')
|
||||
url=$(echo "$entry" | jq -r '.url')
|
||||
# if user, token or url is empty, skip this entry
|
||||
if [ -z "$user" ] || [ -z "$token" ] || [ -z "$url" ]; then
|
||||
echo "⚠️ Warning: Skipping invalid registry entry: $entry"
|
||||
continue
|
||||
fi
|
||||
echo "Authenticating to private package repository: $url with user: $user"
|
||||
composer config http-basic."$url" "$user" "$token"
|
||||
done
|
||||
composer install --prefer-dist
|
||||
working-directory: ${{ inputs.composer-directory }}
|
||||
|
||||
@@ -203,13 +214,16 @@ jobs:
|
||||
phpunit --colors=never \
|
||||
--no-coverage \
|
||||
--coverage-text=phpunit-coverage.txt \
|
||||
--coverage-clover=phpunit-openclover.xml
|
||||
--coverage-clover=phpunit-openclover.xml \
|
||||
--log-junit=phpunit-junit.log
|
||||
else
|
||||
phpunit --colors=never \
|
||||
--no-coverage \
|
||||
--coverage-text=phpunit-coverage.txt \
|
||||
--only-summary-for-coverage-text \
|
||||
--coverage-openclover=phpunit-openclover.xml
|
||||
--coverage-openclover=phpunit-openclover.xml \
|
||||
--log-junit=phpunit-junit.log \
|
||||
--log-otr=phpunit-otr.log
|
||||
fi;
|
||||
|
||||
- name: Code Coverage Summary Report
|
||||
@@ -293,6 +307,35 @@ jobs:
|
||||
} >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ -f phpunit-junit.log ]; then
|
||||
{
|
||||
echo "<h3>PHPUnit Test Results</h3>"
|
||||
echo ""
|
||||
# Extract totals from the top-level testsuite element (first testsuite line)
|
||||
JUNIT_LINE=$(grep -m1 '<testsuite ' phpunit-junit.log)
|
||||
TESTS=$(echo "$JUNIT_LINE" | grep -oP 'tests="\K[0-9]+')
|
||||
ASSERTIONS=$(echo "$JUNIT_LINE" | grep -oP 'assertions="\K[0-9]+')
|
||||
ERRORS=$(echo "$JUNIT_LINE" | grep -oP 'errors="\K[0-9]+')
|
||||
FAILURES=$(echo "$JUNIT_LINE" | grep -oP 'failures="\K[0-9]+')
|
||||
SKIPPED=$(echo "$JUNIT_LINE" | grep -oP 'skipped="\K[0-9]+')
|
||||
TIME=$(echo "$JUNIT_LINE" | grep -oP 'time="\K[0-9]+\.[0-9]+')
|
||||
PASSED=$(( TESTS - ERRORS - FAILURES - SKIPPED ))
|
||||
test_icon() {
|
||||
if [ "$1" -gt 0 ]; then echo "❌"; else echo "✅"; fi
|
||||
}
|
||||
echo "| Metric | Value |"
|
||||
echo "| --- | --- |"
|
||||
echo "| Tests | $TESTS |"
|
||||
echo "| Passed | $PASSED |"
|
||||
echo "| Assertions | $ASSERTIONS |"
|
||||
echo "| Skipped | $(test_icon "${SKIPPED:-0}") ${SKIPPED:-0} |"
|
||||
echo "| Failures | $(test_icon "${FAILURES:-0}") ${FAILURES:-0} |"
|
||||
echo "| Errors | $(test_icon "${ERRORS:-0}") ${ERRORS:-0} |"
|
||||
echo "| Time | ${TIME}s |"
|
||||
echo ""
|
||||
} >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ -f phpunit-coverage.txt ]; then
|
||||
{
|
||||
echo "<h3>Code Coverage</h3>"
|
||||
|
||||
Reference in New Issue
Block a user