mirror of
https://github.com/personamanagmentlayer/pcl.git
synced 2026-09-14 15:40:22 +08:00
7ef4df47ad
Bumps [actions/github-script](https://github.com/actions/github-script) from 7 to 9. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v7...v9) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: '9' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
243 lines
8.8 KiB
YAML
243 lines
8.8 KiB
YAML
name: PR Checks
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
pull_request_review:
|
|
types: [submitted]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
checks: write
|
|
|
|
jobs:
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# PR VALIDATION
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
validate:
|
|
name: Validate PR
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.draft == false
|
|
|
|
steps:
|
|
- name: 📥 Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: ✅ Check PR title format
|
|
uses: amannn/action-semantic-pull-request@v5
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
types: |
|
|
feat
|
|
fix
|
|
docs
|
|
style
|
|
refactor
|
|
perf
|
|
test
|
|
build
|
|
ci
|
|
chore
|
|
revert
|
|
requireScope: false
|
|
|
|
- name: 📊 PR size check
|
|
run: |
|
|
FILES_CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | wc -l)
|
|
LINES_CHANGED=$(git diff --stat origin/${{ github.base_ref }}...HEAD | tail -1 | awk '{print $4+$6}')
|
|
|
|
echo "📁 Files changed: $FILES_CHANGED"
|
|
echo "📝 Lines changed: $LINES_CHANGED"
|
|
|
|
if [ "$FILES_CHANGED" -gt 100 ]; then
|
|
echo "⚠️ Warning: Large PR with $FILES_CHANGED files changed"
|
|
echo "::warning::Consider breaking this PR into smaller chunks"
|
|
fi
|
|
|
|
if [ "$LINES_CHANGED" -gt 1000 ]; then
|
|
echo "⚠️ Warning: Large PR with $LINES_CHANGED lines changed"
|
|
echo "::warning::Consider breaking this PR into smaller chunks"
|
|
fi
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# CHANGED FILES ANALYSIS
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
analyze-changes:
|
|
name: Analyze Changes
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.draft == false
|
|
|
|
outputs:
|
|
has_src_changes: ${{ steps.filter.outputs.src }}
|
|
has_test_changes: ${{ steps.filter.outputs.tests }}
|
|
has_docs_changes: ${{ steps.filter.outputs.docs }}
|
|
|
|
steps:
|
|
- name: 📥 Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: 🔍 Check changed files
|
|
uses: dorny/paths-filter@v2
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
src:
|
|
- 'src/**/*.ts'
|
|
tests:
|
|
- 'tests/**/*.ts'
|
|
docs:
|
|
- '**.md'
|
|
- 'docs/**'
|
|
|
|
- name: 📝 Comment on missing tests
|
|
if: steps.filter.outputs.src == 'true' && steps.filter.outputs.tests == 'false'
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: '⚠️ **Reminder**: This PR modifies source code but doesn\'t include test updates. Please consider adding tests if applicable.'
|
|
})
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# TEST COVERAGE DIFF
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
coverage-diff:
|
|
name: Coverage Comparison
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.draft == false
|
|
|
|
steps:
|
|
- name: 📥 Checkout PR code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: 🔧 Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: 📦 Install dependencies
|
|
run: npm ci
|
|
|
|
- name: 📊 Run coverage (PR)
|
|
run: npm run test:coverage
|
|
continue-on-error: true
|
|
|
|
- name: 💬 Comment coverage summary
|
|
uses: romeovs/lcov-reporter-action@v0.3.1
|
|
with:
|
|
lcov-file: ./coverage/lcov.info
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
delete-old-comments: true
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# COMPATIBILITY CHECK
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
compatibility:
|
|
name: API Compatibility Check
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.draft == false
|
|
|
|
steps:
|
|
- name: 📥 Checkout base branch
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ github.base_ref }}
|
|
path: base
|
|
continue-on-error: true
|
|
id: checkout-base
|
|
|
|
- name: 📥 Checkout PR branch
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: pr
|
|
|
|
- name: 🔧 Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: 📦 Build base version
|
|
if: steps.checkout-base.outcome == 'success'
|
|
working-directory: base
|
|
continue-on-error: true
|
|
id: build-base
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: 📦 Build PR version
|
|
working-directory: pr
|
|
id: build-pr
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: 🔍 Check for breaking changes
|
|
run: |
|
|
if [ "${{ steps.checkout-base.outcome }}" == "failure" ]; then
|
|
echo "::notice::Base branch checkout failed - this is expected for the first PR to a new branch"
|
|
echo "::notice::Skipping compatibility check"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "${{ steps.build-base.outcome }}" == "failure" ]; then
|
|
echo "::notice::Base branch build failed - this is expected when PR adds new dependencies or files"
|
|
echo "::notice::Skipping API compatibility check for this PR"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "${{ steps.build-pr.outcome }}" == "success" ]; then
|
|
echo "::notice::Both base and PR builds succeeded"
|
|
echo "::notice::🔍 Checking for API breaking changes..."
|
|
# Compare exported types and functions
|
|
# This is a placeholder - add actual API comparison logic
|
|
echo "::notice::✅ No obvious breaking changes detected"
|
|
else
|
|
echo "::error::PR build failed - this needs to be fixed"
|
|
exit 1
|
|
fi
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# PR LABELS
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
label:
|
|
name: Auto-label PR
|
|
runs-on: ubuntu-latest
|
|
needs: [analyze-changes]
|
|
|
|
steps:
|
|
- name: 🏷️ Add labels based on files changed
|
|
uses: actions/labeler@v6
|
|
with:
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
configuration-path: .github/labeler.yml
|
|
sync-labels: true
|
|
|
|
- name: 🏷️ Add size label
|
|
uses: codelytv/pr-size-labeler@v1
|
|
with:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
xs_label: 'size/xs'
|
|
xs_max_size: '10'
|
|
s_label: 'size/s'
|
|
s_max_size: '100'
|
|
m_label: 'size/m'
|
|
m_max_size: '500'
|
|
l_label: 'size/l'
|
|
l_max_size: '1000'
|
|
xl_label: 'size/xl'
|
|
fail_if_xl: 'false'
|