Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIMS-2130: Update Python Create Jira Tickets Script #2772

Merged
merged 65 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
aae9317
removing python script to create jira tickets
TaylorFries Oct 28, 2024
0320fe5
checking what output is
TaylorFries Oct 31, 2024
172aef1
Revert "checking what output is"
TaylorFries Oct 31, 2024
d40e4be
adding documentation for workflow
TaylorFries Nov 6, 2024
e7c031e
updating npm-dep scripts
TaylorFries Nov 6, 2024
8a6e1be
add python file to creaate comment
TaylorFries Nov 6, 2024
b83fd7a
small updates to readme and formatting
TaylorFries Nov 6, 2024
6ad1128
fir error catching
TaylorFries Nov 6, 2024
b34b790
add comment when adding issue
TaylorFries Nov 6, 2024
14c924e
update how we store comment
TaylorFries Nov 6, 2024
65da1a7
use the correct job name for output
TaylorFries Nov 6, 2024
1c658be
steps != needs
TaylorFries Nov 6, 2024
673d60e
try this line end
TaylorFries Nov 6, 2024
7ee189b
test to see what the coment is
TaylorFries Nov 6, 2024
c112e27
write to github output instead of env
TaylorFries Nov 6, 2024
13ec249
wrong job id
TaylorFries Nov 6, 2024
18764ea
remove a lot of console.logs()
TaylorFries Nov 6, 2024
4930ed1
have to wait for issue number
TaylorFries Nov 6, 2024
157135b
add pause to wait for issue to post
TaylorFries Nov 6, 2024
0d52078
add pause before trying to comment
TaylorFries Nov 6, 2024
a4fc1cf
maybe a fix?
TaylorFries Nov 6, 2024
744b974
add decode
TaylorFries Nov 6, 2024
421d61b
testing with no decode
TaylorFries Nov 6, 2024
aded1ff
testing what we are sending as a comment
TaylorFries Nov 7, 2024
c4b2a9a
testing as string maybe
TaylorFries Nov 7, 2024
247739d
jira cant process arrays of arrays
TaylorFries Nov 7, 2024
ceeeba7
only send comment with correct folder info
TaylorFries Nov 7, 2024
b61b754
trying to make this an object of arrays
TaylorFries Nov 7, 2024
451bded
so many lists of objects
TaylorFries Nov 7, 2024
a8255cf
formatting and remove header grouping
TaylorFries Nov 7, 2024
84e85a6
Merge branch 'main' into PIMS-2130-fix-ticket-creator-script
Sharala-Perumal Nov 7, 2024
459a5b8
making string easier to parse for jIrA aUtOmAtE
TaylorFries Nov 7, 2024
5e902ea
Merge branch 'PIMS-2130-fix-ticket-creator-script' of https://github.…
TaylorFries Nov 7, 2024
01daab8
format comment better
TaylorFries Nov 7, 2024
30dec9c
missed another list to join
TaylorFries Nov 7, 2024
e379966
remove test file
TaylorFries Nov 7, 2024
68b03df
better format
TaylorFries Nov 8, 2024
6620a9f
better english
TaylorFries Nov 8, 2024
50341c5
get issue number from created issue
TaylorFries Nov 8, 2024
3e71066
i goofed something up
TaylorFries Nov 8, 2024
bc1ad3e
better
TaylorFries Nov 8, 2024
c03432f
I updated way too much in this one commit.
TaylorFries Nov 8, 2024
85e9290
try this as import statements
TaylorFries Nov 8, 2024
6ea44d4
cant import here
TaylorFries Nov 8, 2024
ba5e97f
adding reminders about imports
TaylorFries Nov 8, 2024
d569b95
renaming file
TaylorFries Nov 8, 2024
329185f
more import problems
TaylorFries Nov 8, 2024
1ac46e3
deleted path require
TaylorFries Nov 8, 2024
87ef366
trying this as import
TaylorFries Nov 8, 2024
c079e89
hopefully this one works
TaylorFries Nov 8, 2024
934fc6f
going back to this format
TaylorFries Nov 8, 2024
b42209b
i wish these little errors were caught before trying to run.
TaylorFries Nov 8, 2024
d38582e
removing some console.logs as they are not needed rn
TaylorFries Nov 8, 2024
133c0e7
trying different timeouts
TaylorFries Nov 9, 2024
703b6c6
upping timeout
TaylorFries Nov 9, 2024
1908acf
the awaits arent awaiting
TaylorFries Nov 9, 2024
ab66c75
this shouldnt be failing like this
TaylorFries Nov 9, 2024
dbc8bc9
just one step at a time to figure out why this is failing
TaylorFries Nov 9, 2024
c1d639a
it was my fault. I was indexing into body instead of data
TaylorFries Nov 9, 2024
0fd07bf
remove unused import
TaylorFries Nov 9, 2024
e41ea53
Update documentation
TaylorFries Nov 9, 2024
9bfb9f6
updating where ignore list and dep levels are set
TaylorFries Nov 12, 2024
8c15bf8
update documentation
TaylorFries Nov 12, 2024
9951949
add ending back tick
TaylorFries Nov 13, 2024
42ea6da
Merge branch 'main' into PIMS-2130-fix-ticket-creator-script
TaylorFries Nov 13, 2024
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
21 changes: 5 additions & 16 deletions .github/config/dep-report.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
// Check package.json files for dependency updates.
packageJsonPaths: ["react-app", "express-api"],

// Do not report on the following packages.
ignorePackages: {
// Path to package.json file.
"src/react-app": [], // Add names of packages such as ["typescript"].
"src/express-api": ["xlsx"],
},
// List of packages to ignore when reporting in jira ticket(s)
ignoreList: ["xlsx"],

// Sets what levels of dependencies to include in the jira ticket(s)
depLevels: ["minor", "major"],

// The env variables below are used to update the create_tickets.py script

// used to determine what updates to post
LEVEL_FLAGS: "MINOR MAJOR",
// sets what JIRA board to post and pull from
JIRA_BOARD: "PIMS",
// each Jira board has a different issue type for subtasks
JIRA_SUBTASK: "10003",
// epic links are technically a custom field with this specific id and ticket number (for PIMS)
JIRA_EPIC: "10014, PIMS-450"
}
21 changes: 0 additions & 21 deletions .github/helpers/github-api/create-and-close-existing-issue.mjs

This file was deleted.

142 changes: 72 additions & 70 deletions .github/helpers/github-api/github-api-requests.mjs
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
/**
* Reusable functions for making requests to the GitHub REST API.
* @author Brady Mitchell <[email protected] | [email protected]>
* API Documentation: https://octokit.github.io/rest.js/v19#usage
* @editor Taylor Friesen <[email protected]>
* API Documentation: https://docs.github.com/en/rest
*
* THIS FILE DOES NOT NEED TO BE EDITED, but you can add more functions if desired.
* Place within .github/helpers/github-api/
*
* - Be sure to include the env variables from below!
*
* @example GitHub Actions Workflow:
* jobs:
* github-api:
* runs-on: ubuntu-22.04
* container:
* image: node:20.2-bullseye-slim
*
* steps:
* # Checkout branch.
* - name: Checkout repository
* uses: actions/checkout@v3
*
* # Get Repo Owner and Repo Name.
* - name: Set repo information
* run: |
* echo "REPO_OWNER=$(echo ${{ github.repository }} | cut -d / -f 1)" >> $GITHUB_ENV
* echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d / -f 2)" >> $GITHUB_ENV
*
* # Install @octokit/rest npm package for making GitHub rest API requests.
* - name: Install @octokit/rest npm
* run: npm i @octokit/rest
*
* # Run Node Script that calls functions from github-api-requests.js.
* - name: Node Script
* env:
* GITHUB_OWNER: ${{ env.REPO_OWNER }}
* GITHUB_REPO: ${{ env.REPO_NAME }}
* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
* run: node .github/helpers/script.js
*/

import { Octokit } from '@octokit/rest';
import { Octokit } from "@octokit/rest";
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env;
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split('/');
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split("/");

// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: GITHUB_TOKEN });
Expand All @@ -50,64 +19,97 @@ const octokit = new Octokit({ auth: GITHUB_TOKEN });
* Create an Issue with the GitHub REST API.
* @param {string} title - The title for the new issue.
* @param {string} body - The content body for the new issue.
* @returns request.data - Data returned by the request.
* @returns - response - returned response from github.
* @example
* createIssue('My Issue', 'An example issue');
*/
export async function createIssue(title, body) {
const request = await octokit.rest.issues.create({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
title,
body,
});
console.log(request.data);
return request;
const response = await octokit.rest.issues.create({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
title,
body,
});
//console.log("create issue: ", response.data);
return response;
}

/**
* Close an Issue with the GitHub REST API.
* @param {number} issue_number - The id for a GitHub Issue.
* @returns request.data - Data returned by the request.
* @returns - response - returned response from github.
* @example
* closeIssue(1044);
*/
export async function closeIssue(issue_number) {
const request = await octokit.rest.issues.update({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number,
state: 'closed',
});
console.log(request.data);
return request;
const response = await octokit.rest.issues.update({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number,
state: "closed",
});
//console.log("close issue: ", response.data);
return response;
}

/**
* Get issue number from title, and create a request to add a comment.
* @param {*} issueNumber - the number for the issue to comment on
* @param {*} issueComment - the comment to add
* @returns - response - returned response from github.
* @example
* addComment(1234, 'An example comment');
*/
export async function addComment(issueNumber, issueComment) {
const response = await octokit.rest.issues.createComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number: issueNumber,
body: issueComment,
});
//console.log("add comment: ", response.data);
return response;
}

/**
* Close a comment on an issue by referencing the ID
* @param {*} commentID - the number associated with a comment
* @returns - response - returned response from github.
* @example
* deleteComment(1234);
*/
export async function deleteComment(commentID) {
const response = await octokit.rest.issues.deleteComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
comment_id: commentID,
});
//console.log("delete comment: ", response.data);
return response;
}

/**
* Find an Issue's ID number with the GitHub REST API, given a title.
* @param {string} title - The title of the issue to search for.
* @param {string} state - (optional, default=open) Search for all, open, or closed issues.
* @returns issue.number or null
* @returns response from Github
* @example
* findIssueByTitle('My Issue');
*/
export async function findIssueByTitle(title, state = 'open') {
const { data: issues } = await octokit.rest.issues.listForRepo({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
state, // Get issues that are 'open', 'closed' or 'all'.
});

for (const issue of issues) {
if (issue.title === title) {
return issue.number;
}
}
return null; // Return null if no issue found.
export async function findIssues(state = "open") {
const response = await octokit.rest.issues.listForRepo({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
state, // Get issues that are 'open', 'closed' or 'all'.
});
//console.log("found issue: ", response.data);
return response;
}

export default {
createIssue,
closeIssue,
findIssueByTitle,
createIssue,
closeIssue,
addComment,
deleteComment,
findIssues,
};
Loading
Loading