Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bb25eb8
feat(ci): add PR size label pipeline
williamfzc Mar 31, 2026
ebd65ed
chore(ci): make PR label sync non-blocking
williamfzc Mar 31, 2026
b1599d4
feat(ci): add dry-run mode for PR label sync
williamfzc Mar 31, 2026
04351c7
feat(ci): add PR label dry-run samples
williamfzc Mar 31, 2026
05c50a7
test(ci): update PR label samples with real historical merged PRs
williamfzc Mar 31, 2026
91ce441
feat(ci): add high-level area tags for PRs
williamfzc Mar 31, 2026
5a841dc
refactor(ci): extract pr-label-sync logic to a dedicated directory
williamfzc Mar 31, 2026
8e0c997
refactor(ci): rename pr label script directory for simplicity
williamfzc Mar 31, 2026
de656ee
ci: add GitHub Actions workflow to check skill format
williamfzc Mar 31, 2026
7b4657e
test(ci): update sample json to include expected_areas
williamfzc Mar 31, 2026
c781307
refactor(scripts): move skill format check to isolated directory and …
williamfzc Mar 31, 2026
117cb8e
test(scripts): add positive and negative tests for skill format check
williamfzc Mar 31, 2026
701160c
fix(scripts): revert skill changes and downgrade version/metadata che…
williamfzc Mar 31, 2026
cc58e06
fix(scripts): completely remove version check and skip lark-shared
williamfzc Mar 31, 2026
4df331f
refactor(ci): improve pr-labels script readability and maintainability
williamfzc Mar 31, 2026
d0fe4cf
Merge remote-tracking branch 'origin/codex/pr-label-pipeline'
williamfzc Mar 31, 2026
1ecb2f2
Merge remote-tracking branch 'origin/feature/skill-format-check'
williamfzc Mar 31, 2026
c9de60f
ci: fix setup-node version in pr-labels workflow
williamfzc Mar 31, 2026
b9f2803
tmp
williamfzc Mar 31, 2026
5e7f0d3
refactor(ci): replace generic area labels with business-specific ones
williamfzc Mar 31, 2026
5c5942c
fix(ci): address PR review feedback for label scripts and workflows
williamfzc Mar 31, 2026
d272d4d
fix(skill-format-check): address CodeRabbit review feedback
williamfzc Mar 31, 2026
35d8aea
fix: address review comments from PR 148
williamfzc Mar 31, 2026
ad6a354
fix: add error handling for directory enumeration in skill-format-check
williamfzc Mar 31, 2026
eb83503
docs(skill-format-check): clarify `metadata` requirement in README
williamfzc Mar 31, 2026
445cf0c
test(pr-labels): add real PR edge case samples
williamfzc Mar 31, 2026
b2027b4
refactor(ci): migrate pr labels from area to domain prefix
williamfzc Mar 31, 2026
18f74ff
test: use execFileSync instead of execSync in pr-labels test script
williamfzc Mar 31, 2026
26072bb
fix: resolve target path against process.cwd() instead of __dirname i…
williamfzc Mar 31, 2026
405ef15
docs: correct label prefix in PR label workflow README
williamfzc Mar 31, 2026
13b1c49
fix(ci): fix dry-run console output formatting and enforce auth in tests
williamfzc Mar 31, 2026
eca66bd
fix(ci): ensure PR labels can be applied reliably
williamfzc Mar 31, 2026
798c039
fix(ci): fix edge cases in pr-label index script
williamfzc Mar 31, 2026
d4cd27c
test(ci): clean up PR label test samples
williamfzc Mar 31, 2026
3c22248
fix(ci): bootstrap new labels before applying to PRs
williamfzc Mar 31, 2026
fc3985b
test(ci): automate PR label regression testing
williamfzc Mar 31, 2026
3946fcf
Merge branch 'larksuite:main' into main
williamfzc Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pr-labels-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test PR Label Logic

on:
push:
branches: [main]
paths:
- "scripts/pr-labels/**"
- ".github/workflows/pr-labels-test.yml"
pull_request:
branches: [main]
paths:
- "scripts/pr-labels/**"
- ".github/workflows/pr-labels-test.yml"

permissions:
contents: read

jobs:
test-pr-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run PR label regression tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/pr-labels/test.js
43 changes: 43 additions & 0 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR Labels

on:
pull_request_target:
# NOTE: This event runs with base-branch code and write permissions.
# Do NOT add `ref: github.event.pull_request.head.sha` to the checkout step,
# as that would execute untrusted PR code with elevated access.
types:
- opened
- edited
- reopened
- synchronize
- ready_for_review
Comment thread
coderabbitai[bot] marked this conversation as resolved.

permissions:
contents: read
pull-requests: write
issues: write

jobs:
sync-pr-labels:
if: ${{ github.event.pull_request.state == 'open' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Sync managed PR labels
id: sync_pr_labels
# Labeling is best-effort and must not block PR merges.
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/pr-labels/index.js

- name: Warn when label sync fails
if: ${{ always() && steps.sync_pr_labels.outcome == 'failure' }}
run: |
echo "::warning::PR label sync failed; labels may be stale."
echo "⚠️ PR label sync failed; labels may be stale." >> "$GITHUB_STEP_SUMMARY"
32 changes: 32 additions & 0 deletions .github/workflows/skill-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Skill Format Check

on:
push:
branches: [main]
paths:
- "skills/**"
- "scripts/skill-format-check/**"
- ".github/workflows/skill-format-check.yml"
pull_request:
branches: [main]
paths:
- "skills/**"
- "scripts/skill-format-check/**"
- ".github/workflows/skill-format-check.yml"

permissions:
contents: read

jobs:
check-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run Skill Format Check
run: node scripts/skill-format-check/index.js
58 changes: 58 additions & 0 deletions scripts/pr-labels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# PR Label Sync

This directory contains scripts and sample data for automatically classifying and labeling GitHub Pull Requests based on the files they modify.

## Files

- `index.js`: The main Node.js script. It fetches PR files, evaluates their risk level, calculates business impact, and uses GitHub APIs to add appropriate `size/*` and `domain/*` labels.
- `samples.json`: A collection of historical PRs used as test cases to verify the labeling logic (especially for regression testing the S/M/L thresholds).

## Features

### Size Labels (`size/*`)
The script evaluates the "effective" lines of code changed (ignoring tests, docs, and ci files) to classify the PR:
- **`size/S`**: Low-risk changes involving only docs, tests, CI workflows, or chores.
- **`size/M`**: Small-to-medium changes affecting a single business domain, with effective lines under 300.
- **`size/L`**: Large features (>= 300 lines), cross-domain changes, or any changes touching core architecture paths (like `cmd/`).
- **`size/XL`**: Architectural overhauls, extremely large PRs (>1200 lines), or sensitive refactors.

### Domain Tags (`domain/*`)
The script also identifies which business domains a PR touches to give reviewers an immediate sense of the impact scope. Currently tracked domains include:
- `domain/im`
- `domain/vc`
- `domain/ccm`
- `domain/base`
- `domain/mail`
- `domain/calendar`
- `domain/task`
- `domain/contact`

Minor modules like docs and tests are omitted to keep PR tags clean and focused on structural changes.

## Usage

### In GitHub Actions
This script is designed to run in CI workflows. It automatically reads the `GITHUB_EVENT_PATH` payload to get the PR context.

```bash
node scripts/pr-labels/index.js
```

### Local Dry Run
You can test the labeling logic against an existing GitHub PR without actually applying labels by using the `--dry-run` flag.

```bash
# Requires GITHUB_TOKEN environment variable or passing --token
node scripts/pr-labels/index.js --dry-run --repo larksuite/cli --pr-number 123
```

## Testing

A regression test suite is available in `test.js` which verifies the output of the classification logic against historical PRs configured in `samples.json`.

```bash
# Requires GITHUB_TOKEN environment variable to avoid rate limits
GITHUB_TOKEN=$(gh auth token) node scripts/pr-labels/test.js
```

This test suite also runs automatically in CI via `.github/workflows/pr-labels-test.yml` when changes are made to this directory.
Loading
Loading