Skip to content

Commit 48b9b49

Browse files
authored
Merge pull request #28117 from github/repo-sync
Repo sync
2 parents d4f1665 + 5a95792 commit 48b9b49

35 files changed

+487
-455
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ jobs:
5353
{ name: 'github-apps', path: 'src/github-apps/tests', },
5454
{ name: 'graphql', path: 'src/graphql/tests', },
5555
{ name: 'landings', path: 'src/landings/tests', },
56-
// { name: 'learning-track', path: 'src/learning-track/tests', },
56+
{ name: 'learning-track', path: 'src/learning-track/tests', },
5757
{ name: 'linting', path: 'src/content-linter/tests', },
5858
{ name: 'observability', path: 'src/observability/tests' },
5959
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
6060
{ name: 'redirects', path: 'src/redirects/tests', },
61+
{ name: 'release-notes', path: 'src/release-notes/tests', },
6162
{ name: 'rendering', path: 'tests/rendering', },
6263
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
6364
{ name: 'rest', path: 'src/rest/tests', },
6465
{ name: 'routing', path: 'tests/routing', },
6566
{ name: 'search', path: 'src/search/tests', },
67+
{ name: 'secret-scanning', path: 'src/secret-scanning/tests',},
6668
{ name: 'shielding', path: 'src/shielding/tests', },
6769
context.payload.repository.full_name === 'github/docs-internal' &&
6870
{ name: 'languages', path: 'src/languages/tests', },

content/apps/creating-github-apps/writing-code-for-a-github-app/building-ci-checks-with-a-github-app.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ class GHAapp < Sinatra::Application
319319
# this request is an attack, and you should reject it. GitHub uses the HMAC
320320
# hexdigest to compute the signature. The `X-HUB-Signature` looks something
321321
# like this: 'sha1=123456'.
322-
# See https://developer.github.com/webhooks/securing/ for details.
323322
def verify_webhook_signature
324323
their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='
325324
method, their_digest = their_signature_header.split('=')
@@ -571,7 +570,7 @@ You can test that the server is listening to your app by triggering an event for
571570

572571
1. Create a new repository to use for testing your tutorial code. For more information, see "[AUTOTITLE](/repositories/creating-and-managing-repositories/creating-a-new-repository)."
573572
1. Install the {% data variables.product.prodname_github_app %} on the repository you just created. For more information, see "[AUTOTITLE](/apps/using-github-apps/installing-your-own-github-app#installing-your-own-github-app)." During the installation process, choose **Only select repositories**, and select the repository you created in the previous step.
574-
2. After you click **Install**, look at the output in the terminal tab where you're running `server.rb`. You should see something like this:
573+
1. After you click **Install**, look at the output in the terminal tab where you're running `server.rb`. You should see something like this:
575574

576575
```shell
577576
> D, [2023-06-08T15:45:43.773077 #30488] DEBUG -- : ---- received event installation
@@ -1147,7 +1146,7 @@ To push to a repository, your app must have write permissions for "Contents" in
11471146
To commit files, Git must know which username and email address to associate with the commit. Next you'll add environment variables to store the name and email address that your app will use when it makes Git commits.
11481147
11491148
1. Open the `.env` file you created earlier in this tutorial.
1150-
2. Add the following environment variables to your `.env` file. Replace `APP_NAME` with the name of your app, and `EMAIL_ADDRESS` with any email you'd like to use for this example.
1149+
1. Add the following environment variables to your `.env` file. Replace `APP_NAME` with the name of your app, and `EMAIL_ADDRESS` with any email you'd like to use for this example.
11511150
11521151
```shell copy
11531152
GITHUB_APP_USER_NAME="APP_NAME"
@@ -1542,7 +1541,6 @@ class GHAapp < Sinatra::Application
15421541
# this request is an attack, and you should reject it. GitHub uses the HMAC
15431542
# hexdigest to compute the signature. The `X-HUB-Signature` looks something
15441543
# like this: 'sha1=123456'.
1545-
# See https://developer.github.com/webhooks/securing/ for details.
15461544
def verify_webhook_signature
15471545
their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='
15481546
method, their_digest = their_signature_header.split('=')

lib/ajv-validate.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Ajv from 'ajv'
2+
import addErrors from 'ajv-errors'
3+
import addFormats from 'ajv-formats'
4+
import semver from 'semver'
5+
6+
const ajv = new Ajv({ allErrors: true, allowUnionTypes: true })
7+
addFormats(ajv)
8+
addErrors(ajv)
9+
// *** TODO: We can drop this override once the frontmatter schema has been updated to work with AJV. ***
10+
ajv.addFormat('semver', {
11+
validate: (x) => semver.validRange(x),
12+
})
13+
14+
export function ajvValidate(schema) {
15+
return ajv.compile(schema)
16+
}

src/content-linter/lib/default-markdownlint-options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export function testOptions(rule, module, fixtureFile) {
1+
export function testOptions(rule, module, strings) {
22
const config = {
33
default: false,
44
[rule]: true,
55
}
66

77
const options = {
8-
files: [fixtureFile],
8+
strings,
99
customRules: [module],
1010
config,
1111
}

src/content-linter/lib/helpers/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ export function getRange(line, content) {
99
const startColumnIndex = line.indexOf(content)
1010
return startColumnIndex !== -1 ? [startColumnIndex + 1, content.length] : null
1111
}
12+
13+
export function isStringQuoted(text) {
14+
// String starts with either a single or double quote
15+
// ends with either a single or double quote
16+
// and optionally ends with a question mark or exclamation point
17+
// because that punctuation can exist outside of the quoted string
18+
const regex = /^['"].*['"][?!]?$/
19+
return text.match(regex)
20+
}

src/content-linter/lib/init-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import markdownlint from 'markdownlint'
22

33
import { testOptions } from './default-markdownlint-options.js'
44

5-
export async function runRule(module, fixtureFile) {
6-
const options = testOptions(module.names[0], module, fixtureFile)
5+
export async function runRule(module, strings) {
6+
const options = testOptions(module.names[0], module, strings)
77
return await markdownlint.promises.markdownlint(options)
88
}

src/content-linter/lib/linting-rules/image-alt-text-end-punctuation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { forEachInlineChild } from 'markdownlint-rule-helpers'
22

3-
import { addFixErrorDetail, getRange } from '../helpers/utils.js'
3+
import { addFixErrorDetail, getRange, isStringQuoted } from '../helpers/utils.js'
44

55
export const imageAltTextEndPunctuation = {
66
names: ['GHD002', 'image-alt-text-end-punctuation'],
@@ -20,7 +20,9 @@ export const imageAltTextEndPunctuation = {
2020
) {
2121
addFixErrorDetail(onError, token.lineNumber, imageAltText + '.', imageAltText, range, {
2222
lineNumber: token.lineNumber,
23-
editColumn: token.line.indexOf(']') + 1,
23+
editColumn: isStringQuoted(imageAltText)
24+
? token.line.indexOf(']')
25+
: token.line.indexOf(']') + 1,
2426
deleteCount: 0,
2527
insertText: '.',
2628
})

src/content-linter/lib/linting-rules/internal-links-lang.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { filterTokens } from 'markdownlint-rule-helpers'
2-
32
import { addFixErrorDetail, getRange } from '../helpers/utils.js'
4-
import { languageKeys } from '#src/languages/lib/languages.js'
3+
import { allLanguageKeys } from '#src/languages/lib/languages.js'
54

65
export const internalLinksLang = {
76
names: ['GHD005', 'internal-links-lang'],
@@ -24,7 +23,7 @@ export const internalLinksLang = {
2423
.filter((attr) => attr[0] === 'href')
2524
.filter((attr) => attr[1].startsWith('/') || !attr[1].startsWith('//'))
2625
// Filter out link paths that start with language code
27-
.filter((attr) => languageKeys.some((lang) => attr[1].split('/')[1] === lang))
26+
.filter((attr) => allLanguageKeys.some((lang) => attr[1].split('/')[1] === lang))
2827
// Get the link path from the attribute
2928
.map((attr) => attr[1])
3029
// Create errors for each link path that includes a language code

src/content-linter/scripts/markdownlint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ main()
4646
async function main() {
4747
// If paths has not been specified, lint all files
4848
const files = getFilesToLint((summaryByRule && ALL_CONTENT_DIR) || paths || getChangedFiles())
49-
const spinner = ora({ text: 'Running content linter', spinner: 'simpleDots' })
49+
const spinner = ora({ text: 'Running content linter\n\n', spinner: 'simpleDots' })
5050

5151
if (!files.length) {
5252
spinner.succeed('No files to lint')

src/content-linter/style/github-docs.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const githubDocsConfig = {
3434
severity: 'error',
3535
'partial-markdown-files': true,
3636
},
37+
'no-github-docs-domains': {
38+
// GHD020
39+
severity: 'error',
40+
'partial-markdown-files': true,
41+
},
3742
'search-replace': {
3843
severity: 'error',
3944
'severity-local-env': 'warning',
@@ -45,6 +50,34 @@ export const githubDocsConfig = {
4550
search: 'TODOCS',
4651
searchScope: 'all',
4752
},
53+
{
54+
name: 'docs-domain',
55+
message: 'Catch occurrences of docs.gitub.com domain.',
56+
search: 'docs.gitub.com',
57+
searchScope: 'all',
58+
},
59+
{
60+
name: 'help-domain',
61+
message: 'Catch occurrences of help.github.com domain.',
62+
search: 'help.github.com',
63+
searchScope: 'all',
64+
},
65+
{
66+
name: 'preview-domain',
67+
message: 'Catch occurrences of preview.ghdocs.com domain.',
68+
search: 'preview.ghdocs.com',
69+
searchScope: 'all',
70+
},
71+
{
72+
name: 'developer-domain',
73+
message: 'Catch occurrences of developer.github.com domain.',
74+
// Do not match developer.github.com/changes or
75+
// developer.github.com/enterprise/[0-9] or
76+
// developer.github.com/enterprise/{{something}} (e.g. liquid).
77+
// There are occurences that will likely always remain in the content.
78+
searchPattern: '/developer.github.com(?!/(changes|enterprise/([0-9]|{))).*/g',
79+
searchScope: 'all',
80+
},
4881
],
4982
},
5083
}

0 commit comments

Comments
 (0)