Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions .github/workflows/dev_cron.yml → .github/workflows/dev_jira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,38 @@
# specific language governing permissions and limitations
# under the License.

name: Dev Cron
name: PR JIRA integration

on:
push:
paths:
- '.github/workflows/dev_cron.yml'
pull_request:
paths:
- '.github/workflows/dev_cron.yml'
schedule:
- cron: |
*/15 * * * *
pull_request_target:
types:
- opened
- edited

jobs:

jira-link:
if: github.repository == 'apache/arrow'
name: JIRA link
link:
name: Link
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: Comment
uses: actions/github-script@master
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
const path = ".github/workflows/dev_cron/jira_link.js";
const script = fs.readFileSync(path).toString();
eval(script);
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_jira/link.js`);
script({github, context});

title-check:
if: github.repository == 'apache/arrow'
name: Title check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: Check
uses: actions/github-script@master
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
const path = ".github/workflows/dev_cron/title_check.js";
const script = fs.readFileSync(path).toString();
eval(script);
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_jira/title_check.js`);
script({github, context});
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@
// specific language governing permissions and limitations
// under the License.

const {owner: owner, repo: repo} = context.repo;

function detectJIRAID(title) {
if (!title) {
return null;
}
const matched = /^(ARROW|PARQUET)-\d+/.exec(title);
const matched = /^(WIP:?\s*)?((ARROW|PARQUET)-\d+)/.exec(title);
if (!matched) {
return null;
}
return matched[0];
return matched[2];
}

async function haveComment(pullRequestNumber, body) {
async function haveComment(github, context, pullRequestNumber, body) {
const options = {
owner: owner,
repo: repo,
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
page: 1
};
Expand All @@ -48,30 +46,24 @@ async function haveComment(pullRequestNumber, body) {
return false;
}

async function commentJIRAURL(pullRequestNumber, jiraID) {
async function commentJIRAURL(github, context, pullRequestNumber, jiraID) {
const jiraURL = `https://issues.apache.org/jira/browse/${jiraID}`;
if (await haveComment(pullRequestNumber, jiraURL)) {
if (await haveComment(github, context, pullRequestNumber, jiraURL)) {
return;
}
await github.issues.createComment({
owner: owner,
repo: repo,
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: jiraURL
});
}

(async () => {
const {data: pulls} = await github.pulls.list({
owner: owner,
repo: repo,
});
pulls.forEach(async (pull) => {
const pullRequestNumber = pull.number;
const title = pull.title;
const jiraID = detectJIRAID(title);
if (jiraID) {
await commentJIRAURL(pullRequestNumber, jiraID);
}
});
})();
module.exports = async ({github, context}) => {
const pullRequestNumber = context.payload.number;
const title = context.payload.pull_request.title;
const jiraID = detectJIRAID(title);
if (jiraID) {
await commentJIRAURL(github, context, pullRequestNumber, jiraID);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,39 @@
// specific language governing permissions and limitations
// under the License.

console.log("title-check");

const fs = require("fs");

const {owner: owner, repo: repo} = context.repo;

function haveJIRAID(title) {
if (!title) {
return false;
}
return /^(ARROW|PARQUET)-\d+/.test(title);
return /^(WIP:?\s*)?(ARROW|PARQUET)-\d+/.test(title);
}

async function commentOpenJIRAIssue(pullRequestNumber) {
async function commentOpenJIRAIssue(github, context, pullRequestNumber) {
const {data: comments} = await github.issues.listComments({
owner: owner,
repo: repo,
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
per_page: 1
});
if (comments.length > 0) {
return;
}
const commentPath = ".github/workflows/dev_cron/title_check.md";
const commentPath = ".github/workflows/dev_jira/title_check.md";
const comment = fs.readFileSync(commentPath).toString();
await github.issues.createComment({
owner: owner,
repo: repo,
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: comment
});
}

(async () => {
const {data: pulls} = await github.pulls.list({
owner: owner,
repo: repo,
});
pulls.forEach(async (pull) => {
const pullRequestNumber = pull.number;
const title = pull.title;
if (!haveJIRAID(title)) {
await commentOpenJIRAIssue(pullRequestNumber);
}
});
})();
module.exports = async ({github, context}) => {
const pullRequestNumber = context.payload.number;
const title = context.payload.pull_request.title;
if (!haveJIRAID(title)) {
await commentOpenJIRAIssue(github, context, pullRequestNumber);
}
};
3 changes: 2 additions & 1 deletion .github/workflows/dev_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ on:
types: [opened, reopened]

jobs:
assign-rust-labels:
label:
name: Label
runs-on: ubuntu-latest
steps:
- name: Assign Github labels
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dev_labeler_pr_rebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ on:
types: [synchronize]

jobs:
main:
label:
name: Label
runs-on: ubuntu-latest
steps:
- name: Checks if PR needs rebase
Expand Down