Skip to content

Commit

Permalink
Merge branch 'trunk' into refactor/social-register-feature-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjuhasz committed Dec 7, 2023
2 parents d7949bf + e625880 commit b7c2568
Show file tree
Hide file tree
Showing 259 changed files with 3,968 additions and 1,111 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/autotagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
export GIT_COMMITTER_NAME=matticbot
export [email protected]
EXIT=0
echo "Creating tags..."
TOPUSH=()
for T in "${TAGS[@]}"; do
Expand All @@ -79,8 +80,22 @@ jobs:
done
if [[ ${#TOPUSH[@]} -gt 0 ]]; then
echo "Pushing tags..."
git push origin "${TOPUSH[@]}"
echo "::notice::Created tags: ${TOPUSH[*]}"
# GitHub has a limit on the number of tags that can be updated in a single push. So do them in batches.
DONE=()
while [[ ${#TOPUSH[@]} -gt 0 ]]; do
BATCH=( "${TOPUSH[@]:0:5}" )
if git push origin "${BATCH[@]}"; then
DONE+=( "${BATCH[@]}" )
else
echo "::error::Failed to create tags: ${BATCH[*]}"
EXIT=1
fi
TOPUSH=( "${TOPUSH[@]:5}" )
done
if [[ ${#DONE[@]} -gt 0 ]]; then
echo "::notice::Created tags: ${DONE[*]}"
fi
else
echo "::notice::No tags needed creation."
fi
exit $EXIT
1 change: 1 addition & 0 deletions .github/workflows/slack-workflow-failed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- Build Docker
- Tests
- Gardening
- Monorepo Auto-tagger
- Post-Build
- PR is up-to-date
- Update Jetpack Staging Test Sites
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions projects/github-actions/repo-gardening/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The action relies on the following parameters.
- (Optional) `reply_to_customers_threshold`. It is optional, and defaults to 10. It is the minimum number of support references needed to trigger an alert that we need to reply to customers.
- (Optional) `triage_projects_token` is a [personal access token](https://github.com/settings/tokens/new) with `repo` and `project` scopes. The token should be stored in a secret. This is required if you want to use the `updateBoard` task.
- (Optional) `project_board_url` is the URL of a GitHub Project Board. We'll automate some of the work on that board in the `updateBoard` task.
- (Optional) `labels_team_assignments` is a list of features you can provide, with matching team names, as specified in the "Team" field of your GitHub Project Board used for the `updateBoard` task, and lists of labels in use in your repository.

#### How to create a Slack bot and get your SLACK_TOKEN

Expand Down
4 changes: 4 additions & 0 deletions projects/github-actions/repo-gardening/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ inputs:
description: "URL of the GitHub project board to update"
required: false
default: ""
labels_team_assignments:
description: "Mapping of team assignments for labels"
required: false
default: ""
runs:
using: node16
main: "dist/index.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Issue references: do not gather support references in Pull Requests, only in issues.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Issue references: avoid changing capitalization of p2 shortlinks.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Automated Board triage: fix event reference to trigger the action.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Project Board triage: automatically assign teams to an issue based on issue labels.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Issue references triage: update matching for p2 comments


2 changes: 1 addition & 1 deletion projects/github-actions/repo-gardening/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const automations = [
},
{
event: 'issues',
action: [ 'labeled' ],
action: [ 'labeled', 'opened' ],
task: updateBoard,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const debug = require( '../../utils/debug' );
const getAffectedChangeloggerProjects = require( '../../utils/get-affected-changelogger-projects' );
const getComments = require( '../../utils/get-comments' );
const getFiles = require( '../../utils/get-files' );
const getLabels = require( '../../utils/get-labels' );
const getNextValidMilestone = require( '../../utils/get-next-valid-milestone' );
const getPluginNames = require( '../../utils/get-plugin-names' );
const getPrWorkspace = require( '../../utils/get-pr-workspace' );
const getLabels = require( '../../utils/labels/get-labels' );

/* global GitHub, WebhookPayloadPullRequest */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const debug = require( '../../utils/debug' );
const getLabels = require( '../../utils/get-labels' );
const getLabels = require( '../../utils/labels/get-labels' );

/* global GitHub, WebhookPayloadPullRequest */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getInput, setFailed } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const sendSlackMessage = require( '../../utils/send-slack-message' );
const sendSlackMessage = require( '../../utils/slack/send-slack-message' );

/* global GitHub, WebhookPayloadPullRequest */

Expand All @@ -27,12 +27,6 @@ async function flagOss( payload, octokit ) {
labels: [ 'OSS Citizen' ],
} );

const slackToken = getInput( 'slack_token' );
if ( ! slackToken ) {
setFailed( `flag-oss: Input slack_token is required but missing. Aborting.` );
return;
}

const channel = getInput( 'slack_team_channel' );
if ( ! channel ) {
setFailed( `flag-oss: Input slack_team_channel is required but missing. Aborting.` );
Expand All @@ -43,7 +37,6 @@ async function flagOss( payload, octokit ) {
await sendSlackMessage(
`An external contributor submitted this PR. Be sure to go welcome them! 👏`,
channel,
slackToken,
payload
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { getInput } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const getComments = require( '../../utils/get-comments' );
const getLabels = require( '../../utils/get-labels' );
const sendSlackMessage = require( '../../utils/send-slack-message' );
const getLabels = require( '../../utils/labels/get-labels' );
const sendSlackMessage = require( '../../utils/slack/send-slack-message' );

/* global GitHub, WebhookPayloadIssue */

Expand Down Expand Up @@ -87,7 +87,11 @@ async function getIssueReferences( octokit, owner, repo, number, issueComments )
const correctedId = `${ wrongId[ 1 ] }-zen`;
correctedSupportIds.add( correctedId );
} else {
correctedSupportIds.add( supportId.toLowerCase() );
// Switch to lowercase when it's not a p2 comment reference.
const standardizedsupportId = supportId.match( /[a-zA-Z0-9-]+-p2#comment-[0-9]*/ )
? supportId
: supportId.toLowerCase();
correctedSupportIds.add( standardizedsupportId );
}
} );

Expand Down Expand Up @@ -230,7 +234,7 @@ async function checkForEscalation( issueReferences, commentBody, escalationNote,
);
const message = `:warning: This issue has now gathered more than 10 tickets. It may be time to reconsider its priority.`;
const slackMessageFormat = formatSlackMessage( payload, channel, message );
await sendSlackMessage( message, channel, slackToken, payload, slackMessageFormat );
await sendSlackMessage( message, channel, payload, slackMessageFormat );

return true;
}
Expand Down Expand Up @@ -430,10 +434,20 @@ async function addHappinessLabel( octokit, ownerLogin, repo, number ) {
* @param {GitHub} octokit - Initialized Octokit REST client.
*/
async function gatherSupportReferences( payload, octokit ) {
const { issue, repository } = payload;
const { number } = issue;
const {
issue: { number, pull_request },
repository,
} = payload;
const { name: repo, owner } = repository;

// Do not run this task on pull requests.
if ( pull_request ) {
debug(
`gather-support-references: do not gather support references on Pull Requests, here #${ number }. Aborting.`
);
return;
}

const issueComments = await getComments( octokit, owner.login, repo, number );
const issueReferences = await getIssueReferences( octokit, owner, repo, number, issueComments );
if ( issueReferences.length > 0 ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { getInput, setFailed } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const getLabels = require( '../../utils/get-labels' );
const sendSlackMessage = require( '../../utils/send-slack-message' );
const getLabels = require( '../../utils/labels/get-labels' );
const sendSlackMessage = require( '../../utils/slack/send-slack-message' );

/* global GitHub, WebhookPayloadPullRequest */

Expand Down Expand Up @@ -61,12 +61,6 @@ async function notifyDesign( payload, octokit ) {
const { owner, name: repo } = repository;
const ownerLogin = owner.login;

const slackToken = getInput( 'slack_token' );
if ( ! slackToken ) {
setFailed( `notify-design: Input slack_token is required but missing. Aborting.` );
return;
}

const channel = getInput( 'slack_design_channel' );
if ( ! channel ) {
setFailed( `notify-design: Input slack_design_channel is required but missing. Aborting.` );
Expand All @@ -89,7 +83,6 @@ async function notifyDesign( payload, octokit ) {
await sendSlackMessage(
`Someone would be interested in input from the Design team on this topic.`,
channel,
slackToken,
payload
);
}
Expand All @@ -103,7 +96,6 @@ async function notifyDesign( payload, octokit ) {
await sendSlackMessage(
`Someone is looking for a review from the design team.`,
channel,
slackToken,
payload
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { getInput, setFailed } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const getLabels = require( '../../utils/get-labels' );
const sendSlackMessage = require( '../../utils/send-slack-message' );
const getLabels = require( '../../utils/labels/get-labels' );
const sendSlackMessage = require( '../../utils/slack/send-slack-message' );

/* global GitHub, WebhookPayloadPullRequest */

Expand Down Expand Up @@ -98,7 +98,6 @@ async function notifyEditorial( payload, octokit ) {
await sendSlackMessage(
`Someone would be interested in input from the Editorial team on this topic.`,
channel,
slackToken,
payload
);
}
Expand All @@ -112,7 +111,6 @@ async function notifyEditorial( payload, octokit ) {
await sendSlackMessage(
`Someone is looking for a review from the Editorial team.`,
channel,
slackToken,
payload
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { getInput, setFailed } = require( '@actions/core' );
const debug = require( '../../utils/debug' );
const getComments = require( '../../utils/get-comments' );
const getLabels = require( '../../utils/get-labels' );
const sendSlackMessage = require( '../../utils/send-slack-message' );
const getLabels = require( '../../utils/labels/get-labels' );
const hasManySupportReferences = require( '../../utils/parse-content/has-many-support-references' );
const sendSlackMessage = require( '../../utils/slack/send-slack-message' );

/* global GitHub, WebhookPayloadIssue */

Expand All @@ -21,35 +22,6 @@ async function hasHighPriorityLabel( octokit, owner, repo, number ) {
return labels.some( label => label === '[Pri] High' || label === '[Pri] BLOCKER' );
}

/**
* Check if the issue has a comment with a list of support references,
* and at least x support references listed there.
* (x is specified with reply_to_customers_threshold input, default to 10).
* We only count the number of unanswered support references, since they're the ones we'll need to contact.
*
* @param {Array} issueComments - Array of all comments on that issue.
* @returns {Promise<boolean>} Promise resolving to boolean.
*/
async function hasManySupportReferences( issueComments ) {
const referencesThreshhold = getInput( 'reply_to_customers_threshold' );

let isWidelySpreadIssue = false;
issueComments.map( comment => {
if (
comment.user.login === 'github-actions[bot]' &&
comment.body.includes( '**Support References**' )
) {
// Count the number of to-do items in the comment.
const countReferences = comment.body.split( '- [ ] ' ).length - 1;
if ( countReferences >= parseInt( referencesThreshhold ) ) {
isWidelySpreadIssue = true;
}
}
} );

return isWidelySpreadIssue;
}

/**
* Build an object containing the slack message and its formatting to send to Slack.
*
Expand Down Expand Up @@ -136,14 +108,6 @@ async function replyToCustomersReminder( payload, octokit ) {
const { full_name, owner, name: repo } = repository;
const ownerLogin = owner.login;

const slackToken = getInput( 'slack_token' );
if ( ! slackToken ) {
setFailed(
`reply-to-customers-reminder: Input slack_token is required but missing. Aborting.`
);
return;
}

const channel = getInput( 'slack_he_triage_channel' );
if ( ! channel ) {
setFailed(
Expand Down Expand Up @@ -184,7 +148,7 @@ Before you send follow-up replies, you'll want to make sure the fix has been dep
}`;

const slackMessageFormat = formatSlackMessage( payload, channel, message );
await sendSlackMessage( message, channel, slackToken, payload, slackMessageFormat );
await sendSlackMessage( message, channel, payload, slackMessageFormat );
}

module.exports = replyToCustomersReminder;
Loading

0 comments on commit b7c2568

Please sign in to comment.