Skip to content

Commit 34fae1f

Browse files
authored
Onboard the GitHub Action based Issue-Labeler (#115256)
* Import v2.0.0 issue-labeler default workflows * issue-labeler workflow customization for dotnet/runtime * Document issue-labeler workflow setup and config * Add comments referencing the labeler.md * Make labeler.md wording copy-able across repos
1 parent 6a3a32e commit 34fae1f

6 files changed

+421
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Workflow template imported and updated from:
2+
# https://github.com/dotnet/issue-labeler/wiki/Onboarding
3+
#
4+
# See labeler.md for more information
5+
#
6+
# Regularly restore the prediction models from cache to prevent cache eviction
7+
name: "Labeler: Cache Retention"
8+
9+
# For more information about GitHub's action cache limits and eviction policy, see:
10+
# https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
11+
12+
on:
13+
schedule:
14+
- cron: "58 15 * * *" # 15:58 every day (arbitrary time daily)
15+
16+
workflow_dispatch:
17+
inputs:
18+
cache_key:
19+
description: "The cache key suffix to use for restoring the model from cache. Defaults to 'ACTIVE'."
20+
required: true
21+
default: "ACTIVE"
22+
23+
env:
24+
CACHE_KEY: ${{ inputs.cache_key || 'ACTIVE' }}
25+
26+
jobs:
27+
restore-cache:
28+
# Do not automatically run the workflow on forks outside the 'dotnet' org
29+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
type: ["issues", "pulls"]
35+
steps:
36+
- uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
37+
with:
38+
type: ${{ matrix.type }}
39+
cache_key: ${{ env.CACHE_KEY }}
40+
fail-on-cache-miss: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Workflow template imported and updated from:
2+
# https://github.com/dotnet/issue-labeler/wiki/Onboarding
3+
#
4+
# See labeler.md for more information
5+
#
6+
# Predict labels for Issues using a trained model
7+
name: "Labeler: Predict (Issues)"
8+
9+
on:
10+
# Only automatically predict area labels when issues are first opened
11+
issues:
12+
types: opened
13+
14+
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
15+
workflow_dispatch:
16+
inputs:
17+
issues:
18+
description: "Issue Numbers (comma-separated list of ranges)."
19+
required: true
20+
cache_key:
21+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
22+
required: true
23+
default: "ACTIVE"
24+
25+
env:
26+
# Do not allow failure for jobs triggered automatically (as this causes red noise on the workflows list)
27+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
28+
29+
LABEL_PREFIX: "area-"
30+
THRESHOLD: 0.40
31+
DEFAULT_LABEL: "needs-area-label"
32+
33+
jobs:
34+
predict-issue-label:
35+
# Do not automatically run the workflow on forks outside the 'dotnet' org
36+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
37+
runs-on: ubuntu-latest
38+
permissions:
39+
issues: write
40+
steps:
41+
- name: "Restore issues model from cache"
42+
id: restore-model
43+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
44+
with:
45+
type: issues
46+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
47+
quiet: true
48+
49+
- name: "Predict issue labels"
50+
id: prediction
51+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
52+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
53+
with:
54+
issues: ${{ inputs.issues || github.event.issue.number }}
55+
label_prefix: ${{ env.LABEL_PREFIX }}
56+
threshold: ${{ env.THRESHOLD }}
57+
default_label: ${{ env.DEFAULT_LABEL }}
58+
env:
59+
GITHUB_TOKEN: ${{ github.token }}
60+
continue-on-error: ${{ !env.ALLOW_FAILURE }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Workflow template imported and updated from:
2+
# https://github.com/dotnet/issue-labeler/wiki/Onboarding
3+
#
4+
# See labeler.md for more information
5+
#
6+
# Predict labels for Pull Requests using a trained model
7+
name: "Labeler: Predict (Pulls)"
8+
9+
on:
10+
# Per to the following documentation:
11+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target
12+
#
13+
# The `pull_request_target` event runs in the context of the base of the pull request, rather
14+
# than in the context of the merge commit, as the `pull_request` event does. This prevents
15+
# execution of unsafe code from the head of the pull request that could alter the repository
16+
# or steal any secrets you use in your workflow. This event allows your workflow to do things
17+
# like label or comment on pull requests from forks.
18+
#
19+
# Only automatically predict area labels when pull requests are first opened
20+
pull_request_target:
21+
types: opened
22+
23+
# Configure the branches that need to have PRs labeled
24+
branches:
25+
- 'main'
26+
- 'release/*'
27+
28+
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
29+
workflow_dispatch:
30+
inputs:
31+
pulls:
32+
description: "Pull Request Numbers (comma-separated list of ranges)."
33+
required: true
34+
cache_key:
35+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
36+
required: true
37+
default: "ACTIVE"
38+
39+
env:
40+
# Do not allow failure for jobs triggered automatically (this can block PR merge)
41+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
42+
43+
LABEL_PREFIX: "area-"
44+
THRESHOLD: 0.40
45+
DEFAULT_LABEL: "needs-area-label"
46+
47+
jobs:
48+
predict-pull-label:
49+
# Do not automatically run the workflow on forks outside the 'dotnet' org
50+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
51+
runs-on: ubuntu-latest
52+
permissions:
53+
pull-requests: write
54+
steps:
55+
- name: "Restore pulls model from cache"
56+
id: restore-model
57+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
58+
with:
59+
type: pulls
60+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
61+
quiet: true
62+
63+
- name: "Predict pull labels"
64+
id: prediction
65+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
66+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
67+
with:
68+
pulls: ${{ inputs.pulls || github.event.number }}
69+
label_prefix: ${{ env.LABEL_PREFIX }}
70+
threshold: ${{ env.THRESHOLD }}
71+
default_label: ${{ env.DEFAULT_LABEL }}
72+
env:
73+
GITHUB_TOKEN: ${{ github.token }}
74+
continue-on-error: ${{ !env.ALLOW_FAILURE }}

.github/workflows/labeler-promote.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Workflow template imported and updated from:
2+
# https://github.com/dotnet/issue-labeler/wiki/Onboarding
3+
#
4+
# See labeler.md for more information
5+
#
6+
# Promote a model from staging to 'ACTIVE', backing up the currently 'ACTIVE' model
7+
name: "Labeler: Promotion"
8+
9+
on:
10+
# Dispatched via the Actions UI, promotes the staged models from
11+
# a staged slot into the prediction environment
12+
workflow_dispatch:
13+
inputs:
14+
issues:
15+
description: "Issues: Promote Model"
16+
type: boolean
17+
required: true
18+
pulls:
19+
description: "Pulls: Promote Model"
20+
type: boolean
21+
required: true
22+
staged_key:
23+
description: "The cache key suffix to use for promoting a staged model to 'ACTIVE'. Defaults to 'staged'."
24+
required: true
25+
default: "staged"
26+
backup_key:
27+
description: "The cache key suffix to use for backing up the currently active model. Defaults to 'backup'."
28+
default: "backup"
29+
30+
permissions:
31+
actions: write
32+
33+
jobs:
34+
promote-issues:
35+
if: ${{ inputs.issues }}
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: "Promote Model for Issues"
39+
uses: dotnet/issue-labeler/promote@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
40+
with:
41+
type: "issues"
42+
staged_key: ${{ inputs.staged_key }}
43+
backup_key: ${{ inputs.backup_key }}
44+
45+
promote-pulls:
46+
if: ${{ inputs.pulls }}
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: "Promote Model for Pull Requests"
50+
uses: dotnet/issue-labeler/promote@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
51+
with:
52+
type: "pulls"
53+
staged_key: ${{ inputs.staged_key }}
54+
backup_key: ${{ inputs.backup_key }}

.github/workflows/labeler-train.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Workflow template imported and updated from:
2+
# https://github.com/dotnet/issue-labeler/wiki/Onboarding
3+
#
4+
# See labeler.md for more information
5+
#
6+
# Train the Issues and Pull Requests models for label prediction
7+
name: "Labeler: Training"
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
type:
13+
description: "Issues or Pull Requests"
14+
type: choice
15+
required: true
16+
default: "Both"
17+
options:
18+
- "Both"
19+
- "Issues"
20+
- "Pull Requests"
21+
22+
steps:
23+
description: "Training Steps"
24+
type: choice
25+
required: true
26+
default: "All"
27+
options:
28+
- "All"
29+
- "Download Data"
30+
- "Train Model"
31+
- "Test Model"
32+
33+
limit:
34+
description: "Max number of items to download for training/testing the model (newest items are used). Defaults to the max number of pages times the page size."
35+
type: number
36+
page_size:
37+
description: "Number of items per page in GitHub API requests. Defaults to 100 for issues, 25 for pull requests."
38+
type: number
39+
page_limit:
40+
description: "Maximum number of pages to download for training/testing the model. Defaults to 1000 for issues, 4000 for pull requests."
41+
type: number
42+
cache_key_suffix:
43+
description: "The cache key suffix to use for staged data/models (use 'ACTIVE' to bypass staging). Defaults to 'staged'."
44+
required: true
45+
default: "staged"
46+
47+
env:
48+
CACHE_KEY: ${{ inputs.cache_key_suffix }}
49+
REPOSITORY: ${{ github.repository }}
50+
LABEL_PREFIX: "area-"
51+
THRESHOLD: "0.40"
52+
LIMIT: ${{ inputs.limit }}
53+
PAGE_SIZE: ${{ inputs.page_size }}
54+
PAGE_LIMIT: ${{ inputs.page_limit }}
55+
56+
jobs:
57+
download-issues:
58+
if: ${{ contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }}
59+
runs-on: ubuntu-latest
60+
permissions:
61+
issues: read
62+
steps:
63+
- name: "Download Issues"
64+
uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
65+
with:
66+
type: "issues"
67+
cache_key: ${{ env.CACHE_KEY }}
68+
repository: ${{ env.REPOSITORY }}
69+
label_prefix: ${{ env.LABEL_PREFIX }}
70+
limit: ${{ env.LIMIT }}
71+
page_size: ${{ env.PAGE_SIZE }}
72+
page_limit: ${{ env.PAGE_LIMIT }}
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
76+
download-pulls:
77+
if: ${{ contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }}
78+
runs-on: ubuntu-latest
79+
permissions:
80+
pull-requests: read
81+
steps:
82+
- name: "Download Pull Requests"
83+
uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
84+
with:
85+
type: "pulls"
86+
cache_key: ${{ env.CACHE_KEY }}
87+
repository: ${{ env.REPOSITORY }}
88+
label_prefix: ${{ env.LABEL_PREFIX }}
89+
limit: ${{ env.LIMIT }}
90+
page_size: ${{ env.PAGE_SIZE }}
91+
page_limit: ${{ env.PAGE_LIMIT }}
92+
env:
93+
GITHUB_TOKEN: ${{ github.token }}
94+
95+
train-issues:
96+
if: ${{ always() && contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Train Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.download-issues.result) }}
97+
runs-on: ubuntu-latest
98+
permissions: {}
99+
needs: download-issues
100+
steps:
101+
- name: "Train Model for Issues"
102+
uses: dotnet/issue-labeler/train@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
103+
with:
104+
type: "issues"
105+
data_cache_key: ${{ env.CACHE_KEY }}
106+
model_cache_key: ${{ env.CACHE_KEY }}
107+
108+
train-pulls:
109+
if: ${{ always() && contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Train Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.download-pulls.result) }}
110+
runs-on: ubuntu-latest
111+
permissions: {}
112+
needs: download-pulls
113+
steps:
114+
- name: "Train Model for Pull Requests"
115+
uses: dotnet/issue-labeler/train@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
116+
with:
117+
type: "pulls"
118+
data_cache_key: ${{ env.CACHE_KEY }}
119+
model_cache_key: ${{ env.CACHE_KEY }}
120+
121+
test-issues:
122+
if: ${{ always() && contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Test Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.train-issues.result) }}
123+
runs-on: ubuntu-latest
124+
permissions:
125+
issues: read
126+
needs: train-issues
127+
steps:
128+
- name: "Test Model for Issues"
129+
uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
130+
with:
131+
type: "issues"
132+
cache_key: ${{ env.CACHE_KEY }}
133+
repository: ${{ env.REPOSITORY }}
134+
label_prefix: ${{ env.LABEL_PREFIX }}
135+
threshold: ${{ env.THRESHOLD }}
136+
limit: ${{ env.LIMIT }}
137+
page_size: ${{ env.PAGE_SIZE }}
138+
page_limit: ${{ env.PAGE_LIMIT }}
139+
env:
140+
GITHUB_TOKEN: ${{ github.token }}
141+
142+
test-pulls:
143+
if: ${{ always() && contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Test Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.train-pulls.result) }}
144+
runs-on: ubuntu-latest
145+
permissions:
146+
pull-requests: read
147+
needs: train-pulls
148+
steps:
149+
- name: "Test Model for Pull Requests"
150+
uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
151+
with:
152+
type: "pulls"
153+
cache_key: ${{ env.CACHE_KEY }}
154+
repository: ${{ env.REPOSITORY }}
155+
label_prefix: ${{ env.LABEL_PREFIX }}
156+
threshold: ${{ env.THRESHOLD }}
157+
limit: ${{ env.LIMIT }}
158+
page_size: ${{ env.PAGE_SIZE }}
159+
page_limit: ${{ env.PAGE_LIMIT }}
160+
env:
161+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)