]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/.github/workflows/dev_pr/jira_check.js
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / .github / workflows / dev_pr / jira_check.js
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17
18 const helpers = require("./helpers.js");
19
20 async function verifyJIRAIssue(github, context, pullRequestNumber, jiraID) {
21 const ticketInfo = await helpers.getJiraInfo(jiraID);
22 if(!ticketInfo["fields"]["components"].length) {
23 await commentMissingComponents(github, context, pullRequestNumber);
24 }
25
26 if(ticketInfo["fields"]["status"]["id"] == 1) {
27 // "status": {"name":"Open","id":"1"
28 // "description":"The issue is open and ready for the assignee to start work on it.",
29 await commentNotStartedTicket(github, context, pullRequestNumber);
30 }
31 }
32
33 async function commentMissingComponents(github, context, pullRequestNumber) {
34 const {data: comments} = await github.issues.listComments({
35 owner: context.repo.owner,
36 repo: context.repo.repo,
37 issue_number: pullRequestNumber,
38 per_page: 100
39 });
40
41 var found = false;
42 for(var i=0; i<comments.length; i++) {
43 if (comments[i].body.includes("has no components in JIRA")) {
44 found = true;
45 }
46 }
47 if (!found) {
48 await github.issues.createComment({
49 owner: context.repo.owner,
50 repo: context.repo.repo,
51 issue_number: pullRequestNumber,
52 body: ":warning: Ticket **has no components in JIRA**, make sure you assign one."
53 });
54 }
55 }
56
57 async function commentNotStartedTicket(github, context, pullRequestNumber) {
58 const {data: comments} = await github.issues.listComments({
59 owner: context.repo.owner,
60 repo: context.repo.repo,
61 issue_number: pullRequestNumber,
62 per_page: 100
63 });
64
65 var found = false;
66 for(var i=0; i<comments.length; i++) {
67 if (comments[i].body.includes("has not been started in JIRA")) {
68 found = true;
69 }
70 }
71 if (!found) {
72 await github.issues.createComment({
73 owner: context.repo.owner,
74 repo: context.repo.repo,
75 issue_number: pullRequestNumber,
76 body: ":warning: Ticket **has not been started in JIRA**, please click 'Start Progress'."
77 });
78 }
79 }
80
81 module.exports = async ({github, context}) => {
82 const pullRequestNumber = context.payload.number;
83 const title = context.payload.pull_request.title;
84 const jiraID = helpers.detectJIRAID(title);
85 if (jiraID) {
86 await verifyJIRAIssue(github, context, pullRequestNumber, jiraID);
87 }
88 };