]>
git.proxmox.com Git - ceph.git/blob - 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
9 // http://www.apache.org/licenses/LICENSE-2.0
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
18 const helpers
= require("./helpers.js");
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
);
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
);
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
,
42 for(var i
=0; i
<comments
.length
; i
++) {
43 if (comments
[i
].body
.includes("has no components in JIRA")) {
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."
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
,
66 for(var i
=0; i
<comments
.length
; i
++) {
67 if (comments
[i
].body
.includes("has not been started in JIRA")) {
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'."
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
);
86 await
verifyJIRAIssue(github
, context
, pullRequestNumber
, jiraID
);