-
Notifications
You must be signed in to change notification settings - Fork 620
feat(ci): refine PR business area labels and introduce skill format check #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 ebd65ed
chore(ci): make PR label sync non-blocking
williamfzc b1599d4
feat(ci): add dry-run mode for PR label sync
williamfzc 04351c7
feat(ci): add PR label dry-run samples
williamfzc 05c50a7
test(ci): update PR label samples with real historical merged PRs
williamfzc 91ce441
feat(ci): add high-level area tags for PRs
williamfzc 5a841dc
refactor(ci): extract pr-label-sync logic to a dedicated directory
williamfzc 8e0c997
refactor(ci): rename pr label script directory for simplicity
williamfzc de656ee
ci: add GitHub Actions workflow to check skill format
williamfzc 7b4657e
test(ci): update sample json to include expected_areas
williamfzc c781307
refactor(scripts): move skill format check to isolated directory and …
williamfzc 117cb8e
test(scripts): add positive and negative tests for skill format check
williamfzc 701160c
fix(scripts): revert skill changes and downgrade version/metadata che…
williamfzc cc58e06
fix(scripts): completely remove version check and skip lark-shared
williamfzc 4df331f
refactor(ci): improve pr-labels script readability and maintainability
williamfzc d0fe4cf
Merge remote-tracking branch 'origin/codex/pr-label-pipeline'
williamfzc 1ecb2f2
Merge remote-tracking branch 'origin/feature/skill-format-check'
williamfzc c9de60f
ci: fix setup-node version in pr-labels workflow
williamfzc b9f2803
tmp
williamfzc 5e7f0d3
refactor(ci): replace generic area labels with business-specific ones
williamfzc 5c5942c
fix(ci): address PR review feedback for label scripts and workflows
williamfzc d272d4d
fix(skill-format-check): address CodeRabbit review feedback
williamfzc 35d8aea
fix: address review comments from PR 148
williamfzc ad6a354
fix: add error handling for directory enumeration in skill-format-check
williamfzc eb83503
docs(skill-format-check): clarify `metadata` requirement in README
williamfzc 445cf0c
test(pr-labels): add real PR edge case samples
williamfzc b2027b4
refactor(ci): migrate pr labels from area to domain prefix
williamfzc 18f74ff
test: use execFileSync instead of execSync in pr-labels test script
williamfzc 26072bb
fix: resolve target path against process.cwd() instead of __dirname i…
williamfzc 405ef15
docs: correct label prefix in PR label workflow README
williamfzc 13b1c49
fix(ci): fix dry-run console output formatting and enforce auth in tests
williamfzc eca66bd
fix(ci): ensure PR labels can be applied reliably
williamfzc 798c039
fix(ci): fix edge cases in pr-label index script
williamfzc d4cd27c
test(ci): clean up PR label test samples
williamfzc 3c22248
fix(ci): bootstrap new labels before applying to PRs
williamfzc fc3985b
test(ci): automate PR label regression testing
williamfzc 3946fcf
Merge branch 'larksuite:main' into main
williamfzc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| 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" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.