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

Add new external media endpoint #40145

Closed
wants to merge 52 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bd5e753
Add Google Photos Picker new WPCOM endpoints
zaerl Nov 12, 2024
c9b92d7
changelog
zaerl Nov 12, 2024
a512d13
Backup: Add next daily backup schedule time (#39914)
Initsogar Nov 12, 2024
f05867c
Repo Gardening: allow escalating issues to multiple groups (#39973)
jeherve Nov 12, 2024
b42824f
General: Bump minimum WordPress version to 6.6 (#40146)
tbradsha Nov 12, 2024
04af86b
Coming Soon: Change the color on the coming soon banner to new WordPr…
katinthehatsite Nov 12, 2024
c663031
Jetpack AI: Adding "transform list into table" functionality back to …
mwatson Nov 12, 2024
6baa6d5
Repo Gardening: update conditions when AI Labelling is triggered (#40…
jeherve Nov 13, 2024
0b45b96
Boost: Fix broken Beta tag for "Auto-Resize Lazy Images" (#40143)
dilirity Nov 13, 2024
bfe4286
Additional CSS: Update the upgrade nudge with the correct plan (#40107)
BogdanUngureanu Nov 13, 2024
9cd7a8f
Add missing endpoint
zaerl Nov 13, 2024
cd25cb0
Fix phan errors
zaerl Nov 13, 2024
ebef826
Jetpack AI: add featured image styles support (#40113)
CGastrell Nov 13, 2024
d7d7102
Repo Gardening: cover more use-cases of changelog files (#40160)
jeherve Nov 13, 2024
3669f38
ci: Fix coverage munger with no coverage (#40150)
anomiex Nov 13, 2024
bbe16de
Jetpack Sync: Add 'od_url_metrics' in blacklisted post types (#40158)
fgiannar Nov 13, 2024
410917f
Boost: Cornerstone Pages list UI tweaks (#40163)
dilirity Nov 13, 2024
e2ab2c1
General: Bump minimum PHP version to 7.2 (#40147)
tbradsha Nov 13, 2024
e1fd272
Repo Gardening: update Type column in project board based off label (…
jeherve Nov 13, 2024
88d9ec8
Protect: Add Scan tab threat count (#40056)
dkmyta Nov 13, 2024
494d36b
ThreatFixerButton: Add tooltips alt (#40111)
dkmyta Nov 13, 2024
a24a5f6
Protect Status: Add a threats list property to the status, and deprec…
nateweller Nov 13, 2024
3eeff5b
Backup: fix backup pricing placeholder (#40157)
Initsogar Nov 13, 2024
53cd95d
Remove json_decode
zaerl Nov 14, 2024
612faa7
Add HTTP header injection
zaerl Nov 14, 2024
486a04b
SupportInteractions: Pass params on get (#40185)
heavyweight Nov 14, 2024
d8d592d
Fix: return type
zaerl Nov 14, 2024
7b6f3e3
Social: Add utm toggle sync (#40144)
gmjuhasz Nov 14, 2024
e0cdabc
Add direct output of binary
zaerl Nov 14, 2024
f7a2f86
Add checks for output error
zaerl Nov 14, 2024
47bfdb5
Jetpack AI: Make sure we validate that the new option exists (#40186)
mwatson Nov 14, 2024
b5dede3
Update/wpcomsh package to sync growth constant features (#40187)
CodeyGuyDylan Nov 14, 2024
fcf3010
Add/jetpack growth to constants (#40176)
CodeyGuyDylan Nov 14, 2024
bbb0564
coverage: Always process coverage, even if tests fail (#40167)
anomiex Nov 14, 2024
1f68cdf
Jetpack: show connection cards with disabled promotions (#40179)
sergeymitr Nov 14, 2024
fa3e13d
Migrate to WordPress.com: remove the plugin (#40166)
jeherve Nov 14, 2024
8ee1c37
Codesniffer: remove PHP 7.0 and 7.1 support (#40174)
tbradsha Nov 14, 2024
a4ea55a
tools: Run `jetpack install --root` when releasing plugins (#40193)
anomiex Nov 14, 2024
13cb3bc
Backport backup 3.0 Changes (#40194)
Initsogar Nov 14, 2024
b8f11c6
cli: Rewrite test command (#40175)
anomiex Nov 14, 2024
33c1e82
jetpack: Limit test-coverage concurrency (#40195)
anomiex Nov 14, 2024
af007b7
Jetpack AI: bug hotfix - general image disabled input (#40198)
CGastrell Nov 14, 2024
41823b2
Add Google Photos Picker new WPCOM endpoints
zaerl Nov 12, 2024
50465ce
changelog
zaerl Nov 12, 2024
ef0e45e
Add missing endpoint
zaerl Nov 13, 2024
cd92207
Fix phan errors
zaerl Nov 13, 2024
7418144
Remove json_decode
zaerl Nov 14, 2024
facde9f
Add HTTP header injection
zaerl Nov 14, 2024
86b1108
Fix: return type
zaerl Nov 14, 2024
a3d5798
Add direct output of binary
zaerl Nov 14, 2024
5020c8a
Add checks for output error
zaerl Nov 14, 2024
3230657
Merge branch 'add/new-external-media-endpoint' of github.com:Automatt…
zaerl Nov 15, 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
Prev Previous commit
Next Next commit
Repo Gardening: update Type column in project board based off label (#…
…40110)

* Repo Gardening: update Type column in project board based off label

If we can extract the type of the issue from the labels, we will update our project board's "Type" column accordingly.

* Get rid of extra label check when an issue is being labeled

The added label is already returned by getLabels.

* Simplify issue type management

I made some changes to the One Board settings to make things simpler.

* Fix project type extraction

* Fix string check
jeherve authored Nov 13, 2024
commit e1fd27219bf3f531371044dd83fbc9cd485d5e53
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Board Triage: automatically add the issue type to our project board when a Type label can be found in the issue.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getInput } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const isBug = require( '../../utils/labels/is-bug' );
const getIssueType = require( '../../utils/labels/get-issue-type' );
const findPlatforms = require( '../../utils/parse-content/find-platforms' );
const findPlugins = require( '../../utils/parse-content/find-plugins' );
const formatSlackMessage = require( '../../utils/slack/format-slack-message' );
@@ -23,7 +23,7 @@ const updateBoard = require( './update-board' );
* @param {GitHub} octokit - Initialized Octokit REST client.
*/
async function triageIssues( payload, octokit ) {
const { action, issue, label = {}, repository } = payload;
const { action, issue, repository } = payload;
const { number, body, state } = issue;
const { owner, name, full_name } = repository;
const ownerLogin = owner.login;
@@ -35,7 +35,8 @@ async function triageIssues( payload, octokit ) {
}

const { labels: priorityLabels, inferred } = await getIssuePriority( payload, octokit );
const isBugIssue = await isBug( octokit, ownerLogin, name, number, action, label );
const issueType = await getIssueType( octokit, ownerLogin, name, number );
const isBug = issueType === 'Bug';
const qualityChannel = getInput( 'slack_quality_channel' );

// If this is a new issue, add labels.
@@ -71,7 +72,7 @@ async function triageIssues( payload, octokit ) {
}

// Add priority label to the issue, if none already existed on the issue.
if ( priorityLabels.length === 1 && isBugIssue && inferred ) {
if ( priorityLabels.length === 1 && isBug && inferred ) {
const inferredPriority = priorityLabels[ 0 ];
debug( `triage-issues: Adding ${ inferredPriority } label to issue #${ number }` );

@@ -103,11 +104,11 @@ async function triageIssues( payload, octokit ) {
}

// Triage the issue to a Project board if necessary and possible.
await updateBoard( payload, octokit, isBugIssue, priorityLabels );
await updateBoard( payload, octokit, issueType, priorityLabels );

// Send a Slack notification to Product ambassadors if the issue is important.
if (
isBugIssue &&
isBug &&
qualityChannel &&
priorityLabels.length > 0 &&
( priorityLabels.includes( '[Pri] BLOCKER' ) || priorityLabels.includes( '[Pri] High' ) )
Original file line number Diff line number Diff line change
@@ -99,6 +99,14 @@ async function getProjectDetails( octokit, projectBoardLink ) {
projectInfo.team = teamField; // Info about our Team column (id as well as possible values).
}

// Extract the ID of the Type field.
const typeField = projectDetails[ projectInfo.ownerType ]?.projectV2.fields.nodes.find(
field => field.name === 'Type'
);
if ( typeField ) {
projectInfo.type = typeField; // Info about our Type column (id as well as possible values).
}

return projectInfo;
}

@@ -266,6 +274,68 @@ async function setPriorityField( octokit, projectInfo, projectItemId, priorityTe
return newProjectItemId; // New Project item ID (what we just edited). String.
}

/**
* Set the Type field for a project item, to match the Type label if it exists.
*
* @param {GitHub} octokit - Initialized Octokit REST client.
* @param {object} projectInfo - Info about our project board.
* @param {string} projectItemId - The ID of the project item.
* @param {string} typeText - Type of our issue (must match an existing column in the project board).
* @return {Promise<string>} - The new project item id.
*/
async function setTypeField( octokit, projectInfo, projectItemId, typeText ) {
const {
projectNodeId, // Project board node ID.
type: {
id: typeFieldId, // ID of the type field.
options,
},
} = projectInfo;

// Find the ID of the Type option that matches our issue type label.
const typeOptionId = options.find( option => option.name === typeText )?.id;
if ( ! typeOptionId ) {
debug(
`triage-issues > update-board: Type ${ typeText } does not exist as a column option in the project board.`
);
return '';
}

const projectNewItemDetails = await octokit.graphql(
`mutation ( $input: UpdateProjectV2ItemFieldValueInput! ) {
set_type: updateProjectV2ItemFieldValue( input: $input ) {
projectV2Item {
id
}
}
}`,
{
input: {
projectId: projectNodeId,
itemId: projectItemId,
fieldId: typeFieldId,
value: {
singleSelectOptionId: typeOptionId,
},
},
}
);

const newProjectItemId = projectNewItemDetails.set_type.projectV2Item.id;
if ( ! newProjectItemId ) {
debug(
`triage-issues > update-board: Failed to set the "${ typeText }" type for this project item.`
);
return '';
}

debug(
`triage-issues > update-board: Project item ${ newProjectItemId } was moved to "${ typeText }" type.`
);

return newProjectItemId; // New Project item ID (what we just edited). String.
}

/**
* Update the "Status" field in our project board.
*
@@ -439,18 +509,11 @@ async function loadTeamAssignments( ownerLogin ) {
* @param {object} payload - Issue event payload.
* @param {object} projectInfo - Info about our project board.
* @param {string} projectItemId - The ID of the project item.
* @param {boolean} isBugIssue - Is the issue a bug?
* @param {boolean} isBug - Is the issue a bug?
* @param {Array} priorityLabels - Array of priority labels.
* @return {Promise<string>} - The new project item id.
*/
async function assignTeam(
octokit,
payload,
projectInfo,
projectItemId,
isBugIssue,
priorityLabels
) {
async function assignTeam( octokit, payload, projectInfo, projectItemId, isBug, priorityLabels ) {
const {
action,
issue: { number },
@@ -499,7 +562,7 @@ async function assignTeam(
slack_id &&
priorityLabels.length > 0 &&
( priorityLabels.includes( '[Pri] BLOCKER' ) || priorityLabels.includes( '[Pri] High' ) ) &&
isBugIssue
isBug
) {
debug(
`triage-issues > update-board: Issue #${ number } has the following priority labels: ${ priorityLabels.join(
@@ -553,27 +616,29 @@ async function assignTeam(
*
* @param {WebhookPayloadIssue} payload - Issue event payload.
* @param {GitHub} octokit - Initialized Octokit REST client.
* @param {boolean} isBugIssue - Is the issue a bug?
* @param {string} issueType - Type of the issue, defined by a "[Type]" label on the issue.
* @param {Array} priorityLabels - Array of Priority Labels matching this issue.
*/
async function updateBoard( payload, octokit, isBugIssue, priorityLabels ) {
async function updateBoard( payload, octokit, issueType, priorityLabels ) {
const {
issue: { number },
repository: { owner, name },
} = payload;
const ownerLogin = owner.login;

const isBug = issueType === 'Bug';

const projectToken = getInput( 'triage_projects_token' );
if ( ! projectToken ) {
setFailed(
debug(
`triage-issues > update-board: Input triage_projects_token is required but missing. Aborting.`
);
return;
}

const projectBoardLink = getInput( 'project_board_url' );
if ( ! projectBoardLink ) {
setFailed(
debug(
`triage-issues > update-board: No project board link provided. Cannot triage to a board. Aborting.`
);
return;
@@ -587,63 +652,61 @@ async function updateBoard( payload, octokit, isBugIssue, priorityLabels ) {
// Get details about our project board, to use in our requests.
const projectInfo = await getProjectDetails( projectOctokit, projectBoardLink );
if ( Object.keys( projectInfo ).length === 0 || ! projectInfo.projectNodeId ) {
setFailed(
debug(
`triage-issues > update-board: we cannot fetch info about our project board. Aborting task.`
);
return;
}

// Check if the issue is already on the project board. If so, return its ID on the board.
// Check if the issue is already on the project board. If so, return its ID.
let projectItemId = await getIssueProjectItemId( projectOctokit, projectInfo, name, number );
if ( ! projectItemId ) {

// If we have no ID, that means the issue isn't on the board yet.
// If it is a bug, add it to the board.
if ( ! projectItemId && isBug ) {
debug(
`triage-issues > update-board: Issue #${ number } is not on our project board. Let's check if it is a bug. If it is, we will want to add it to our board.`
`triage-issues > update-board: Issue #${ number } is not on our project board. Let's add it.`
);
projectItemId = await addIssueToBoard( payload, projectOctokit, projectInfo );

// If the issue is not a bug, stop.
if ( ! isBugIssue ) {
if ( projectItemId ) {
// Set the "Needs Triage" status for our issue on the board.
debug(
`triage-issues > update-board: Issue #${ number } is not classified as a bug. Aborting.`
`triage-issues > update-board: Setting the "Needs Triage" status for this project item, issue #${ number }.`
);
return;
projectItemId = await setStatusField(
projectOctokit,
projectInfo,
projectItemId,
'Needs Triage'
);
} else {
debug( `triage-issues > update-board: Failed to add issue to project board.` );
}
}

// If the issue is a bug, add it to our project board.
// Check if the type needs to be updated for that issue.
// We do need info about the type column in the board to be able to do that.
if ( issueType && projectInfo.type ) {
debug(
`triage-issues > update-board: Issue #${ number } is a bug. Adding it to our project board.`
`triage-issues > update-board: Issue #${ number } has a type label set, ${ issueType }. Let’s ensure the Type field of the project board matches that.`
);
projectItemId = await addIssueToBoard( payload, projectOctokit, projectInfo );
if ( ! projectItemId ) {
debug( `triage-issues > update-board: Failed to add issue to project board. Aborting.` );
return;
}

// Set the "Needs Triage" status for our issue on the board.
debug(
`triage-issues > update-board: Setting the "Needs Triage" status for this project item, issue #${ number }.`
);
projectItemId = await setStatusField(
projectOctokit,
projectInfo,
projectItemId,
'Needs Triage'
);
// So far, our project board only supports the following types: 'Bug', 'Enhancement', and 'Task'
if ( [ 'Bug', 'Enhancement', 'Task' ].includes( issueType ) ) {
projectItemId = await setTypeField( projectOctokit, projectInfo, projectItemId, issueType );
}
}

// Check if priority needs to be updated for that issue.
if ( priorityLabels.length > 0 ) {
// We do need info about the priority column in the board to be able to do that.
if ( priorityLabels.length > 0 && projectInfo.priority ) {
debug(
`triage-issues > update-board: Issue #${ number } has the following priority labels: ${ priorityLabels.join(
', '
) }`
);

// If we have no info about the Priority column, stop.
if ( ! projectInfo.priority ) {
debug( `triage-issues > update-board: No priority column found in project board. Aborting.` );
return;
}

// Remove the "[Pri]" prefix from our priority labels. We also only need one label.
const priorityText = priorityLabels[ 0 ].replace( /^\[Pri\]\s*/, '' );

@@ -677,14 +740,12 @@ async function updateBoard( payload, octokit, isBugIssue, priorityLabels ) {
projectItemId,
'Needs Core/3rd Party Fix'
);
return;
} else {
debug(
`triage-issues > update-board: Setting the "Triaged" status for this project item, issue #${ number }.`
);
await setStatusField( projectOctokit, projectInfo, projectItemId, 'Triaged' );
}

// Set the status field for this project item.
debug(
`triage-issues > update-board: Setting the "Triaged" status for this project item, issue #${ number }.`
);
await setStatusField( projectOctokit, projectInfo, projectItemId, 'Triaged' );
}

// Try to assign the issue to a specific team, if we have a mapping of teams <> labels and a matching label on the issue.
@@ -694,7 +755,7 @@ async function updateBoard( payload, octokit, isBugIssue, priorityLabels ) {
payload,
projectInfo,
projectItemId,
isBugIssue,
isBug,
priorityLabels
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const getLabels = require( './get-labels' );

/* global GitHub */

/**
* Extract the type of the issue, based of the the "[Type]" labels found in that issue.
* If multiple Type labels can be found in the issue, we cannot extract a specific type.
* We will consequently return an empty string.
*
* @param {GitHub} octokit - Initialized Octokit REST client.
* @param {string} owner - Repository owner.
* @param {string} repo - Repository name.
* @param {string} number - Issue number.
* @return {Promise<string>} Promise resolving to a string, the type of the issue, extracted from the label.
*/
async function getIssueType( octokit, owner, repo, number ) {
const labels = await getLabels( octokit, owner, repo, number );

// Extract type labels, and return them all in a new array, but without the [Type] prefix.
const typeLabels = labels
.filter( label => label.startsWith( '[Type]' ) )
.map( label => label.replace( '[Type] ', '' ) );

// If there are multiple types defined in the issue, we cannot extract a specific type.
// We will consequently return an empty string.
if ( typeLabels.length !== 1 ) {
return '';
}

return typeLabels[ 0 ];
}

module.exports = getIssueType;
31 changes: 0 additions & 31 deletions projects/github-actions/repo-gardening/src/utils/labels/is-bug.js

This file was deleted.