Github action call updates

This commit is contained in:
2026-06-25 15:35:55 +09:00
parent e935e0c6d3
commit 8c5ce49f70
2 changed files with 51 additions and 36 deletions
@@ -8,8 +8,8 @@ on:
jobs: jobs:
call-check-and-build-local: call-check-and-build-local:
# call local workflow if repository name is NOT CoreLibs-Composer-All # call local workflow if repository name is NOT Composer.corelibs-composer-all
if: github.event.repository.name != 'CoreLibs-Composer-All' if: github.event.repository.name != 'Composer.corelibs-composer-all'
uses: ./.github/workflows/php-static-checks-and-tests.yml uses: ./.github/workflows/php-static-checks-and-tests.yml
with: with:
php-version: '8.4,8.5' php-version: '8.4,8.5'
@@ -22,8 +22,8 @@ jobs:
opj-package-api-key: ${{ secrets.OPJ_PACKAGE_API_KEY }} opj-package-api-key: ${{ secrets.OPJ_PACKAGE_API_KEY }}
call-check-and-build-remote: call-check-and-build-remote:
# call remote workflow if repository name is CoreLibs-Composer-All # call remote workflow if repository name is Composer.corelibs-composer-all
if: github.event.repository.name == 'CoreLibs-Composer-All' if: github.event.repository.name == 'Composer.corelibs-composer-all'
uses: OmnicomProduction-Japan/Content.github-actions/.github/workflows/php-static-checks-and-tests.yml@v1 uses: OmnicomProduction-Japan/Content.github-actions/.github/workflows/php-static-checks-and-tests.yml@v1
with: with:
php-version: '8.4,8.5' php-version: '8.4,8.5'
@@ -194,11 +194,23 @@ jobs:
- name: Test with phpunit - name: Test with phpunit
id: run-phpunit id: run-phpunit
run: | run: |
phpunit --colors=never \ # if we are older than 12 there is no openclover
--no-coverage \ # version can start with ^ and then have numbers, so we need to remove the ^ and then compare the version numbers
--coverage-text=phpunit-coverage.txt \ phpunit_version="${{ matrix.phpunit-version }}"
--only-summary-for-coverage-text \ phpunit_version="${phpunit_version#^}"
--coverage-openclover=phpunit-openclover.xml phpunit_version="${phpunit_version%%.*}"
if [ "$phpunit_version" -lt 12 ]; then
phpunit --colors=never \
--no-coverage \
--coverage-text=phpunit-coverage.txt \
--coverage-clover=phpunit-openclover.xml
else
phpunit --colors=never \
--no-coverage \
--coverage-text=phpunit-coverage.txt \
--only-summary-for-coverage-text \
--coverage-openclover=phpunit-openclover.xml
fi;
- name: Code Coverage Summary Report - name: Code Coverage Summary Report
uses: saschanowak/CloverCodeCoverageSummary@1.1.1 uses: saschanowak/CloverCodeCoverageSummary@1.1.1
@@ -248,33 +260,6 @@ jobs:
</details> </details>
EOF EOF
if [ -f phpunit-coverage.txt ]; then
{
echo "<h3>Code Coverage</h3>"
echo ""
echo "| Metric | Coverage | Status |"
echo "| --- | --- | --- |"
grep -E '^\s+(Classes|Methods|Lines):' phpunit-coverage.txt | head -3 | while IFS= read -r line; do
name=$(echo "$line" | sed 's/^[[:space:]]*//' | cut -d: -f1)
value=$(echo "$line" | cut -d: -f2- | sed 's/^[[:space:]]*//')
pct=$(echo "$value" | grep -oE '[0-9]+\.[0-9]+' | head -1)
circle=$(awk -v p="$pct" 'BEGIN { if (p+0 == 100) print "🟢"; else if (p+0 >= 60) print "🟠"; else print "🔴" }')
echo "| $name | $value | $circle |"
done
echo ""
echo "<details><summary>Full coverage report</summary>"
echo ""
echo '```'
cat phpunit-coverage.txt
echo '```'
echo ""
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
fi
cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY
if [ -f "$COMPOSER_AUDIT_FILE" ] && jq empty "$COMPOSER_AUDIT_FILE" 2>/dev/null; then if [ -f "$COMPOSER_AUDIT_FILE" ] && jq empty "$COMPOSER_AUDIT_FILE" 2>/dev/null; then
{ {
echo "<h3>Composer Audit</h3>" echo "<h3>Composer Audit</h3>"
@@ -307,3 +292,33 @@ jobs:
echo "</details>" echo "</details>"
} >> $GITHUB_STEP_SUMMARY } >> $GITHUB_STEP_SUMMARY
fi fi
if [ -f phpunit-coverage.txt ]; then
{
echo "<h3>Code Coverage</h3>"
echo ""
echo "| Metric | Coverage | Status |"
echo "| --- | --- | --- |"
grep -E '^\s+(Classes|Methods|Lines):' phpunit-coverage.txt | head -3 | while IFS= read -r line; do
name=$(echo "$line" | sed 's/^[[:space:]]*//' | cut -d: -f1)
value=$(echo "$line" | cut -d: -f2- | sed 's/^[[:space:]]*//')
pct=$(echo "$value" | grep -oE '[0-9]+\.[0-9]+' | head -1)
circle=$(awk -v p="$pct" 'BEGIN { if (p+0 == 100) print "🟢"; else if (p+0 >= 60) print "🟠"; else print "🔴" }')
echo "| $name | $value | $circle |"
done
echo ""
echo "<details><summary>Full coverage report</summary>"
echo ""
echo '```'
cat phpunit-coverage.txt
echo '```'
echo ""
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
fi
if [ -f phpunit-openclover.xml ]; then
cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY
fi