forked from baron/baron-sso
userfront&backend test coverage 추가
This commit is contained in:
@@ -26,6 +26,11 @@ on:
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
run_userfront_coverage:
|
||||
description: "Run userfront Flutter coverage and upload LCOV report"
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
run_userfront_e2e_tests:
|
||||
description: "Run userfront WASM Playwright E2E tests"
|
||||
required: true
|
||||
@@ -74,6 +79,7 @@ jobs:
|
||||
biome: ${{ steps.filter.outputs.biome }}
|
||||
backend: ${{ steps.filter.outputs.backend }}
|
||||
userfront: ${{ steps.filter.outputs.userfront }}
|
||||
userfront_coverage: ${{ steps.filter.outputs.userfront_coverage }}
|
||||
userfront_e2e: ${{ steps.filter.outputs.userfront_e2e }}
|
||||
front_coverage: ${{ steps.filter.outputs.front_coverage }}
|
||||
adminfront: ${{ steps.filter.outputs.adminfront }}
|
||||
@@ -95,7 +101,7 @@ jobs:
|
||||
}
|
||||
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
for key in any lint biome backend userfront userfront_e2e front_coverage adminfront devfront orgfront; do
|
||||
for key in any lint biome backend userfront userfront_coverage userfront_e2e front_coverage adminfront devfront orgfront; do
|
||||
set_output "$key" true
|
||||
done
|
||||
exit 0
|
||||
@@ -129,6 +135,7 @@ jobs:
|
||||
|
||||
backend=false
|
||||
userfront=false
|
||||
userfront_coverage=false
|
||||
userfront_e2e=false
|
||||
adminfront=false
|
||||
devfront=false
|
||||
@@ -138,6 +145,7 @@ jobs:
|
||||
|
||||
if matches "$global|^backend/"; then backend=true; fi
|
||||
if matches "$global|$i18n_shared|^userfront/"; then userfront=true; fi
|
||||
if matches "$global|$i18n_shared|^userfront/|^scripts/summarize_flutter_coverage\.mjs"; then userfront_coverage=true; fi
|
||||
if matches "$global|$i18n_shared|^userfront/|^userfront-e2e/"; then userfront_e2e=true; fi
|
||||
if matches "$front_shared|^adminfront/"; then adminfront=true; fi
|
||||
if matches "$front_shared|^devfront/"; then devfront=true; fi
|
||||
@@ -151,7 +159,7 @@ jobs:
|
||||
fi
|
||||
|
||||
any=false
|
||||
for value in "$lint" "$biome" "$backend" "$userfront" "$userfront_e2e" "$front_coverage" "$adminfront" "$devfront" "$orgfront"; do
|
||||
for value in "$lint" "$biome" "$backend" "$userfront" "$userfront_coverage" "$userfront_e2e" "$front_coverage" "$adminfront" "$devfront" "$orgfront"; do
|
||||
if [ "$value" = true ]; then any=true; fi
|
||||
done
|
||||
|
||||
@@ -160,6 +168,7 @@ jobs:
|
||||
set_output biome "$biome"
|
||||
set_output backend "$backend"
|
||||
set_output userfront "$userfront"
|
||||
set_output userfront_coverage "$userfront_coverage"
|
||||
set_output userfront_e2e "$userfront_e2e"
|
||||
set_output front_coverage "$front_coverage"
|
||||
set_output adminfront "$adminfront"
|
||||
@@ -352,21 +361,51 @@ jobs:
|
||||
mkdir -p reports
|
||||
set +e
|
||||
cd backend
|
||||
go test -v -coverprofile=../reports/backend-coverage.out -covermode=atomic \
|
||||
./internal/domain \
|
||||
./internal/pagination \
|
||||
./internal/response \
|
||||
./internal/utils \
|
||||
./internal/validator 2>&1 | tee ../reports/backend-coverage.log
|
||||
coverage_exit_code=${PIPESTATUS[0]}
|
||||
|
||||
if [ "$coverage_exit_code" -eq 0 ]; then
|
||||
coverage_percent="$(go tool cover -func=../reports/backend-coverage.out | awk '/^total:/ { gsub(/%/, "", $3); print $3 }')"
|
||||
node -e "const fs = require('node:fs'); const statements = Number(process.argv[1]); fs.writeFileSync('../reports/backend-coverage-summary.json', JSON.stringify({ package: 'backend', statements }, null, 2) + '\n');" "$coverage_percent"
|
||||
{
|
||||
echo "# Backend Coverage Summary"
|
||||
echo
|
||||
echo "| Package | Statements |"
|
||||
echo "| --- | ---: |"
|
||||
printf '| backend | %.2f%% |\n' "$coverage_percent"
|
||||
echo
|
||||
} > ../reports/backend-coverage-summary.md
|
||||
cat ../reports/backend-coverage-summary.md >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
go test -v ./... 2>&1 | tee ../reports/backend-test.log
|
||||
test_exit_code=${PIPESTATUS[0]}
|
||||
cd ..
|
||||
|
||||
if [ "$test_exit_code" -ne 0 ]; then
|
||||
if [ "$coverage_exit_code" -ne 0 ] || [ "$test_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Backend Test Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`backend-tests\`"
|
||||
echo "- Exit Code: \`$test_exit_code\`"
|
||||
echo "- Coverage Exit Code: \`$coverage_exit_code\`"
|
||||
echo "- Test Exit Code: \`$test_exit_code\`"
|
||||
echo
|
||||
echo "## Command"
|
||||
echo "\`go test -v ./...\`"
|
||||
echo
|
||||
if [ -f reports/backend-coverage.log ]; then
|
||||
echo "## Coverage Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/backend-coverage.log
|
||||
echo '```'
|
||||
echo
|
||||
fi
|
||||
echo "## Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/backend-test.log
|
||||
@@ -374,6 +413,9 @@ jobs:
|
||||
} > reports/backend-test-failure-report.md
|
||||
fi
|
||||
|
||||
if [ "$coverage_exit_code" -ne 0 ]; then
|
||||
exit "$coverage_exit_code"
|
||||
fi
|
||||
exit "$test_exit_code"
|
||||
|
||||
- name: Publish backend failure summary
|
||||
@@ -384,14 +426,18 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Upload backend failure report artifact
|
||||
if: ${{ failure() }}
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: backend-test-failure-report
|
||||
name: backend-coverage-report
|
||||
path: |
|
||||
reports/backend-test-failure-report.md
|
||||
reports/backend-test.log
|
||||
reports/backend-coverage.log
|
||||
reports/backend-coverage.out
|
||||
reports/backend-coverage-summary.json
|
||||
reports/backend-coverage-summary.md
|
||||
if-no-files-found: ignore
|
||||
|
||||
userfront-tests:
|
||||
@@ -489,6 +535,86 @@ jobs:
|
||||
reports/userfront-test.log
|
||||
if-no-files-found: ignore
|
||||
|
||||
userfront-flutter-coverage:
|
||||
needs:
|
||||
- changes
|
||||
- lint
|
||||
if: ${{ always() && needs.changes.outputs.userfront_coverage == 'true' && (github.event_name != 'workflow_dispatch' || inputs.run_userfront_coverage == true) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
cache: true
|
||||
|
||||
- name: Sync userfront locales
|
||||
run: |
|
||||
/bin/sh ./scripts/sync_userfront_locales.sh
|
||||
|
||||
- name: Run userfront Flutter coverage
|
||||
run: |
|
||||
cd userfront
|
||||
if [ -d test ]; then
|
||||
mkdir -p ../reports
|
||||
set +e
|
||||
flutter test --coverage 2>&1 | tee ../reports/userfront-flutter-coverage.log
|
||||
test_exit_code=${PIPESTATUS[0]}
|
||||
set -e
|
||||
|
||||
if [ "$test_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Userfront Flutter Coverage Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`userfront-flutter-coverage\`"
|
||||
echo "- Exit Code: \`$test_exit_code\`"
|
||||
echo
|
||||
echo "## Command"
|
||||
echo "\`flutter test --coverage\`"
|
||||
echo
|
||||
if [ -f ../reports/userfront-flutter-coverage.log ]; then
|
||||
echo "## Coverage Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 ../reports/userfront-flutter-coverage.log
|
||||
echo '```'
|
||||
fi
|
||||
} > ../reports/userfront-flutter-coverage-failure-report.md
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No userfront tests: skipping coverage (test/ directory not found)."
|
||||
fi
|
||||
|
||||
- name: Generate userfront Flutter coverage summary
|
||||
run: |
|
||||
node scripts/summarize_flutter_coverage.mjs userfront
|
||||
cat reports/userfront-coverage-summary.md >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Publish userfront Flutter coverage failure summary
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
if [ -f reports/userfront-flutter-coverage-failure-report.md ]; then
|
||||
cat reports/userfront-flutter-coverage-failure-report.md >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
- name: Upload userfront Flutter coverage report artifact
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: userfront-flutter-coverage-report
|
||||
path: |
|
||||
reports/package-coverage-summary.json
|
||||
reports/userfront-coverage-summary.md
|
||||
reports/userfront-flutter-coverage-failure-report.md
|
||||
reports/userfront-flutter-coverage.log
|
||||
userfront/coverage/lcov.info
|
||||
if-no-files-found: ignore
|
||||
|
||||
userfront-e2e-tests:
|
||||
needs:
|
||||
- changes
|
||||
@@ -1601,6 +1727,7 @@ jobs:
|
||||
- biome-check
|
||||
- backend-tests
|
||||
- userfront-tests
|
||||
- userfront-flutter-coverage
|
||||
- userfront-e2e-tests
|
||||
- adminfront-vitest-coverage
|
||||
- devfront-vitest-coverage
|
||||
@@ -1621,6 +1748,20 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Download backend coverage report artifact
|
||||
uses: actions/download-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: backend-coverage-report
|
||||
path: badge-artifacts/backend
|
||||
|
||||
- name: Download userfront Flutter coverage report artifact
|
||||
uses: actions/download-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: userfront-flutter-coverage-report
|
||||
path: badge-artifacts/userfront
|
||||
|
||||
- name: Download adminfront Vitest coverage report artifact
|
||||
uses: actions/download-artifact@v3
|
||||
continue-on-error: true
|
||||
@@ -1647,9 +1788,11 @@ jobs:
|
||||
LINT_RESULT: ${{ needs.lint.result }}
|
||||
BIOME_RESULT: ${{ needs['biome-check'].result }}
|
||||
BACKEND_RESULT: ${{ needs['backend-tests'].result }}
|
||||
BACKEND_COVERAGE_RESULT: ${{ needs['backend-tests'].result }}
|
||||
USERFRONT_RESULT: ${{ needs['userfront-tests'].result }}
|
||||
USERFRONT_E2E_RESULT: ${{ needs['userfront-e2e-tests'].result }}
|
||||
USERFRONT_E2E_FULL: ${{ github.event_name == 'workflow_dispatch' && inputs.run_userfront_e2e_full == true }}
|
||||
USERFRONT_COVERAGE_RESULT: ${{ needs['userfront-flutter-coverage'].result }}
|
||||
ADMINFRONT_COVERAGE_RESULT: ${{ needs['adminfront-vitest-coverage'].result }}
|
||||
DEVFRONT_COVERAGE_RESULT: ${{ needs['devfront-vitest-coverage'].result }}
|
||||
ORGFRONT_COVERAGE_RESULT: ${{ needs['orgfront-vitest-coverage'].result }}
|
||||
|
||||
Reference in New Issue
Block a user