|
| 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