-
Notifications
You must be signed in to change notification settings - Fork 59.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34599 from github/repo-sync
Repo sync
- Loading branch information
Showing
19 changed files
with
187 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ jobs: | |
- observability | ||
# - open-source | ||
- pageinfo | ||
- pagelist | ||
# - pages | ||
- products | ||
- redirects | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
| Runner Size | Architecture| Processor (CPU)| Memory (RAM) | Storage (SSD) | Workflow label | | ||
| ------------| ------------| -------------- | ------------- | ------------- | -------------- | | ||
| Large | Intel | 12 | 30 GB | 14 GB | <code>macos-latest-large</code>, <code>macos-12-large</code>, <code>macos-13-large</code> [latest], <code>macos-14-large</code>[Beta] | | ||
| XLarge | arm64 (M1) | 6 (+ 8 GPU hardware acceleration) | 14 GB | 14 GB | <code>macos-latest-xlarge</code>, <code>macos-13-xlarge</code> [latest], <code>macos-14-xlarge</code>[Beta] | | ||
| Large | Intel | 12 | 30 GB | 14 GB | <code>macos-latest-large</code>, <code>macos-12-large</code>, <code>macos-13-large</code> , <code>macos-14-large</code> [latest] | | ||
| XLarge | arm64 (M1) | 6 (+ 8 GPU hardware acceleration) | 14 GB | 14 GB | <code>macos-latest-xlarge</code>, <code>macos-13-xlarge</code>, <code>macos-14-xlarge</code> [latest] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
The short code must be unique to your enterprise, a three-to-eight character alphanumeric string, and contain no special characters. | ||
|
||
> [!WARNING] The short code will be appended to the end of all usernames in your enterprise account. It is not possible to modify the short code after your {% data variables.enterprise.prodname_emu_enterprise %} has been created. Please make sure to select an appropriate short code when requesting your new enterprise account. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Pagelist | ||
|
||
This subject folder contains the code for the `/api/pagelist` endpoint. | ||
|
||
## What it does | ||
|
||
The `/api/pagelist` endpoint provides a flat structure of all the pages on GitHub Docs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import express from 'express' | ||
import type { Response } from 'express' | ||
|
||
import type { ExtendedRequest } from '@/types' | ||
import { defaultCacheControl } from '@/frame/middleware/cache-control.js' | ||
import { getProductStringFromPath, getVersionStringFromPath } from '#src/frame/lib/path-utils.js' | ||
import { latest } from '#src/versions/lib/enterprise-server-releases.js' | ||
|
||
const router = express.Router() | ||
|
||
router.get('/v1/enterprise-server@latest', (req, res) => { | ||
res.redirect( | ||
307, | ||
req.originalUrl.replace( | ||
'/pagelist/v1/enterprise-server@latest', | ||
`/pagelist/v1/enterprise-server@${latest}`, | ||
), | ||
) | ||
}) | ||
|
||
router.get('/v1/:product@:version', (req: ExtendedRequest, res: Response) => { | ||
const { product, version } = req.params | ||
|
||
if (!req.context || !req.context.pages) throw new Error('Request not contextualized.') | ||
|
||
const pages = req.context.pages | ||
|
||
// the keys of `context.pages` are permalinks | ||
const keys = Object.keys(pages) | ||
|
||
// we filter the permalinks to get only our target version | ||
const filteredPermalinks = keys.filter((key) => versionMatcher(key, `${product}@${version}`)) | ||
|
||
if (!filteredPermalinks.length) { | ||
res.status(400).type('text').send('Invalid version') | ||
return | ||
} | ||
|
||
defaultCacheControl(res) | ||
|
||
// new line added at the end so `wc` works as expected with `-l` and `-w`. | ||
res.type('text').send(filteredPermalinks.join('\n').concat('\n')) | ||
}) | ||
|
||
router.get('/:product@:version', (req, res) => { | ||
res.redirect(307, req.originalUrl.replace('/pagelist', '/pagelist/v1')) | ||
}) | ||
|
||
// If no version is provided we'll assume API v1 and Docs version FPT | ||
router.get('/', (req, res) => { | ||
res.redirect(307, req.originalUrl.replace('/pagelist', '/pagelist/v1/free-pro-team@latest')) | ||
}) | ||
|
||
function versionMatcher(key: string, targetVersion: string) { | ||
const versionFromPath = getVersionStringFromPath(key) | ||
|
||
if (!versionFromPath) { | ||
throw new Error(`Couldn't get version from the permalink ${key} when generating the pagelist.`) | ||
} | ||
if (getProductStringFromPath(key) === 'early-access') return null | ||
if (versionFromPath === targetVersion) return key | ||
} | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { beforeAll, describe, expect, test } from 'vitest' | ||
|
||
import { get } from '#src/tests/helpers/e2etest.js' | ||
|
||
import { allVersionKeys } from '#src/versions/lib/all-versions.js' | ||
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js' | ||
import { latest } from '#src/versions/lib/enterprise-server-releases.js' | ||
|
||
test('redirects without version suffix', async () => { | ||
const res = await get(`/api/pagelist`) | ||
expect(res.statusCode).toBe(307) | ||
expect(res.headers.location).toBe(`/api/pagelist/v1/${nonEnterpriseDefaultVersion}`) | ||
}) | ||
|
||
test('redirects for ghes@latest', async () => { | ||
const res = await get(`/api/pagelist/v1/enterprise-server@latest`) | ||
expect(res.statusCode).toBe(307) | ||
expect(res.headers.location).toBe(`/api/pagelist/v1/enterprise-server@${latest}`) | ||
}) | ||
|
||
describe.each(allVersionKeys)('pagelist api for %s', async (versionKey) => { | ||
beforeAll(() => { | ||
// If you didn't set the `ROOT` variable, the tests will fail rather | ||
// cryptically. So as a warning for engineers running these tests, | ||
// alert in case it was accidentally forgotten. | ||
if (!process.env.ROOT) { | ||
console.warn( | ||
'WARNING: The pagelist tests require the ROOT environment variable to be set to the fixture root', | ||
) | ||
} | ||
// Ditto for fixture-based translations to work | ||
if (!process.env.TRANSLATIONS_FIXTURE_ROOT) { | ||
console.warn( | ||
'WARNING: The pagelist tests require the TRANSLATIONS_FIXTURE_ROOT environment variable to be set', | ||
) | ||
} | ||
}) | ||
|
||
// queries the pagelist API for each version | ||
const res = await get(`/api/pagelist/v1/${versionKey}`) | ||
|
||
test('is reachable, returns 200 OK', async () => { | ||
expect(res.statusCode).toBe(200) | ||
}) | ||
|
||
// there's a large assortment of possible URLs, | ||
// even "/en" is an acceptable URL, so regexes capture lots | ||
test('contains valid urls', async () => { | ||
let expression | ||
|
||
// if we're testing the default version, it may be missing | ||
// from the url altogether so we need a slightly different regex | ||
if (versionKey === nonEnterpriseDefaultVersion) | ||
expression = new RegExp(`/\\w{2}(/${versionKey})?/?.*`) | ||
else expression = new RegExp(`/\\w{2}/${versionKey}/?.*`) | ||
|
||
res.body | ||
.trim() | ||
.split('\n') | ||
.forEach((permalink: string) => { | ||
expect(permalink).toMatch(expression) | ||
}) | ||
}) | ||
}) |