Skip to content

Commit c3ea5fb

Browse files
committed
Import v2.0.0 issue-labeler default workflows
1 parent d12915f commit c3ea5fb

File tree

5 files changed

+374
-0
lines changed

5 files changed

+374
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Regularly restore the prediction models from cache to prevent cache eviction
2+
name: "Labeler: Cache Retention"
3+
4+
# For more information about GitHub's action cache limits and eviction policy, see:
5+
# https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
6+
7+
on:
8+
schedule:
9+
- cron: "42 18 * * *" # 18:42 every day (arbitrary time daily)
10+
11+
workflow_dispatch:
12+
inputs:
13+
cache_key:
14+
description: "The cache key suffix to use for restoring the model from cache. Defaults to 'ACTIVE'."
15+
required: true
16+
default: "ACTIVE"
17+
18+
env:
19+
CACHE_KEY: ${{ inputs.cache_key || 'ACTIVE' }}
20+
21+
jobs:
22+
restore-cache:
23+
# Do not automatically run the workflow on forks outside the 'dotnet' org
24+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
type: ["issues", "pulls"]
30+
steps:
31+
- uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
32+
with:
33+
type: ${{ matrix.type }}
34+
cache_key: ${{ env.CACHE_KEY }}
35+
fail-on-cache-miss: true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Predict labels for Issues using a trained model
2+
name: "Labeler: Predict (Issues)"
3+
4+
on:
5+
# Only automatically predict area labels when issues are first opened
6+
issues:
7+
types: opened
8+
9+
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
10+
workflow_dispatch:
11+
inputs:
12+
issues:
13+
description: "Issue Numbers (comma-separated list of ranges)."
14+
required: true
15+
cache_key:
16+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
17+
required: true
18+
default: "ACTIVE"
19+
20+
env:
21+
# Do not allow failure for jobs triggered automatically (as this causes red noise on the workflows list)
22+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
23+
24+
LABEL_PREFIX: "area-"
25+
THRESHOLD: 0.40
26+
DEFAULT_LABEL: "needs-area-label"
27+
EXCLUDED_AUTHORS: "" # Comma-separated list of authors to exclude from training data
28+
29+
jobs:
30+
predict-issue-label:
31+
# Do not automatically run the workflow on forks outside the 'dotnet' org
32+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
33+
runs-on: ubuntu-latest
34+
permissions:
35+
issues: write
36+
steps:
37+
- name: "Restore issues model from cache"
38+
id: restore-model
39+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
40+
with:
41+
type: issues
42+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
43+
quiet: true
44+
45+
- name: "Predict issue labels"
46+
id: prediction
47+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
48+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
49+
with:
50+
issues: ${{ inputs.issues || github.event.issue.number }}
51+
label_prefix: ${{ env.LABEL_PREFIX }}
52+
threshold: ${{ env.THRESHOLD }}
53+
default_label: ${{ env.DEFAULT_LABEL }}
54+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
55+
env:
56+
GITHUB_TOKEN: ${{ github.token }}
57+
continue-on-error: ${{ !env.ALLOW_FAILURE }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Predict labels for Pull Requests using a trained model
2+
name: "Labeler: Predict (Pulls)"
3+
4+
on:
5+
# Per to the following documentation:
6+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target
7+
#
8+
# The `pull_request_target` event runs in the context of the base of the pull request, rather
9+
# than in the context of the merge commit, as the `pull_request` event does. This prevents
10+
# execution of unsafe code from the head of the pull request that could alter the repository
11+
# or steal any secrets you use in your workflow. This event allows your workflow to do things
12+
# like label or comment on pull requests from forks.
13+
#
14+
# Only automatically predict area labels when pull requests are first opened
15+
pull_request_target:
16+
types: opened
17+
18+
# Configure the branches that need to have PRs labeled
19+
branches:
20+
- main
21+
22+
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
23+
workflow_dispatch:
24+
inputs:
25+
pulls:
26+
description: "Pull Request Numbers (comma-separated list of ranges)."
27+
required: true
28+
cache_key:
29+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
30+
required: true
31+
default: "ACTIVE"
32+
33+
env:
34+
# Do not allow failure for jobs triggered automatically (this can block PR merge)
35+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
36+
37+
LABEL_PREFIX: "area-"
38+
THRESHOLD: 0.40
39+
DEFAULT_LABEL: "needs-area-label"
40+
EXCLUDED_AUTHORS: "" # Comma-separated list of authors to exclude from training data
41+
42+
jobs:
43+
predict-pull-label:
44+
# Do not automatically run the workflow on forks outside the 'dotnet' org
45+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
46+
runs-on: ubuntu-latest
47+
permissions:
48+
pull-requests: write
49+
steps:
50+
- name: "Restore pulls model from cache"
51+
id: restore-model
52+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
53+
with:
54+
type: pulls
55+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
56+
quiet: true
57+
58+
- name: "Predict pull labels"
59+
id: prediction
60+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
61+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
62+
with:
63+
pulls: ${{ inputs.pulls || github.event.number }}
64+
label_prefix: ${{ env.LABEL_PREFIX }}
65+
threshold: ${{ env.THRESHOLD }}
66+
default_label: ${{ env.DEFAULT_LABEL }}
67+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
68+
env:
69+
GITHUB_TOKEN: ${{ github.token }}
70+
continue-on-error: ${{ !env.ALLOW_FAILURE }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Promote a model from staging to 'ACTIVE', backing up the currently 'ACTIVE' model
2+
name: "Labeler: Promotion"
3+
4+
on:
5+
# Dispatched via the Actions UI, promotes the staged models from
6+
# a staged slot into the prediction environment
7+
workflow_dispatch:
8+
inputs:
9+
issues:
10+
description: "Issues: Promote Model"
11+
type: boolean
12+
required: true
13+
pulls:
14+
description: "Pulls: Promote Model"
15+
type: boolean
16+
required: true
17+
staged_key:
18+
description: "The cache key suffix to use for promoting a staged model to 'ACTIVE'. Defaults to 'staged'."
19+
required: true
20+
default: "staged"
21+
backup_key:
22+
description: "The cache key suffix to use for backing up the currently active model. Defaults to 'backup'."
23+
default: "backup"
24+
25+
permissions:
26+
actions: write
27+
28+
jobs:
29+
promote-issues:
30+
if: ${{ inputs.issues }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: "Promote Model for Issues"
34+
uses: dotnet/issue-labeler/promote@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
35+
with:
36+
type: "issues"
37+
staged_key: ${{ inputs.staged_key }}
38+
backup_key: ${{ inputs.backup_key }}
39+
40+
promote-pulls:
41+
if: ${{ inputs.pulls }}
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: "Promote Model for Pull Requests"
45+
uses: dotnet/issue-labeler/promote@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
46+
with:
47+
type: "pulls"
48+
staged_key: ${{ inputs.staged_key }}
49+
backup_key: ${{ inputs.backup_key }}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Train the Issues and Pull Requests models for label prediction
2+
name: "Labeler: Training"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
type:
8+
description: "Issues or Pull Requests"
9+
type: choice
10+
required: true
11+
default: "Both"
12+
options:
13+
- "Both"
14+
- "Issues"
15+
- "Pull Requests"
16+
17+
steps:
18+
description: "Training Steps"
19+
type: choice
20+
required: true
21+
default: "All"
22+
options:
23+
- "All"
24+
- "Download Data"
25+
- "Train Model"
26+
- "Test Model"
27+
28+
repository:
29+
description: "The org/repo to download data from. Defaults to the current repository."
30+
limit:
31+
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."
32+
type: number
33+
page_size:
34+
description: "Number of items per page in GitHub API requests. Defaults to 100 for issues, 25 for pull requests."
35+
type: number
36+
page_limit:
37+
description: "Maximum number of pages to download for training/testing the model. Defaults to 1000 for issues, 4000 for pull requests."
38+
type: number
39+
cache_key_suffix:
40+
description: "The cache key suffix to use for staged data/models (use 'ACTIVE' to bypass staging). Defaults to 'staged'."
41+
required: true
42+
default: "staged"
43+
44+
env:
45+
CACHE_KEY: ${{ inputs.cache_key_suffix }}
46+
REPOSITORY: ${{ inputs.repository || github.repository }}
47+
LABEL_PREFIX: "area-"
48+
THRESHOLD: "0.40"
49+
LIMIT: ${{ inputs.limit }}
50+
PAGE_SIZE: ${{ inputs.page_size }}
51+
PAGE_LIMIT: ${{ inputs.page_limit }}
52+
EXCLUDED_AUTHORS: "" # Comma-separated list of authors to exclude from training data
53+
54+
jobs:
55+
download-issues:
56+
if: ${{ contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }}
57+
runs-on: ubuntu-latest
58+
permissions:
59+
issues: read
60+
steps:
61+
- name: "Download Issues"
62+
uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
63+
with:
64+
type: "issues"
65+
cache_key: ${{ env.CACHE_KEY }}
66+
repository: ${{ env.REPOSITORY }}
67+
label_prefix: ${{ env.LABEL_PREFIX }}
68+
limit: ${{ env.LIMIT }}
69+
page_size: ${{ env.PAGE_SIZE }}
70+
page_limit: ${{ env.PAGE_LIMIT }}
71+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
72+
env:
73+
GITHUB_TOKEN: ${{ github.token }}
74+
75+
download-pulls:
76+
if: ${{ contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }}
77+
runs-on: ubuntu-latest
78+
permissions:
79+
pull-requests: read
80+
steps:
81+
- name: "Download Pull Requests"
82+
uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
83+
with:
84+
type: "pulls"
85+
cache_key: ${{ env.CACHE_KEY }}
86+
repository: ${{ env.REPOSITORY }}
87+
label_prefix: ${{ env.LABEL_PREFIX }}
88+
limit: ${{ env.LIMIT }}
89+
page_size: ${{ env.PAGE_SIZE }}
90+
page_limit: ${{ env.PAGE_LIMIT }}
91+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
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+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
140+
env:
141+
GITHUB_TOKEN: ${{ github.token }}
142+
143+
test-pulls:
144+
if: ${{ always() && contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Test Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.train-pulls.result) }}
145+
runs-on: ubuntu-latest
146+
permissions:
147+
pull-requests: read
148+
needs: train-pulls
149+
steps:
150+
- name: "Test Model for Pull Requests"
151+
uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
152+
with:
153+
type: "pulls"
154+
cache_key: ${{ env.CACHE_KEY }}
155+
repository: ${{ env.REPOSITORY }}
156+
label_prefix: ${{ env.LABEL_PREFIX }}
157+
threshold: ${{ env.THRESHOLD }}
158+
limit: ${{ env.LIMIT }}
159+
page_size: ${{ env.PAGE_SIZE }}
160+
page_limit: ${{ env.PAGE_LIMIT }}
161+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
162+
env:
163+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)