Skip to content

Commit dffd44a

Browse files
authored
Merge pull request #12292 from github/repo-sync
repo sync
2 parents 6fe16b5 + 4e2881c commit dffd44a

4 files changed

Lines changed: 59 additions & 15 deletions

File tree

middleware/robots.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ export default function robots(req, res, next) {
88

99
res.type('text/plain')
1010

11-
// remove subdomain from host
12-
// docs-internal-12345--branch-name.herokuapp.com -> herokuapp.com
13-
const rootDomain = req.hostname.split('.').slice(1).join('.')
14-
15-
// prevent crawlers from indexing staging apps
16-
if (rootDomain === 'herokuapp.com') {
17-
return res.send(disallowAll)
11+
// only include robots.txt when it's our production domain and adding localhost for robots-txt.js test
12+
if (req.hostname === 'docs.github.com' || req.hostname === '127.0.0.1') {
13+
return res.send(defaultResponse)
1814
}
1915

20-
return res.send(defaultResponse)
16+
return res.send(disallowAll)
2117
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
"link-check-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en' PORT=4002 node server.mjs",
206206
"link-check-test": "cross-env node script/check-internal-links.js",
207207
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
208-
"lint-translation": "cross-env TEST_TRANSLATION=true jest content/lint-files",
208+
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules TEST_TRANSLATION=true jest tests/linting/lint-files.js",
209209
"pa11y-ci": "pa11y-ci",
210210
"pa11y-test": "start-server-and-test browser-test-server 4001 pa11y-ci",
211211
"prebrowser-test": "npm run build",

script/i18n/lint-translation-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import program from 'commander'
1212

1313
// Set up supported linting check types and their corresponding commands.
1414
const CHECK_COMMANDS = {
15-
parsing: 'TEST_TRANSLATION=true npx jest linting/lint-files',
15+
parsing: 'npm run lint-translation',
1616
rendering: 'script/i18n/test-render-translation.js',
1717
}
1818
const SUPPORTED_CHECK_TYPES = Object.keys(CHECK_COMMANDS)

tests/linting/lint-files.js

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,18 @@ describe('lint yaml content', () => {
679679
if (ymlToLint.length < 1) return
680680
describe.each(ymlToLint)('%s', (yamlRelPath, yamlAbsPath) => {
681681
let dictionary, isEarlyAccess, ifversionConditionals, ifConditionals
682+
// This variable is used to determine if the file was parsed successfully.
683+
// When `yaml.load()` fails to parse the file, it is overwritten with the error message.
684+
// `false` is intentionally chosen since `null` and `undefined` are valid return values.
685+
let dictionaryError = false
682686

683687
beforeAll(async () => {
684688
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
685-
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
689+
try {
690+
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
691+
} catch (error) {
692+
dictionaryError = error
693+
}
686694

687695
isEarlyAccess = yamlRelPath.split('/').includes('early-access')
688696

@@ -691,6 +699,10 @@ describe('lint yaml content', () => {
691699
ifConditionals = getLiquidConditionals(fileContents, 'if')
692700
})
693701

702+
test('it can be parsed as a single yaml document', () => {
703+
expect(dictionaryError).toBe(false)
704+
})
705+
694706
test('ifversion conditionals are valid in yaml', async () => {
695707
const errors = validateIfversionConditionals(ifversionConditionals)
696708
expect(errors.length, errors.join('\n')).toBe(0)
@@ -907,10 +919,19 @@ describe('lint GHES release notes', () => {
907919
if (ghesReleaseNotesToLint.length < 1) return
908920
describe.each(ghesReleaseNotesToLint)('%s', (yamlRelPath, yamlAbsPath) => {
909921
let dictionary
922+
let dictionaryError = false
910923

911924
beforeAll(async () => {
912925
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
913-
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
926+
try {
927+
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
928+
} catch (error) {
929+
dictionaryError = error
930+
}
931+
})
932+
933+
it('can be parsed as a single yaml document', () => {
934+
expect(dictionaryError).toBe(false)
914935
})
915936

916937
it('matches the schema', () => {
@@ -954,10 +975,19 @@ describe('lint GHAE release notes', () => {
954975
const currentWeeksFound = []
955976
describe.each(ghaeReleaseNotesToLint)('%s', (yamlRelPath, yamlAbsPath) => {
956977
let dictionary
978+
let dictionaryError = false
957979

958980
beforeAll(async () => {
959981
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
960-
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
982+
try {
983+
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
984+
} catch (error) {
985+
dictionaryError = error
986+
}
987+
})
988+
989+
it('can be parsed as a single yaml document', () => {
990+
expect(dictionaryError).toBe(false)
961991
})
962992

963993
it('matches the schema', () => {
@@ -1008,10 +1038,19 @@ describe('lint learning tracks', () => {
10081038
if (learningTracksToLint.length < 1) return
10091039
describe.each(learningTracksToLint)('%s', (yamlRelPath, yamlAbsPath) => {
10101040
let dictionary
1041+
let dictionaryError = false
10111042

10121043
beforeAll(async () => {
10131044
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
1014-
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
1045+
try {
1046+
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
1047+
} catch (error) {
1048+
dictionaryError = error
1049+
}
1050+
})
1051+
1052+
it('can be parsed as a single yaml document', () => {
1053+
expect(dictionaryError).toBe(false)
10151054
})
10161055

10171056
it('matches the schema', () => {
@@ -1083,10 +1122,19 @@ describe('lint feature versions', () => {
10831122
if (featureVersionsToLint.length < 1) return
10841123
describe.each(featureVersionsToLint)('%s', (yamlRelPath, yamlAbsPath) => {
10851124
let dictionary
1125+
let dictionaryError = false
10861126

10871127
beforeAll(async () => {
10881128
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
1089-
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
1129+
try {
1130+
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
1131+
} catch (error) {
1132+
dictionaryError = error
1133+
}
1134+
})
1135+
1136+
it('can be parsed as a single yaml document', () => {
1137+
expect(dictionaryError).toBe(false)
10901138
})
10911139

10921140
it('matches the schema', () => {

0 commit comments

Comments
 (0)