Skip to content

Commit 89100b7

Browse files
committed
Import v2.0.0 issue-labeler default workflows
1 parent 81670b9 commit 89100b7

6 files changed

+289
-201
lines changed

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

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 27 additions & 5 deletions
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:
5-
- cron: "13 6 * * *" # 6:13 every day (arbitrary time daily)
9+
- cron: "42 18 * * *" # 18:42 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
Lines changed: 44 additions & 19 deletions
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 }}
Lines changed: 46 additions & 19 deletions
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,31 +14,57 @@ 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:
17-
- 'main'
20+
- main
1821

1922
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
2023
workflow_dispatch:
2124
inputs:
22-
pull_numbers:
23-
description: "Pull Numbers (comma-separated list of ranges)"
24-
type: string
25-
model_cache_key:
26-
description: "The cache key suffix to use for loading the model"
27-
type: string
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'."
2830
required: true
29-
default: "LIVE"
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
3041

3142
jobs:
32-
predict-pulls:
33-
# Do not run the workflow on forks outside the 'dotnet' org
34-
if: ${{ github.repository_owner == 'dotnet' && (inputs.pull_numbers || github.event.number) }}
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
3547
permissions:
3648
pull-requests: write
37-
uses: dotnet/issue-labeler/.github/workflows/predict-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1
38-
with:
39-
model_cache_key: ${{ inputs.model_cache_key }}
40-
pull_numbers: ${{ inputs.pull_numbers || github.event.number }}
41-
label_prefix: "area-"
42-
threshold: 0.40
43-
default_label: "needs-area-label"
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 }}

.github/workflows/labeler-promote.yml

Lines changed: 30 additions & 23 deletions
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)