Skip to content

Commit 7efd8a4

Browse files
authored
Upgrade Issue-Labeler to v2.0.0 (#9074)
* Import v2.0.0 issue-labeler default workflows * issue-labeler workflow customization for dotnet/aspire
1 parent e08e36e commit 7efd8a4

6 files changed

+294
-129
lines changed

.github/workflows/labeler-build-predictor.yml

-17
This file was deleted.
+26-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1+
# Regularly restore the prediction models from cache to prevent cache eviction
12
name: "Labeler: Cache Retention"
23

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+
37
on:
48
schedule:
59
- cron: "25 22 * * *" # 22:25 every day (arbitrary time daily)
610

711
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' }}
820

921
jobs:
10-
cache-retention:
11-
# Do not run the workflow on forks outside the 'dotnet' org
12-
if: ${{ github.repository_owner == 'dotnet' }}
13-
uses: dotnet/issue-labeler/.github/workflows/cache-retention.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
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
+44-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,57 @@
1-
name: "Labeler: Predict Issue Labels"
1+
# Predict labels for Issues using a trained model
2+
name: "Labeler: Predict (Issues)"
23

34
on:
4-
# Only automatically predict area labels when issues are originally opened
5+
# Only automatically predict area labels when issues are first opened
56
issues:
67
types: opened
78

89
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
910
workflow_dispatch:
1011
inputs:
11-
issue_numbers:
12-
description: "Issue Numbers (comma-separated list of ranges)"
13-
type: string
14-
model_cache_key:
15-
description: "The cache key suffix to use for loading the model"
16-
type: string
12+
issues:
13+
description: "Issue Numbers (comma-separated list of ranges)."
1714
required: true
18-
default: "LIVE"
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
1928

2029
jobs:
21-
predict-issues:
22-
# Do not run the workflow on forks outside the 'dotnet' org
23-
if: ${{ github.repository_owner == 'dotnet' && (inputs.issue_numbers || github.event.issue.number) }}
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
2434
permissions:
2535
issues: write
26-
uses: dotnet/issue-labeler/.github/workflows/predict-issues.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
27-
with:
28-
model_cache_key: ${{ inputs.model_cache_key }}
29-
issue_numbers: ${{ inputs.issue_numbers || github.event.issue.number }}
30-
label_prefix: "area-"
31-
threshold: 0.40
32-
default_label: "needs-area-label"
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 }}
+45-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: "Labeler: Predict Pull Labels"
1+
# Predict labels for Pull Requests using a trained model
2+
name: "Labeler: Predict (Pulls)"
23

34
on:
45
# Per to the following documentation:
@@ -13,32 +14,58 @@ on:
1314
# Only automatically predict area labels when pull requests are first opened
1415
pull_request_target:
1516
types: opened
17+
18+
# Configure the branches that need to have PRs labeled
1619
branches:
1720
- 'main'
1821
- 'release/**'
1922

2023
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
2124
workflow_dispatch:
2225
inputs:
23-
pull_numbers:
24-
description: "Pull Numbers (comma-separated list of ranges)"
25-
type: string
26-
model_cache_key:
27-
description: "The cache key suffix to use for loading the model"
28-
type: string
26+
pulls:
27+
description: "Pull Request Numbers (comma-separated list of ranges)."
28+
required: true
29+
cache_key:
30+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
2931
required: true
30-
default: "LIVE"
32+
default: "ACTIVE"
33+
34+
env:
35+
# Do not allow failure for jobs triggered automatically (this can block PR merge)
36+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
37+
38+
LABEL_PREFIX: "area-"
39+
THRESHOLD: 0.40
40+
DEFAULT_LABEL: "needs-area-label"
41+
EXCLUDED_AUTHORS: "" # Comma-separated list of authors to exclude from training data
3142

3243
jobs:
33-
predict-pulls:
34-
# Do not run the workflow on forks outside the 'dotnet' org
35-
if: ${{ github.repository_owner == 'dotnet' && (inputs.pull_numbers || github.event.number) }}
44+
predict-pull-label:
45+
# Do not automatically run the workflow on forks outside the 'dotnet' org
46+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
47+
runs-on: ubuntu-latest
3648
permissions:
3749
pull-requests: write
38-
uses: dotnet/issue-labeler/.github/workflows/predict-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
39-
with:
40-
model_cache_key: ${{ inputs.model_cache_key }}
41-
pull_numbers: ${{ inputs.pull_numbers || github.event.number }}
42-
label_prefix: "area-"
43-
threshold: 0.40
44-
default_label: "needs-area-label"
50+
steps:
51+
- name: "Restore pulls model from cache"
52+
id: restore-model
53+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
54+
with:
55+
type: pulls
56+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
57+
quiet: true
58+
59+
- name: "Predict pull labels"
60+
id: prediction
61+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
62+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
63+
with:
64+
pulls: ${{ inputs.pulls || github.event.number }}
65+
label_prefix: ${{ env.LABEL_PREFIX }}
66+
threshold: ${{ env.THRESHOLD }}
67+
default_label: ${{ env.DEFAULT_LABEL }}
68+
excluded_authors: ${{ env.EXCLUDED_AUTHORS }}
69+
env:
70+
GITHUB_TOKEN: ${{ github.token }}
71+
continue-on-error: ${{ !env.ALLOW_FAILURE }}

.github/workflows/labeler-promote.yml

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
1-
name: "Labeler: Promote Models"
1+
# Promote a model from staging to 'ACTIVE', backing up the currently 'ACTIVE' model
2+
name: "Labeler: Promotion"
23

34
on:
45
# Dispatched via the Actions UI, promotes the staged models from
5-
# a staging slot into the prediction environment
6+
# a staged slot into the prediction environment
67
workflow_dispatch:
78
inputs:
8-
promote_issues:
9+
issues:
910
description: "Issues: Promote Model"
1011
type: boolean
1112
required: true
12-
promote_pulls:
13+
pulls:
1314
description: "Pulls: Promote Model"
1415
type: boolean
1516
required: true
16-
model_cache_key:
17-
description: "The cache key suffix to promote into the 'LIVE' cache"
18-
type: string
17+
staged_key:
18+
description: "The cache key suffix to use for promoting a staged model to 'ACTIVE'. Defaults to 'staged'."
1919
required: true
20-
default: "staging"
21-
backup_cache_key:
22-
description: "The cache key suffix to use for backing up the currently promoted model"
23-
type: string
20+
default: "staged"
21+
backup_key:
22+
description: "The cache key suffix to use for backing up the currently active model. Defaults to 'backup'."
2423
default: "backup"
2524

2625
permissions:
2726
actions: write
2827

2928
jobs:
30-
labeler-promote-issues:
31-
if: ${{ inputs.promote_issues }}
32-
uses: dotnet/issue-labeler/.github/workflows/promote-issues.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
33-
with:
34-
model_cache_key: ${{ inputs.model_cache_key }}
35-
backup_cache_key: ${{ inputs.backup_cache_key }}
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 }}
3639

37-
labeler-promote-pulls:
38-
if: ${{ inputs.promote_pulls }}
39-
uses: dotnet/issue-labeler/.github/workflows/promote-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
40-
with:
41-
model_cache_key: ${{ inputs.model_cache_key }}
42-
backup_cache_key: ${{ inputs.backup_cache_key }}
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 }}

0 commit comments

Comments
 (0)