forked from baron/baron-sso
ci: add code check badges and coverage reports
This commit is contained in:
@@ -4,6 +4,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths-ignore:
|
||||
- "docs/badges/**"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
@@ -49,6 +51,14 @@ on:
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
run_front_coverage:
|
||||
description: "Run adminfront/devfront/orgfront Vitest coverage and upload reports"
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -148,6 +158,51 @@ jobs:
|
||||
cd userfront
|
||||
flutter analyze --no-fatal-warnings --no-fatal-infos
|
||||
|
||||
biome-check:
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || inputs.run_lint == true }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Install adminfront dependencies
|
||||
run: |
|
||||
cd adminfront
|
||||
npx pnpm install -C ../common --no-frozen-lockfile
|
||||
|
||||
- name: Biome check adminfront
|
||||
run: |
|
||||
cd adminfront
|
||||
npx biome check . --formatter-enabled=false --organize-imports-enabled=false
|
||||
npx biome check . --linter-enabled=false --organize-imports-enabled=false
|
||||
|
||||
- name: Install devfront dependencies
|
||||
run: |
|
||||
cd devfront
|
||||
npx pnpm install -C ../common --no-frozen-lockfile
|
||||
|
||||
- name: Biome check devfront
|
||||
run: |
|
||||
cd devfront
|
||||
npx biome check . --formatter-enabled=false --organize-imports-enabled=false
|
||||
npx biome check . --linter-enabled=false --organize-imports-enabled=false
|
||||
|
||||
- name: Install orgfront dependencies
|
||||
run: |
|
||||
cd orgfront
|
||||
npx pnpm install -C ../common --no-frozen-lockfile
|
||||
|
||||
- name: Biome check orgfront
|
||||
run: |
|
||||
cd orgfront
|
||||
npx biome check . --formatter-enabled=false --organize-imports-enabled=false
|
||||
npx biome check . --linter-enabled=false --organize-imports-enabled=false
|
||||
|
||||
backend-tests:
|
||||
needs: lint
|
||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_backend_tests == true) }}
|
||||
@@ -570,6 +625,159 @@ jobs:
|
||||
userfront-e2e/test-results
|
||||
if-no-files-found: ignore
|
||||
|
||||
front-vitest-coverage:
|
||||
needs: lint
|
||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_front_coverage == true) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Install front workspace dependencies
|
||||
run: |
|
||||
mkdir -p reports
|
||||
set +e
|
||||
npm install -g pnpm
|
||||
cd common
|
||||
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
||||
install_exit_code=${PIPESTATUS[0]}
|
||||
cd ..
|
||||
set -e
|
||||
|
||||
if [ "$install_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Front Vitest Coverage Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`front-vitest-coverage\`"
|
||||
echo "- Reason: \`Dependency install failed\`"
|
||||
echo "- Exit Code: \`$install_exit_code\`"
|
||||
echo
|
||||
echo "## Command"
|
||||
echo "\`cd common && pnpm install --no-frozen-lockfile --shamefully-hoist\`"
|
||||
echo
|
||||
echo "## Install Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/front-coverage-install.log
|
||||
echo '```'
|
||||
} > reports/front-vitest-coverage-failure-report.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run adminfront Vitest coverage
|
||||
run: |
|
||||
set +e
|
||||
cd adminfront
|
||||
pnpm run test:coverage 2>&1 | tee ../reports/adminfront-vitest-coverage.log
|
||||
test_exit_code=${PIPESTATUS[0]}
|
||||
cd ..
|
||||
set -e
|
||||
|
||||
if [ "$test_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Front Vitest Coverage Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`front-vitest-coverage\`"
|
||||
echo "- Package: \`adminfront\`"
|
||||
echo "- Exit Code: \`$test_exit_code\`"
|
||||
echo
|
||||
echo "## Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/adminfront-vitest-coverage.log
|
||||
echo '```'
|
||||
} > reports/front-vitest-coverage-failure-report.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run devfront Vitest coverage
|
||||
run: |
|
||||
set +e
|
||||
cd devfront
|
||||
pnpm run test:coverage 2>&1 | tee ../reports/devfront-vitest-coverage.log
|
||||
test_exit_code=${PIPESTATUS[0]}
|
||||
cd ..
|
||||
set -e
|
||||
|
||||
if [ "$test_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Front Vitest Coverage Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`front-vitest-coverage\`"
|
||||
echo "- Package: \`devfront\`"
|
||||
echo "- Exit Code: \`$test_exit_code\`"
|
||||
echo
|
||||
echo "## Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/devfront-vitest-coverage.log
|
||||
echo '```'
|
||||
} > reports/front-vitest-coverage-failure-report.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run orgfront Vitest coverage
|
||||
run: |
|
||||
set +e
|
||||
cd orgfront
|
||||
pnpm run test:coverage 2>&1 | tee ../reports/orgfront-vitest-coverage.log
|
||||
test_exit_code=${PIPESTATUS[0]}
|
||||
cd ..
|
||||
set -e
|
||||
|
||||
if [ "$test_exit_code" -ne 0 ]; then
|
||||
{
|
||||
echo "# Front Vitest Coverage Failure Report"
|
||||
echo
|
||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||
echo "- Job: \`front-vitest-coverage\`"
|
||||
echo "- Package: \`orgfront\`"
|
||||
echo "- Exit Code: \`$test_exit_code\`"
|
||||
echo
|
||||
echo "## Log Tail (last 200 lines)"
|
||||
echo '```text'
|
||||
tail -n 200 reports/orgfront-vitest-coverage.log
|
||||
echo '```'
|
||||
} > reports/front-vitest-coverage-failure-report.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Generate Vitest coverage summary
|
||||
run: |
|
||||
node scripts/summarize_vitest_coverage.mjs
|
||||
cat reports/vitest-coverage-summary.md >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Publish front Vitest coverage failure summary
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
if [ -f reports/front-vitest-coverage-failure-report.md ]; then
|
||||
cat reports/front-vitest-coverage-failure-report.md >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
- name: Upload front Vitest coverage report artifact
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: front-vitest-coverage-report
|
||||
path: |
|
||||
reports/vitest-coverage-summary.md
|
||||
reports/vitest-coverage-summary.json
|
||||
reports/front-vitest-coverage-failure-report.md
|
||||
reports/front-coverage-install.log
|
||||
reports/adminfront-vitest-coverage.log
|
||||
reports/devfront-vitest-coverage.log
|
||||
reports/orgfront-vitest-coverage.log
|
||||
adminfront/coverage
|
||||
devfront/coverage
|
||||
orgfront/coverage
|
||||
if-no-files-found: ignore
|
||||
|
||||
adminfront-tests:
|
||||
needs: lint
|
||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_adminfront_tests == true) }}
|
||||
@@ -1021,3 +1229,63 @@ jobs:
|
||||
orgfront/playwright-report
|
||||
orgfront/test-results
|
||||
if-no-files-found: ignore
|
||||
|
||||
badge-updater:
|
||||
needs:
|
||||
- lint
|
||||
- biome-check
|
||||
- backend-tests
|
||||
- userfront-tests
|
||||
- userfront-e2e-tests
|
||||
- front-vitest-coverage
|
||||
- adminfront-tests
|
||||
- devfront-tests
|
||||
- orgfront-tests
|
||||
if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Download Vitest coverage report artifact
|
||||
uses: actions/download-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: front-vitest-coverage-report
|
||||
path: badge-artifacts/front-vitest-coverage-report
|
||||
|
||||
- name: Update badge files
|
||||
env:
|
||||
LINT_RESULT: ${{ needs.lint.result }}
|
||||
BIOME_RESULT: ${{ needs['biome-check'].result }}
|
||||
BACKEND_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 }}
|
||||
COVERAGE_RESULT: ${{ needs['front-vitest-coverage'].result }}
|
||||
ADMINFRONT_RESULT: ${{ needs['adminfront-tests'].result }}
|
||||
DEVFRONT_RESULT: ${{ needs['devfront-tests'].result }}
|
||||
ORGFRONT_RESULT: ${{ needs['orgfront-tests'].result }}
|
||||
run: |
|
||||
node scripts/update_code_check_badges.mjs
|
||||
cat docs/badges/badges.json
|
||||
|
||||
- name: Commit badge updates
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain docs/badges)" ]; then
|
||||
echo "No badge changes."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.name "gitea-actions"
|
||||
git config user.email "gitea-actions@hmac.kr"
|
||||
git add docs/badges
|
||||
git commit -m "chore: update code check badges [skip ci]"
|
||||
git push
|
||||
|
||||
Reference in New Issue
Block a user