Skip to content

fixed: file download in object Info page #55

fixed: file download in object Info page

fixed: file download in object Info page #55

Workflow file for this run

name: 🧪 Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ============================================================================
# 代码质量检查
# ============================================================================
lint:
name: 🔍 Code Quality
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: 🔍 Run linter
run: ${{ steps.detect-package-manager.outputs.manager }} run lint
- name: 🔍 Type check
run: ${{ steps.detect-package-manager.outputs.manager }} run type-check
# ============================================================================
# 单元测试
# ============================================================================
unit-tests:
name: 🧪 Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
needs: lint
strategy:
matrix:
node-version: [20, 22]
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: |
${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
${{ steps.detect-package-manager.outputs.manager }} add -D vitest jsdom @vitest/ui c8
- name: 🧪 Run unit tests
run: npx vitest run tests/utils/config-helpers.test.ts --reporter=verbose
- name: 📊 Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-results-node-${{ matrix.node-version }}
path: |
coverage/
test-results.xml
retention-days: 7
# ============================================================================
# 集成测试
# ============================================================================
integration-tests:
name: 🔗 Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
needs: lint
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: |
${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
${{ steps.detect-package-manager.outputs.manager }} add -D vitest jsdom @vitest/ui c8
- name: 🔗 Run integration tests
run: npx vitest run tests/utils/config-helpers.integration.test.ts --reporter=verbose
- name: 📊 Upload integration test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results
path: |
coverage/
test-results.xml
retention-days: 7
# ============================================================================
# 代码覆盖率
# ============================================================================
coverage:
name: 📊 Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 15
needs: lint
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: |
${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
${{ steps.detect-package-manager.outputs.manager }} add -D vitest jsdom @vitest/ui c8
- name: 📊 Run tests with coverage
run: npx vitest run tests/utils/config-helpers*.test.ts --coverage --reporter=verbose
env:
CI: true
- name: 📤 Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: config-helpers
name: config-helpers-coverage
fail_ci_if_error: false
- name: 📊 Coverage Summary
run: |
echo "## 📊 Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f coverage/coverage-summary.json ]; then
node -e "
const fs = require('fs');
const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8'));
const total = coverage.total;
console.log('| Metric | Percentage | Covered/Total |');
console.log('|--------|------------|---------------|');
console.log('| Lines | ' + total.lines.pct + '% | ' + total.lines.covered + '/' + total.lines.total + ' |');
console.log('| Functions | ' + total.functions.pct + '% | ' + total.functions.covered + '/' + total.functions.total + ' |');
console.log('| Branches | ' + total.branches.pct + '% | ' + total.branches.covered + '/' + total.branches.total + ' |');
console.log('| Statements | ' + total.statements.pct + '% | ' + total.statements.covered + '/' + total.statements.total + ' |');
" >> $GITHUB_STEP_SUMMARY
fi
- name: 📊 Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 30
# ============================================================================
# 安全扫描
# ============================================================================
security:
name: 🔒 Security Scan
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: 🔒 Run security audit
run: ${{ steps.detect-package-manager.outputs.manager }} audit --audit-level=moderate
- name: 🔍 Run CodeQL Analysis
uses: github/codeql-action/init@v3
with:
languages: javascript
- name: 🔍 Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# ============================================================================
# 构建测试
# ============================================================================
build-test:
name: 🏗️ Build Test
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [coverage, security]
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 10.19.0
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: 📥 Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: 🏗️ Build project
run: ${{ steps.detect-package-manager.outputs.manager }} run build
- name: 📦 Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
.output/
dist/
retention-days: 7
# ============================================================================
# 测试总结
# ============================================================================
test-summary:
name: 📋 Test Summary
runs-on: ubuntu-latest
needs:
[unit-tests, integration-tests, coverage, build-test]
if: always()
steps:
- name: 📥 Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: 📋 Generate test summary
run: |
echo "# 🧪 Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📊 Test Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Test Type | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Unit Tests | ${{ needs.unit-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Integration Tests | ${{ needs.integration-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Coverage | ${{ needs.coverage.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Build Test | ${{ needs.build-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📈 Metrics" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Workflow**: [\#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
- name: 🎉 Success notification
if: needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success' && needs.coverage.result == 'success' && needs.build-test.result == 'success'
run: |
echo "🎉 All tests passed successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The config-helpers module is ready for deployment! 🚀" >> $GITHUB_STEP_SUMMARY