Skip to content

Commit c6015f3

Browse files
authored
Merge branch 'main' into add-gh-pages-token-perms
2 parents 773be85 + 2477c4d commit c6015f3

1,664 files changed

Lines changed: 32558 additions & 30214 deletions

File tree

Some content is hidden

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

.github/actions-scripts/purge-fastly-edge-cache.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,4 @@
22

33
import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js'
44

5-
try {
6-
await purgeEdgeCache()
7-
} catch (error) {
8-
console.error(`Failed to purge the edge cache: ${error.message}`)
9-
console.error(error)
10-
throw error
11-
}
5+
await purgeEdgeCache()

.github/actions-scripts/update-merge-queue-branch.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ const github = getOctokit(token)
88
// https://docs.github.com/en/graphql/reference/enums#mergestatestatus
99
// https://docs.github.com/en/graphql/reference/enums#mergeablestate
1010

11-
/*
12-
This script gets a list of automerge-enabled PRs and sorts them
11+
/*
12+
This script gets a list of automerge-enabled PRs and sorts them
1313
by priority. The PRs with the skip-to-front-of-merge-queue label
14-
are prioritized first. The rest of the PRs are sorted by the date
15-
they were updated. This is basically a FIFO queue, while allowing
14+
are prioritized first. The rest of the PRs are sorted by the date
15+
they were updated. This is basically a FIFO queue, while allowing
1616
writers the ability to skip the line when high-priority ships are
1717
needed but a freeze isn't necessary.
1818
*/
1919

20+
const DRY_RUN = Boolean(JSON.parse(process.env.DRY_RUN || 'false'))
21+
2022
main()
2123

2224
async function main() {
@@ -47,6 +49,15 @@ async function main() {
4749
name
4850
}
4951
}
52+
commits(last: 1) {
53+
nodes {
54+
commit {
55+
statusCheckRollup {
56+
state
57+
}
58+
}
59+
}
60+
}
5061
}
5162
}
5263
pageInfo {
@@ -105,6 +116,14 @@ async function main() {
105116
// a PR is green and the automerge is enabled
106117
.filter((pr) => pr.mergeStateStatus !== 'DIRTY')
107118
.filter((pr) => pr.mergeStateStatus !== 'UNSTABLE')
119+
.filter((pr) => {
120+
const nodes = pr.commits.nodes
121+
if (!nodes || !nodes.length) {
122+
// If it has no commits, why is it even here? Anyway, skip it.
123+
return false
124+
}
125+
return nodes[0].commit.statusCheckRollup.state !== 'FAILURE'
126+
})
108127

109128
autoMergeEnabledPRs.push(...filteredPrs)
110129
}
@@ -120,11 +139,15 @@ async function main() {
120139
if (prioritizedPrList.length) {
121140
const nextInQueue = prioritizedPrList.shift()
122141
// Update the branch for the next PR in the merge queue
123-
github.rest.pulls.updateBranch({
124-
owner: org,
125-
repo,
126-
pull_number: nextInQueue.number,
127-
})
142+
if (DRY_RUN) {
143+
console.log('DRY RUN! But *would* update on next-in-queue')
144+
} else {
145+
github.rest.pulls.updateBranch({
146+
owner: org,
147+
repo,
148+
pull_number: nextInQueue.number,
149+
})
150+
}
128151
console.log(`⏱ Total PRs in the merge queue: ${prioritizedPrList.length + 1}`)
129152
console.log(`🚂 Updated branch for PR #${JSON.stringify(nextInQueue, null, 2)}`)
130153
}

.github/workflows/browser-test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,17 @@ jobs:
4949
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
5050
run: npm ci --include=optional
5151

52+
- name: Cache nextjs build
53+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
54+
with:
55+
path: .next/cache
56+
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}-${{ hashFiles('.github/workflows/browser-test.yml') }}
57+
58+
- name: Cache lib/redirects/.redirects-cache_en_ja.json
59+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
60+
with:
61+
path: lib/redirects/.redirects-cache_en_ja.json
62+
key: ${{ runner.os }}-redirects-cache-${{ hashFiles('.github/workflows/browser-test.yml') }}
63+
5264
- name: Run browser-test
5365
run: npm run browser-test
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
name: Lint JS
1+
name: Lint code
22

3-
# **What it does**: Lints our JavaScript to ensure the code matches the specified code style.
4-
# **Why we have it**: We want some level of consistency to our JavaScript.
3+
# **What it does**: Lints our code to ensure the code matches the specified code style.
4+
# **Why we have it**: We want some level of consistency to our code.
55
# **Who does it impact**: Docs engineering, open-source engineering contributors.
66

7+
permissions:
8+
contents: read
9+
710
on:
811
workflow_dispatch:
912
push:
@@ -15,10 +18,13 @@ on:
1518
- '**.mjs'
1619
- '**.ts'
1720
- '**.tsx'
21+
- '**.yaml'
22+
- '**.yml'
23+
- '**.scss'
1824
# In case something like eslint or tsc or prettier upgrades
1925
- 'package-lock.json'
2026
# Ultimately, for debugging this workflow itself
21-
- .github/workflows/js-lint.yml
27+
- .github/workflows/code-lint.yml
2228

2329
jobs:
2430
lint:
@@ -39,5 +45,8 @@ jobs:
3945
- name: Run linter
4046
run: npm run lint
4147

48+
- name: Run Prettier
49+
run: npm run prettier-check
50+
4251
- name: Run TypeScript
4352
run: npm run tsc

.github/workflows/create-translation-batch-pr.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
jobs:
1717
create-translation-batch:
1818
name: Create translation batch
19+
if: github.repository == 'github/docs-internal'
1920
runs-on: ubuntu-latest
2021
# A sync's average run time is ~3.2 hours.
2122
# This sets a maximum execution time of 300 minutes (5 hours) to prevent the workflow from running longer than necessary.
@@ -66,8 +67,14 @@ jobs:
6667
wget https://artifacts.crowdin.com/repo/deb/crowdin3.deb -O /tmp/crowdin.deb
6768
sudo dpkg -i /tmp/crowdin.deb
6869
70+
# Delete empty source files that would be rejected by Crowdin breaking the workflow
71+
- name: Remove empty source files
72+
run: |
73+
find content -type f -empty -delete
74+
find data -type f -empty -delete
75+
6976
- name: Upload files to crowdin
70-
run: crowdin upload sources --no-progress --no-colors --verbose --debug '--branch=main' '--config=crowdin.yml'
77+
run: crowdin upload sources --delete-obsolete --no-progress --no-colors --verbose --debug '--branch=main' '--config=crowdin.yml'
7178
env:
7279
# This is a numeric id, not to be confused with Crowdin API v1 "project identifier" string
7380
# See "API v2" on https://crowdin.com/project/<your-project>/settings#api
@@ -162,7 +169,8 @@ jobs:
162169
gh pr create --title "New translation batch for ${{ matrix.language }}" \
163170
--base=main \
164171
--head=${{ steps.set-branch.outputs.BRANCH_NAME }} \
165-
--body-file /tmp/pr-body.txt || git push origin :${{ steps.set-branch.outputs.BRANCH_NAME }}
172+
--body-file /tmp/pr-body.txt || git push origin :${{ steps.set-branch.outputs.BRANCH_NAME }} \
173+
--label "translation-batch"
166174
167175
# When the maximum execution time is reached for this job, Actions cancels the workflow run.
168176
# This emits a notification for the first responder to triage.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 'Link Checker: All English'
2+
3+
# **What it does**: Renders the content of every page and check all internal links.
4+
# **Why we have it**: To make sure all links connect correctly.
5+
# **Who does it impact**: Docs content.
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
14+
permissions:
15+
contents: read
16+
# Needed for the 'trilom/file-changes-action' action
17+
pull-requests: read
18+
19+
jobs:
20+
build:
21+
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
25+
26+
- name: Setup node
27+
uses: actions/setup-node@04c56d2f954f1e4c69436aa54cfef261a018f458
28+
with:
29+
node-version: 16.13.x
30+
cache: npm
31+
32+
- name: Install
33+
run: npm ci
34+
35+
- name: Gather files changed
36+
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
37+
id: get_diff_files
38+
with:
39+
# So that `steps.get_diff_files.outputs.files` becomes
40+
# a string like `foo.js path/bar.md`
41+
output: ' '
42+
- name: Insight into changed files
43+
run: |
44+
echo ${{ steps.get_diff_files.outputs.files }}
45+
46+
- name: Link check (warnings, changed files)
47+
run: |
48+
./script/rendered-content-link-checker.mjs \
49+
--language en \
50+
--max 100 \
51+
--check-anchors \
52+
--check-images \
53+
--verbose \
54+
${{ steps.get_diff_files.outputs.files }}
55+
56+
- name: Link check (critical, all files)
57+
run: |
58+
59+
./script/rendered-content-link-checker.mjs \
60+
--language en \
61+
--exit \
62+
--verbose \
63+
--check-images \
64+
--level critical

.github/workflows/prod-build-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ jobs:
178178
env:
179179
FASTLY_TOKEN: ${{ secrets.FASTLY_TOKEN }}
180180
FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }}
181-
FASTLY_SURROGATE_KEY: 'all-the-things'
181+
FASTLY_SURROGATE_KEY: 'every-deployment'
182182
run: .github/actions-scripts/purge-fastly-edge-cache.js
183183

184184
- name: Send Slack notification if workflow failed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sync search - PR
2+
3+
# **What it does**: Tries running the sync-search when relevant files change.
4+
# **Why we have it**: To test that the script works and the popular pages json is valid.
5+
# **Who does it impact**: Docs engineering.
6+
7+
on:
8+
pull_request:
9+
paths:
10+
- script/search/parse-page-sections-into-records.js
11+
- script/search/popular-pages.js
12+
- lib/search/popular-pages.json
13+
# Ultimately, for debugging this workflow itself
14+
- .github/workflows/sync-search-pr.yml
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out repo
21+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
22+
23+
- name: Setup node
24+
uses: actions/setup-node@04c56d2f954f1e4c69436aa54cfef261a018f458
25+
with:
26+
node-version: 16.13.x
27+
cache: npm
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Run sync-search
36+
env:
37+
# Set filtered to only these so it doesn't run for too long.
38+
LANGUAGE: en
39+
VERSION: free-pro-team@latest
40+
run: npm run sync-search

.github/workflows/test.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ jobs:
7070
- name: Install dependencies
7171
run: npm ci
7272

73-
- if: ${{ github.repository == 'github/docs-internal' }}
74-
name: Clone early access
75-
run: npm run heroku-postbuild
73+
- name: Clone early access
74+
if: ${{ github.repository == 'github/docs-internal' }}
75+
run: script/early-access/clone-for-build.js
7676
env:
7777
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
7878
GIT_BRANCH: ${{ github.head_ref || github.ref }}
7979

80-
- if: ${{ github.repository != 'github/docs-internal' }}
81-
name: Run build script
80+
- name: Cache nextjs build
81+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
82+
with:
83+
path: .next/cache
84+
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}-${{ hashFiles('.github/workflows/test.yml') }}
85+
86+
- name: Run build script
8287
run: npm run build
8388

8489
- name: Run tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ coverage/
1010
/data/early-access
1111
.next
1212
.eslintcache
13+
*.tsbuildinfo
1314

1415
# blc: broken link checker
1516
blc_output.log

0 commit comments

Comments
 (0)