Skip to content

Commit 5d3e41f

Browse files
authored
Onboard the dotnet/issue-labeler for 'area-' label prediction on issues (#9889)
* [Issue-Labeler] Configure labeler-train.yml Configure the issue-labeler training workflow. - Imported the workflow template - Removed inputs, jobs, and conditions related to pull requests, as we will only use the labeler for issues in this repository * [Issue-Labeler] Configure labeler-promote.yml Configure the issue-labeler promotion workflow. - Imported the workflow template - Removed input and job for pull requests, as we will only use the labeler for issues in this repository * [Issue-Labeler] Configure labeler-predict-issues.yml Configure the issue-labeler issue prediction workflow. - Imported the workflow template - Removed the excluded_authors input * [Issue-Labeler] Configure labeler-cache-retention.yml Configure the issue-labeler cache retention workflow. - Imported the workflow template - Removed config related to pull requests, as we will only use the labeler for issues in this repository * [Issue-Labeler] Add labeler onboarding/configuration doc * Bump superlinter to v7 (via SHA) to get type:number support in GitHub workflows * Address CHECKOV lint errors in GitHub workflows * Ignore GitHub workflow files from prettier * Explicitly set workflow permissions * Comment that UTC is used for cron schedule
1 parent 2b337e1 commit 5d3e41f

10 files changed

+280
-4
lines changed

.checkov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# Available properties:
3+
# https://github.com/bridgecrewio/checkov#configuration-using-a-config-file
4+
5+
skip-check:
6+
# CKV_GHA_7: "The build output cannot be affected by user parameters other
7+
# than the build entry point and the top-level source location. GitHub
8+
# Actions workflow_dispatch inputs MUST be empty."
9+
# Suppressed as issue-labeler workflows require `workflow_dispatch` inputs.
10+
- CKV_GHA_7
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Workflow template imported from:
2+
# https://github.com/dotnet/.github/workflow-templates
3+
#
4+
# Regularly restore the prediction model from cache to prevent cache eviction
5+
name: "Labeler: Cache Retention"
6+
7+
# For more information about GitHub's action cache limits and eviction policy, see:
8+
# https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
9+
10+
on:
11+
schedule:
12+
- cron: "24 12 * * *" # 12:24 UTC every day (arbitrary time daily)
13+
14+
workflow_dispatch:
15+
inputs:
16+
cache_key:
17+
description: "The cache key suffix to use for restoring the model from cache. Defaults to 'ACTIVE'."
18+
required: true
19+
default: "ACTIVE"
20+
21+
env:
22+
CACHE_KEY: ${{ inputs.cache_key || 'ACTIVE' }}
23+
24+
permissions: {}
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+
steps:
32+
- uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
33+
with:
34+
type: "issues"
35+
cache_key: ${{ env.CACHE_KEY }}
36+
fail-on-cache-miss: true
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Workflow template imported from:
2+
# https://github.com/dotnet/.github/workflow-templates
3+
#
4+
# Predict labels for Issues using a trained model
5+
name: "Labeler: Predict (Issues)"
6+
7+
on:
8+
# Only automatically predict area labels when issues are first opened
9+
issues:
10+
types: opened
11+
12+
# Allow dispatching the workflow via the Actions UI, specifying ranges of numbers
13+
workflow_dispatch:
14+
inputs:
15+
issues:
16+
description: "Issue Numbers (comma-separated list of ranges)."
17+
required: true
18+
cache_key:
19+
description: "The cache key suffix to use for restoring the model. Defaults to 'ACTIVE'."
20+
required: true
21+
default: "ACTIVE"
22+
23+
env:
24+
# Do not allow failure for jobs triggered automatically (as this causes red noise on the workflows list)
25+
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' }}
26+
27+
LABEL_PREFIX: "area-"
28+
THRESHOLD: 0.40
29+
DEFAULT_LABEL: "needs-area-label"
30+
31+
permissions:
32+
issues: write
33+
34+
jobs:
35+
predict-issue-label:
36+
# Do not automatically run the workflow on forks outside the 'dotnet' org
37+
if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }}
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: "Restore issues model from cache"
41+
id: restore-model
42+
uses: dotnet/issue-labeler/restore@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
43+
with:
44+
type: issues
45+
fail-on-cache-miss: ${{ env.ALLOW_FAILURE }}
46+
quiet: true
47+
48+
- name: "Predict issue labels"
49+
id: prediction
50+
if: ${{ steps.restore-model.outputs.cache-hit == 'true' }}
51+
uses: dotnet/issue-labeler/predict@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
52+
with:
53+
issues: ${{ inputs.issues || github.event.issue.number }}
54+
label_prefix: ${{ env.LABEL_PREFIX }}
55+
threshold: ${{ env.THRESHOLD }}
56+
default_label: ${{ env.DEFAULT_LABEL }}
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}
59+
continue-on-error: ${{ !env.ALLOW_FAILURE }}

.github/workflows/labeler-promote.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Workflow template imported from:
2+
# https://github.com/dotnet/.github/workflow-templates
3+
#
4+
# Promote a model from staging to 'ACTIVE', backing up the currently 'ACTIVE' model
5+
name: "Labeler: Promotion"
6+
7+
on:
8+
# Dispatched via the Actions UI, promotes the model from a staged slot into the active prediction environment
9+
workflow_dispatch:
10+
inputs:
11+
issues:
12+
description: "Issues: Promote Model"
13+
type: boolean
14+
required: true
15+
staged_key:
16+
description: "The cache key suffix to use for promoting a staged model to 'ACTIVE'. Defaults to 'staged'."
17+
required: true
18+
default: "staged"
19+
backup_key:
20+
description: "The cache key suffix to use for backing up the currently active model. Defaults to 'backup'."
21+
default: "backup"
22+
23+
permissions:
24+
actions: write
25+
26+
jobs:
27+
promote-issues:
28+
if: ${{ inputs.issues }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: "Promote Model for Issues"
32+
uses: dotnet/issue-labeler/promote@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
33+
with:
34+
type: "issues"
35+
staged_key: ${{ inputs.staged_key }}
36+
backup_key: ${{ inputs.backup_key }}

.github/workflows/labeler-train.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Workflow template imported from:
2+
# https://github.com/dotnet/.github/workflow-templates
3+
#
4+
# Train the model for issue label prediction
5+
name: "Labeler: Training"
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
steps:
11+
description: "Training Steps"
12+
type: choice
13+
required: true
14+
default: "All"
15+
options:
16+
- "All"
17+
- "Download Data"
18+
- "Train Model"
19+
- "Test Model"
20+
21+
limit:
22+
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."
23+
type: number
24+
page_size:
25+
description: "Number of items per page in GitHub API requests. Defaults to 100."
26+
type: number
27+
page_limit:
28+
description: "Maximum number of pages to download for training/testing the model. Defaults to 1000."
29+
type: number
30+
cache_key_suffix:
31+
description: "The cache key suffix to use for staged data/models (use 'ACTIVE' to bypass staging). Defaults to 'staged'."
32+
required: true
33+
default: "staged"
34+
35+
env:
36+
CACHE_KEY: ${{ inputs.cache_key_suffix }}
37+
REPOSITORY: ${{ github.repository }}
38+
LABEL_PREFIX: "area-"
39+
THRESHOLD: "0.40"
40+
LIMIT: ${{ inputs.limit }}
41+
PAGE_SIZE: ${{ inputs.page_size }}
42+
PAGE_LIMIT: ${{ inputs.page_limit }}
43+
44+
permissions:
45+
issues: read
46+
47+
jobs:
48+
download-issues:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: "Download Issues"
52+
uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
53+
with:
54+
type: "issues"
55+
cache_key: ${{ env.CACHE_KEY }}
56+
repository: ${{ env.REPOSITORY }}
57+
label_prefix: ${{ env.LABEL_PREFIX }}
58+
limit: ${{ env.LIMIT }}
59+
page_size: ${{ env.PAGE_SIZE }}
60+
page_limit: ${{ env.PAGE_LIMIT }}
61+
env:
62+
GITHUB_TOKEN: ${{ github.token }}
63+
64+
train-issues:
65+
runs-on: ubuntu-latest
66+
permissions: {}
67+
needs: download-issues
68+
steps:
69+
- name: "Train Model for Issues"
70+
uses: dotnet/issue-labeler/train@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
71+
with:
72+
type: "issues"
73+
data_cache_key: ${{ env.CACHE_KEY }}
74+
model_cache_key: ${{ env.CACHE_KEY }}
75+
76+
test-issues:
77+
runs-on: ubuntu-latest
78+
needs: train-issues
79+
steps:
80+
- name: "Test Model for Issues"
81+
uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0
82+
with:
83+
type: "issues"
84+
cache_key: ${{ env.CACHE_KEY }}
85+
repository: ${{ env.REPOSITORY }}
86+
label_prefix: ${{ env.LABEL_PREFIX }}
87+
threshold: ${{ env.THRESHOLD }}
88+
limit: ${{ env.LIMIT }}
89+
page_size: ${{ env.PAGE_SIZE }}
90+
page_limit: ${{ env.PAGE_LIMIT }}
91+
env:
92+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/labeler.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Issue-Labeler Workflows
2+
3+
This repository uses actions from [dotnet/issue-labeler](https://github.com/dotnet/issue-labeler) to predict area labels for issues and pull requests.
4+
5+
The following workflow templates were imported and updated from [dotnet/.github/workflow-templates](https://github.com/dotnet/.github/tree/main/workflow-templates) using
6+
GitHub's UI for adding new workflows. Issue Labeler [Onboarding](https://github.com/dotnet/issue-labeler/wiki/Onboarding) was referenced for the configurations.
7+
8+
1. `labeler-train.yml`
9+
2. `labeler-promote.yml`
10+
3. `labeler-predict-issues.yml`
11+
4. `labeler-cache-retention.yml`
12+
13+
## Repository Configuration
14+
15+
Across these workflows, the following changes were made to configure the issue labeler for this repository:
16+
17+
1. Set `LABEL_PREFIX` to `"area-"`:
18+
- `labeler-predict-issues.yml`
19+
- `labeler-train.yml`
20+
2. Set the `DEFAULT_LABEL` value to `"needs-area-label"` to apply a default label when no prediction is made.
21+
- `labeler-predict-issues.yml`
22+
3. Remove the `EXCLUDED_AUTHORS` value as we do not bypass labeling for any authors' issues/pulls in this repository:
23+
- `labeler-predict-issues.yml`
24+
- `labeler-train.yml`
25+
4. Remove the `repository` input for training the models against another repository:
26+
- `labeler-train.yml`
27+
5. Update the cache retention cron schedule to an arbitrary time of day:
28+
- `labeler-cache-retention.yml`
29+
6. Remove configuration, inputs, and jobs related to pull requests, as we will only predict labels for issues in this repository:
30+
- `labeler-train.yml`
31+
- `labeler-promote.yml`
32+
- `labeler-cache-retention.yml`

.github/workflows/markdown-link-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
paths:
1010
- '**.md'
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
markdown-link-check:
1417
runs-on: ubuntu-latest

.github/workflows/no-response.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ on:
1212
# Schedule for five minutes after the hour, every hour
1313
- cron: '5 * * * *'
1414

15+
permissions:
16+
issues: write
17+
1518
jobs:
1619
noResponse:
1720
runs-on: ubuntu-latest
18-
permissions:
19-
issues: write
2021
steps:
2122
- uses: actions/stale@v9
2223
with:

.github/workflows/super-linter.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ on:
1111
branches: [main]
1212
pull_request:
1313
branches: [main]
14+
15+
permissions:
16+
contents: read
17+
1418
jobs:
1519
run-lint:
1620
runs-on: ubuntu-latest
1721
steps:
1822
- name: Checkout code
19-
uses: actions/checkout@v2
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2024
with:
2125
# Full git history is needed to get a proper list of changed files within `super-linter`
2226
fetch-depth: 0
2327

2428
- name: Lint Code Base
25-
uses: github/super-linter@v5
29+
uses: github/super-linter@b807e99ddd37e444d189cfd2c2ca1274d8ae8ef1 # v7
2630
env:
2731
VALIDATE_ALL_CODEBASE: false
2832
VALIDATE_JSCPD: false

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore GitHub Workflow files and docs
2+
.github/workflows/*.yml
3+
.github/workflows/*.md

0 commit comments

Comments
 (0)