Skip to content

Commit bdb704e

Browse files
authored
Merge branch 'main' into patch-2
2 parents fd3e81c + 685f9c9 commit bdb704e

File tree

388 files changed

+3112
-1717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+3112
-1717
lines changed

.github/actions-scripts/fr-add-docs-reviewers-requests.js

Lines changed: 97 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,83 @@ import {
88
generateUpdateProjectNextItemFieldMutation,
99
} from './projects.js'
1010

11-
async function run() {
12-
// Get info about the docs-content review board project
13-
// and about open github/github PRs
14-
const data = await graphql(
15-
`
16-
query ($organization: String!, $repo: String!, $projectNumber: Int!, $num_prs: Int!) {
17-
organization(login: $organization) {
18-
projectNext(number: $projectNumber) {
19-
id
20-
items(last: 100) {
11+
async function getAllOpenPRs() {
12+
let prsRemaining = true
13+
let cursor
14+
let prData = []
15+
while (prsRemaining) {
16+
const data = await graphql(
17+
`
18+
query ($organization: String!, $repo: String!) {
19+
repository(name: $repo, owner: $organization) {
20+
pullRequests(last: 100, states: OPEN${cursor ? ` before:"${cursor}"` : ''}) {
21+
pageInfo{startCursor, hasPreviousPage},
2122
nodes {
2223
id
23-
}
24-
}
25-
fields(first: 20) {
26-
nodes {
27-
id
28-
name
29-
settings
30-
}
31-
}
32-
}
33-
}
34-
repository(name: $repo, owner: $organization) {
35-
pullRequests(last: $num_prs, states: OPEN) {
36-
nodes {
37-
id
38-
isDraft
39-
reviewRequests(first: 10) {
40-
nodes {
41-
requestedReviewer {
42-
... on Team {
43-
name
24+
isDraft
25+
reviewRequests(first: 10) {
26+
nodes {
27+
requestedReviewer {
28+
... on Team {
29+
name
30+
}
4431
}
4532
}
4633
}
47-
}
48-
labels(first: 5) {
49-
nodes {
50-
name
34+
labels(first: 5) {
35+
nodes {
36+
name
37+
}
5138
}
52-
}
53-
reviews(first: 10) {
54-
nodes {
55-
onBehalfOf(first: 1) {
56-
nodes {
57-
name
39+
reviews(first: 10) {
40+
nodes {
41+
onBehalfOf(first: 1) {
42+
nodes {
43+
name
44+
}
5845
}
5946
}
6047
}
61-
}
62-
author {
63-
login
48+
author {
49+
login
50+
}
6451
}
6552
}
6653
}
6754
}
55+
`,
56+
{
57+
organization: process.env.ORGANIZATION,
58+
repo: process.env.REPO,
59+
headers: {
60+
authorization: `token ${process.env.TOKEN}`,
61+
},
6862
}
69-
`,
70-
{
71-
organization: process.env.ORGANIZATION,
72-
repo: process.env.REPO,
73-
projectNumber: parseInt(process.env.PROJECT_NUMBER),
74-
num_prs: parseInt(process.env.NUM_PRS),
75-
headers: {
76-
authorization: `token ${process.env.TOKEN}`,
77-
'GraphQL-Features': 'projects_next_graphql',
78-
},
79-
}
80-
)
63+
)
64+
65+
prsRemaining = data.repository.pullRequests.pageInfo.hasPreviousPage
66+
cursor = data.repository.pullRequests.pageInfo.startCursor
67+
prData = [...prData, ...data.repository.pullRequests.nodes]
68+
}
69+
70+
return prData
71+
}
72+
73+
async function run() {
74+
// Get info about open github/github PRs
75+
const prData = await getAllOpenPRs()
8176

8277
// Get the PRs that are:
8378
// - not draft
8479
// - not a train
8580
// - are requesting a review by docs-reviewers
8681
// - have not already been reviewed on behalf of docs-reviewers
87-
const prs = data.repository.pullRequests.nodes.filter(
82+
const prs = prData.filter(
8883
(pr) =>
8984
!pr.isDraft &&
9085
!pr.labels.nodes.find((label) => label.name === 'Deploy train 🚂') &&
9186
pr.reviewRequests.nodes.find(
92-
(requestedReviewers) => requestedReviewers.requestedReviewer.name === process.env.REVIEWER
87+
(requestedReviewers) => requestedReviewers.requestedReviewer?.name === process.env.REVIEWER
9388
) &&
9489
!pr.reviews.nodes
9590
.flatMap((review) => review.onBehalfOf.nodes)
@@ -104,28 +99,60 @@ async function run() {
10499
const prAuthors = prs.map((pr) => pr.author.login)
105100
console.log(`PRs found: ${prIDs}`)
106101

102+
// Get info about the docs-content review board project
103+
const projectData = await graphql(
104+
`
105+
query ($organization: String!, $projectNumber: Int!) {
106+
organization(login: $organization) {
107+
projectNext(number: $projectNumber) {
108+
id
109+
items(last: 100) {
110+
nodes {
111+
id
112+
}
113+
}
114+
fields(first: 100) {
115+
nodes {
116+
id
117+
name
118+
settings
119+
}
120+
}
121+
}
122+
}
123+
}
124+
`,
125+
{
126+
organization: process.env.ORGANIZATION,
127+
projectNumber: parseInt(process.env.PROJECT_NUMBER),
128+
headers: {
129+
authorization: `token ${process.env.TOKEN}`,
130+
},
131+
}
132+
)
133+
107134
// Get the project ID
108-
const projectID = data.organization.projectNext.id
135+
const projectID = projectData.organization.projectNext.id
109136

110137
// Get the IDs of the last 100 items on the board.
111138
// Until we have a way to check from a PR whether the PR is in a project,
112139
// this is how we (roughly) avoid overwriting PRs that are already on the board.
113140
// If we are overwriting items, query for more items.
114-
const existingItemIDs = data.organization.projectNext.items.nodes.map((node) => node.id)
141+
const existingItemIDs = projectData.organization.projectNext.items.nodes.map((node) => node.id)
115142

116143
// Get the ID of the fields that we want to populate
117-
const datePostedID = findFieldID('Date posted', data)
118-
const reviewDueDateID = findFieldID('Review due date', data)
119-
const statusID = findFieldID('Status', data)
120-
const featureID = findFieldID('Feature', data)
121-
const contributorTypeID = findFieldID('Contributor type', data)
122-
const sizeTypeID = findFieldID('Size', data)
123-
const authorID = findFieldID('Contributor', data)
144+
const datePostedID = findFieldID('Date posted', projectData)
145+
const reviewDueDateID = findFieldID('Review due date', projectData)
146+
const statusID = findFieldID('Status', projectData)
147+
const featureID = findFieldID('Feature', projectData)
148+
const contributorTypeID = findFieldID('Contributor type', projectData)
149+
const sizeTypeID = findFieldID('Size', projectData)
150+
const authorID = findFieldID('Contributor', projectData)
124151

125152
// Get the ID of the single select values that we want to set
126-
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', data)
127-
const hubberTypeID = findSingleSelectID('Hubber or partner', 'Contributor type', data)
128-
const docsMemberTypeID = findSingleSelectID('Docs team', 'Contributor type', data)
153+
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', projectData)
154+
const hubberTypeID = findSingleSelectID('Hubber or partner', 'Contributor type', projectData)
155+
const docsMemberTypeID = findSingleSelectID('Docs team', 'Contributor type', projectData)
129156

130157
// Add the PRs to the project
131158
const itemIDs = await addItemsToProject(prIDs, projectID)

.github/actions-scripts/projects.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ export async function isDocsTeamMember(login) {
114114
return teamMembers.includes(login)
115115
}
116116

117+
// Given a GitHub login, returns a bool indicating
118+
// whether the login is part of the GitHub org
119+
export async function isGitHubOrgMember(login) {
120+
const data = await graphql(
121+
`
122+
query {
123+
user(login: "${login}") {
124+
organization(login: "github"){
125+
name
126+
}
127+
}
128+
}
129+
`,
130+
{
131+
headers: {
132+
authorization: `token ${process.env.TOKEN}`,
133+
},
134+
}
135+
)
136+
137+
return Boolean(data.user.organization)
138+
}
139+
117140
// Formats a date object into the required format for projects
118141
export function formatDateForProject(date) {
119142
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
@@ -246,6 +269,7 @@ export default {
246269
addItemsToProject,
247270
addItemToProject,
248271
isDocsTeamMember,
272+
isGitHubOrgMember,
249273
findFieldID,
250274
findSingleSelectID,
251275
formatDateForProject,

.github/actions-scripts/ready-for-docs-review.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { graphql } from '@octokit/graphql'
33
import {
44
addItemToProject,
55
isDocsTeamMember,
6+
isGitHubOrgMember,
67
findFieldID,
78
findSingleSelectID,
89
generateUpdateProjectNextItemFieldMutation,
@@ -178,9 +179,12 @@ async function run() {
178179
let contributorType
179180
if (await isDocsTeamMember(process.env.AUTHOR_LOGIN)) {
180181
contributorType = docsMemberTypeID
182+
} else if (await isGitHubOrgMember(process.env.AUTHOR_LOGIN)) {
183+
contributorType = hubberTypeID
181184
} else if (process.env.REPO === 'github/docs') {
182185
contributorType = osContributorTypeID
183186
} else {
187+
// use hubber as the fallback so that the PR doesn't get lost on the board
184188
contributorType = hubberTypeID
185189
}
186190

.github/allowed-actions.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
34-
- uses: github/codeql-action/init@v1
34+
- uses: github/codeql-action/init@5f532563584d71fdef14ee64d17bafb34f751ce5
3535
with:
3636
languages: javascript # comma separated list of values from {go, python, javascript, java, cpp, csharp} (not YET ruby, sorry!)
37-
- uses: github/codeql-action/analyze@v1
37+
- uses: github/codeql-action/analyze@5f532563584d71fdef14ee64d17bafb34f751ce5
3838
continue-on-error: true

.github/workflows/docs-review-collect.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,3 @@ jobs:
4040
ORGANIZATION: 'github'
4141
REPO: 'github'
4242
REVIEWER: 'docs-reviewers'
43-
# This is an educated guess of how many PRs are opened in a day on the github/github repo
44-
# If we are missing PRs, either increase this number or increase the frequency at which this script is run
45-
NUM_PRS: 100

.github/workflows/hubber-contribution-help.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Hubber contribution help
55
# **Who does it impact**: docs-internal contributors
66

77
on:
8-
pull_request:
8+
pull_request_target:
99
types:
1010
- opened
1111
paths:

.github/workflows/link-check-all.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
output: ' '
4747
- name: Insight into changed files
4848
run: |
49-
echo ${{ steps.get_diff_files.outputs.files }}
49+
echo "${{ steps.get_diff_files.outputs.files }}"
5050
5151
- name: Link check (warnings, changed files)
5252
run: |
@@ -56,7 +56,7 @@ jobs:
5656
--check-anchors \
5757
--check-images \
5858
--verbose \
59-
${{ steps.get_diff_files.outputs.files }}
59+
"${{ steps.get_diff_files.outputs.files }}"
6060
6161
- name: Link check (critical, all files)
6262
run: |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Orphaned assets check'
2+
3+
# **What it does**: Checks that there are no files in ./assets/ that aren't mentioned in any source file.
4+
# **Why we have it**: To avoid orphans into the repo.
5+
# **Who does it impact**: Docs content.
6+
7+
on:
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
19+
20+
- name: Setup node
21+
uses: actions/setup-node@04c56d2f954f1e4c69436aa54cfef261a018f458
22+
with:
23+
node-version: 16.13.x
24+
cache: npm
25+
26+
- name: Install
27+
run: npm ci
28+
29+
- name: Check for orphaned assets
30+
run: ./script/find-orphaned-assets.mjs --verbose --exit

0 commit comments

Comments
 (0)