Skip to content

Commit 58e5118

Browse files
authored
Merge pull request github#28371 from github/repo-sync
Repo sync
2 parents abebafc + d4db0a4 commit 58e5118

File tree

4 files changed

+72
-90
lines changed

4 files changed

+72
-90
lines changed

.github/workflows/test.yml

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,66 +24,67 @@ env:
2424
ELASTICSEARCH_URL: http://localhost:9200/
2525

2626
jobs:
27-
figureOutMatrix:
28-
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
29-
runs-on: ubuntu-latest
30-
outputs:
31-
matrix: ${{ steps.set-matrix.outputs.result }}
32-
steps:
33-
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
34-
id: set-matrix
35-
with:
36-
script: |
37-
// We only want to run the 'languages' suite when we know
38-
// we're on the private docs-internal repo because only that
39-
// one has ability to clone the remote (private) languages
40-
// repos.
41-
// You can run multiple paths per suite as space-separated in `path`.
42-
// Note that *if you add* to this, remember to also add that
43-
// to the **required checks** in the branch protection rules.
44-
return [
45-
{ name: 'assets', path: 'src/assets/tests', },
46-
// { name: 'audit-logs', path: 'src/assets/audit-logs', },
47-
{ name: 'automated-pipelines', path: 'src/automated-pipelines/tests', },
48-
{ name: 'color-schemes', path: 'src/color-schemes/tests', },
49-
{ name: 'content', path: 'tests/content', },
50-
{ name: 'content-linter', path: 'src/content-linter/tests', },
51-
{ name: 'content-render', path: 'src/content-render/tests', },
52-
{ name: 'events', path: 'src/events/tests', },
53-
{ name: 'ghes-releases', path: 'src/ghes-releases/tests', },
54-
{ name: 'github-apps', path: 'src/github-apps/tests', },
55-
{ name: 'graphql', path: 'src/graphql/tests', },
56-
{ name: 'landings', path: 'src/landings/tests', },
57-
{ name: 'learning-track', path: 'src/learning-track/tests', },
58-
{ name: 'observability', path: 'src/observability/tests' },
59-
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
60-
{ name: 'redirects', path: 'src/redirects/tests', },
61-
{ name: 'release-notes', path: 'src/release-notes/tests', },
62-
{ name: 'rendering', path: 'tests/rendering', },
63-
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
64-
{ name: 'rest', path: 'src/rest/tests', },
65-
{ name: 'routing', path: 'tests/routing', },
66-
{ name: 'search', path: 'src/search/tests', },
67-
{ name: 'secret-scanning', path: 'src/secret-scanning/tests',},
68-
{ name: 'shielding', path: 'src/shielding/tests', },
69-
context.payload.repository.full_name === 'github/docs-internal' &&
70-
{ name: 'languages', path: 'src/languages/tests', },
71-
{ name: 'unit', path: 'tests/unit', },
72-
// { name: 'tools', path: 'src/tools/tests', }
73-
{ name: 'webhooks', path: 'src/webhooks/tests', },
74-
].filter(Boolean)
75-
7627
test:
7728
name: ${{ matrix.name }}
78-
needs: figureOutMatrix
29+
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
30+
7931
# Run on ubuntu-20.04-xl if the private repo or ubuntu-latest if the public repo
8032
# See pull # 17442 in the private repo for context
8133
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
8234
timeout-minutes: 60
8335
strategy:
8436
fail-fast: false
8537
matrix:
86-
include: ${{ fromJSON(needs.figureOutMatrix.outputs.matrix) }}
38+
# Note that *if you add* to this, remember to also add that
39+
# to the **required checks** in the branch protection rules.
40+
name:
41+
# tests/ directory
42+
- content
43+
- rendering
44+
- rendering-fixtures
45+
- routing
46+
- unit
47+
48+
# src/ directory
49+
- archives
50+
- assets
51+
# - audit-logs
52+
- automated-pipelines
53+
# - codeql-cli
54+
- color-schemes
55+
- content-linter
56+
- content-render
57+
- early-access
58+
- events
59+
# - frame
60+
- ghes-releases
61+
- github-apps
62+
- graphql
63+
- landings
64+
- languages
65+
- learning-track
66+
# - links
67+
- observability
68+
# - open-source
69+
- pageinfo
70+
# - pages
71+
- redirects
72+
- release-notes
73+
- rest
74+
- search
75+
- secret-scanning
76+
- shielding
77+
# - tools
78+
- versions
79+
- webhooks
80+
81+
# The languages suite only runs on docs-internal
82+
isPrivateRepo:
83+
- ${{ github.repository == 'github/docs-internal' }}
84+
exclude:
85+
- name: languages
86+
isPrivateRepo: false
87+
8788
steps:
8889
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
8990
# Even if if doesn't do anything
@@ -185,4 +186,10 @@ jobs:
185186
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
186187
ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'tests/fixtures' || '' }}
187188
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo') && 'tests/fixtures/translations' || '' }}
188-
run: npm test -- ${{ matrix.path }}/
189+
run: |
190+
if [ -d "tests/${{ matrix.name }}/" ]
191+
then
192+
npm test -- tests/${{ matrix.name }}/
193+
else
194+
npm test -- src/${{ matrix.name }}/tests/
195+
fi

src/content-linter/tests/unit/internal-link-punctuation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,15 @@ describe(internalLinkPunctuation.names.join(' - '), () => {
4343
expect(errors[0].errorRange).toEqual([2, 30])
4444
expect(errors[9].lineNumber).toBe(10)
4545
})
46+
test('links that is not plain text', async () => {
47+
const markdown = [
48+
'[*emphasize*](./image.png)',
49+
'[**boldness**](./image.png)',
50+
'[**boldness** and *emphasize*](./image.png)',
51+
].join('\n')
52+
53+
const result = await runRule(internalLinkPunctuation, { markdown })
54+
const errors = result.markdown
55+
expect(errors.length).toBe(0)
56+
})
4657
})

src/content-render/unified/rewrite-asset-img-tags.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
import { visit, SKIP } from 'unist-util-visit'
22

3-
/**
4-
* `structuredClone` was added in Node 17 and onwards.
5-
* https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility
6-
*
7-
* At the time of writing, we use Node 18 in CI and in production, but
8-
* someone might be previewing locally with an older version so
9-
* let's make a quick polyfill.
10-
* We could add a specific (`js-core`) package for this polyfill, but it's
11-
* fortunately not necessary in this context because it's safe enough
12-
* clone by turning into a string and back again.
13-
*/
14-
function structuredClonePolyfill(obj) {
15-
if (typeof structuredClone !== 'undefined') {
16-
return structuredClone(obj)
17-
} else {
18-
// Note, that this naive clone would turn Date objects into strings.
19-
// So don't use this polyfill if certain values aren't primitives
20-
// that JSON.parse can handle.
21-
return JSON.parse(JSON.stringify(obj))
22-
}
23-
}
24-
253
// This number must match a width we're willing to accept in a dynamic
264
// asset URL.
275
// (note this is exported for the sake of end-to-end tests' assertions)
@@ -52,7 +30,7 @@ export default function rewriteAssetImgTags() {
5230
return (tree) => {
5331
visit(tree, matcher, (node) => {
5432
if (node.properties.src.endsWith('.png')) {
55-
const copyPNG = structuredClonePolyfill(node)
33+
const copyPNG = structuredClone(node)
5634

5735
const sourceWEBP = {
5836
type: 'element',

src/links/lib/update-internal-links.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ import getRedirect, { splitPathByLanguage } from '#src/redirects/lib/get-redirec
2020
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
2121
import { deprecated } from '#src/versions/lib/enterprise-server-releases.js'
2222

23-
function objectClone(obj) {
24-
try {
25-
return structuredClone(obj)
26-
} catch {
27-
// Need to polyfill for Node 16 folks
28-
// Using `yaml.load(yaml.dump(...))` is safe enough because this
29-
// data itself came from the Yaml deserializing in frontmatter().
30-
return yaml.load(yaml.dump(obj))
31-
}
32-
}
33-
3423
// That magical string that can be turned into th actual title when
3524
// we, at runtime, render out the links
3625
const AUTOTITLE = 'AUTOTITLE'
@@ -94,10 +83,7 @@ async function updateFile(file, context, opts) {
9483
const replacements = []
9584
const warnings = []
9685

97-
// The day we know with confidence that everyone us on Node >=17,
98-
// we can change this to use `structuredClone` without the polyfill
99-
// technique.
100-
const newData = objectClone(data)
86+
const newData = structuredClone(data)
10187

10288
const ANY = Symbol('any')
10389
const IS_ARRAY = Symbol('is array')

0 commit comments

Comments
 (0)