forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GH Action to ensure new issues have a QA label (rancher#10572)
* Add GH Action to ensure new issues have a QA label * Remove incorrect comment * Add QA None support * Add more intelligent choice of label * Change order of label choice so tech-debt is first
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Add QA Label | ||
on: | ||
issues: | ||
types: | ||
- opened | ||
jobs: | ||
add_qa_label_to_issues: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '16.x' | ||
- name: script | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: node .github/workflows/scripts/add-qa-label.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env node | ||
|
||
const request = require('./request'); | ||
|
||
const QA_DEV_AUTOMATION_LABEL = 'QA/dev-automation'; | ||
const QA_MANUAL_TEST_LABEL = 'QA/manual-test'; | ||
const QA_NONE_LABEL = 'QA/None'; | ||
|
||
const EMBER_LABEL = 'ember'; | ||
const TECH_DEBT_LABEL = 'kind/tech-debt'; | ||
|
||
// The event object | ||
const event = require(process.env.GITHUB_EVENT_PATH); | ||
|
||
async function processOpenAction() { | ||
const issue = event.issue; | ||
|
||
console.log('======'); | ||
console.log('Processing Opened Issue #' + issue.number + ' : ' + issue.title); | ||
console.log('======'); | ||
|
||
// Get an array of labels | ||
const labels = issue.labels.map((label) => label.name); | ||
|
||
// Check we have a QA label | ||
if (!labels.includes(QA_DEV_AUTOMATION_LABEL) && !labels.includes(QA_MANUAL_TEST_LABEL) && !labels.includes(QA_NONE_LABEL)) { | ||
|
||
// Add the appropriate QA label | ||
if (labels.includes(TECH_DEBT_LABEL)) { | ||
console.log(' Issue does not have a QA label, adding QA/None label (as issue is marked as tech-debt)'); | ||
|
||
labels.push(QA_NONE_LABEL); | ||
} else if (labels.includes(EMBER_LABEL)) { | ||
console.log(' Issue does not have a QA label, adding manual test label (as issue is marked as ember)'); | ||
|
||
labels.push(QA_MANUAL_TEST_LABEL); | ||
} else { | ||
console.log(' Issue does not have a QA label, adding dev-automation label'); | ||
|
||
labels.push(QA_DEV_AUTOMATION_LABEL); | ||
} | ||
|
||
// Update the labels | ||
const labelsAPI = `${issue.url}/labels`; | ||
await request.put(labelsAPI, { labels }); | ||
|
||
console.log(' Issue has been updated with QA label'); | ||
} else { | ||
console.log(' Issue already has a QA label, nothing to do'); | ||
} | ||
} | ||
|
||
// Debugging | ||
// console.log(JSON.stringify(event, null, 2)); | ||
|
||
// Look at the action | ||
if (event.action === 'opened') { | ||
processOpenAction(); | ||
} else { | ||
console.log(`Unsupported action: ${event.action}`); | ||
} |