Skip to content

Commit 1a452b7

Browse files
authored
Merge pull request #41060 from github/repo-sync
Repo sync
2 parents a33e29c + 8e897b2 commit 1a452b7

File tree

94 files changed

+610
-615
lines changed

Some content is hidden

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

94 files changed

+610
-615
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Validate OpenAPI Check Docker
2+
3+
# **What it does**: Tests building and running the OpenAPI check Docker container
4+
# **Why we have it**: To ensure the Dockerfile and openapi-check script work correctly
5+
# **Who does it impact**: Docs engineering.
6+
7+
on:
8+
workflow_dispatch:
9+
pull_request:
10+
paths:
11+
- 'Dockerfile.openapi_decorator'
12+
- 'src/rest/scripts/openapi-check.ts'
13+
- 'src/rest/scripts/utils/get-operations.ts'
14+
- 'src/rest/scripts/utils/operation.ts'
15+
# In case dependencies change
16+
- 'package.json'
17+
- 'package-lock.json'
18+
- 'tsconfig.json'
19+
# Self-test
20+
- '.github/workflows/validate-openapi-check.yml'
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
validate-openapi-check:
27+
runs-on: ubuntu-latest
28+
if: github.repository == 'github/docs-internal'
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
35+
36+
- name: Build Docker image
37+
run: |
38+
docker build -f Dockerfile.openapi_decorator -t openapi-decorator:test .
39+
40+
- name: Test Docker image with sample OpenAPI file
41+
run: |
42+
docker run --rm openapi-decorator:test -f "src/rest/data/fpt-2022-11-28/schema.json"
43+
44+
- name: Test Docker image with multiple OpenAPI files
45+
run: |
46+
docker run --rm openapi-decorator:test \
47+
-f "src/rest/data/fpt-2022-11-28/schema.json" \
48+
"src/rest/data/ghec-2022-11-28/schema.json"

Dockerfile.openapi_decorator

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
FROM node:18.15-alpine
2-
3-
RUN apk add --no-cache git python make g++
1+
FROM node:24-alpine
42

53
WORKDIR /openapi-check
64

@@ -10,10 +8,11 @@ USER node
108

119
COPY --chown=node:node package.json /openapi-check
1210
COPY --chown=node:node package-lock.json /openapi-check
11+
COPY --chown=node:node tsconfig.json /openapi-check
1312
ADD --chown=node:node src /openapi-check/src
1413
ADD --chown=node:node content /openapi-check/content
1514
ADD --chown=node:node data /openapi-check/data
1615

1716
RUN npm ci -D
1817

19-
ENTRYPOINT ["node", "/openapi-check/src/rest/scripts/openapi-check.ts"]
18+
ENTRYPOINT ["npx", "tsx", "/openapi-check/src/rest/scripts/openapi-check.ts"]

eslint.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ export default [
9696
camelcase: 'off', // Many gh apis use underscores, 600+ uses
9797

9898
// Disabled rules to review
99-
'github/no-then': 'off', // 30+
10099
'@typescript-eslint/ban-ts-comment': 'off', // 50+
101-
'no-shadow': 'off', // 150+
102100
'github/array-foreach': 'off', // 250+
103101
'no-console': 'off', // 800+
104102
'@typescript-eslint/no-explicit-any': 'off', // 1000+

next.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ const config: NextConfig = {
4949
}
5050
})
5151
},
52-
webpack: (config) => {
53-
config.experiments = config.experiments || {}
54-
config.experiments.topLevelAwait = true
55-
config.resolve.fallback = { fs: false, async_hooks: false }
56-
return config
52+
webpack: (webpackConfig) => {
53+
webpackConfig.experiments = webpackConfig.experiments || {}
54+
webpackConfig.experiments.topLevelAwait = true
55+
webpackConfig.resolve.fallback = { fs: false, async_hooks: false }
56+
return webpackConfig
5757
},
5858

5959
// https://nextjs.org/docs/api-reference/next.config.js/compression

src/assets/middleware/dynamic-assets.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ export default async function dynamicAssets(
143143
const buffer = await image.webp({ effort }).toBuffer()
144144
assetCacheControl(res)
145145
return res.type('image/webp').send(buffer)
146-
} catch (error) {
147-
if (error instanceof Error && (error as any).code !== 'ENOENT') {
148-
throw error
146+
} catch (catchError) {
147+
if (catchError instanceof Error && (catchError as any).code !== 'ENOENT') {
148+
throw catchError
149149
}
150150
}
151151
}

src/assets/tests/static-assets.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function getNextStaticAsset(directory: string) {
1616
return path.join(root, files[0])
1717
}
1818

19-
function mockRequest(path: string, { headers }: { headers?: Record<string, string> } = {}) {
19+
function mockRequest(requestPath: string, { headers }: { headers?: Record<string, string> } = {}) {
2020
const _headers = Object.fromEntries(
2121
Object.entries(headers || {}).map(([key, value]) => [key.toLowerCase(), value]),
2222
)
2323
return {
24-
path,
25-
url: path,
24+
path: requestPath,
25+
url: requestPath,
2626
get: (header: string) => {
2727
return _headers[header.toLowerCase()]
2828
},
@@ -74,8 +74,8 @@ const mockResponse = () => {
7474
if (typeof key === 'string') {
7575
res.headers[key.toLowerCase()] = value
7676
} else {
77-
for (const [k, value] of Object.entries(key)) {
78-
res.headers[k.toLowerCase()] = value
77+
for (const [k, v] of Object.entries(key)) {
78+
res.headers[k.toLowerCase()] = v
7979
}
8080
}
8181
}
@@ -319,9 +319,9 @@ describe('archived enterprise static assets', () => {
319319
},
320320
])(
321321
'should return $expectStatus for $name',
322-
({ name, path, referrer, expectStatus, shouldCallNext }) => {
322+
({ name, path: testPath, referrer, expectStatus, shouldCallNext }) => {
323323
test(name, async () => {
324-
const req = mockRequest(path, {
324+
const req = mockRequest(testPath, {
325325
headers: {
326326
Referrer: referrer,
327327
},
@@ -359,22 +359,25 @@ describe('archived enterprise static assets', () => {
359359
expectStatus: undefined,
360360
shouldCallNext: true,
361361
},
362-
])('should not suppress $name', ({ name, path, referrer, expectStatus, shouldCallNext }) => {
363-
test(name, async () => {
364-
const req = mockRequest(path, {
365-
headers: {
366-
Referrer: referrer,
367-
},
362+
])(
363+
'should not suppress $name',
364+
({ name, path: testPath, referrer, expectStatus, shouldCallNext }) => {
365+
test(name, async () => {
366+
const req = mockRequest(testPath, {
367+
headers: {
368+
Referrer: referrer,
369+
},
370+
})
371+
const res = mockResponse()
372+
let nexted = false
373+
const next = () => {
374+
nexted = true
375+
}
376+
setDefaultFastlySurrogateKey(req, res, () => {})
377+
await archivedEnterpriseVersionsAssets(req as any, res as any, next)
378+
expect(nexted).toBe(shouldCallNext)
379+
expect(res.statusCode).toBe(expectStatus)
368380
})
369-
const res = mockResponse()
370-
let nexted = false
371-
const next = () => {
372-
nexted = true
373-
}
374-
setDefaultFastlySurrogateKey(req, res, () => {})
375-
await archivedEnterpriseVersionsAssets(req as any, res as any, next)
376-
expect(nexted).toBe(shouldCallNext)
377-
expect(res.statusCode).toBe(expectStatus)
378-
})
379-
})
381+
},
382+
)
380383
})

src/codeql-cli/scripts/sync.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ async function setupEnvironment() {
8383

8484
// copy the raw rst files to the temp directory and convert them
8585
// to Markdownusing pandoc
86-
async function rstToMarkdown(sourceDirectory: string) {
87-
const sourceFiles = walk(sourceDirectory, {
86+
async function rstToMarkdown(rstSourceDirectory: string) {
87+
const sourceFiles = walk(rstSourceDirectory, {
8888
includeBasePath: true,
8989
globs: ['**/*.rst'],
9090
})

src/content-linter/lib/helpers/get-lintable-yml.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ export async function getLintableYml(dataFilePath: string): Promise<Record<strin
8080
// back to a file in the data directory.
8181
// The resulting key looks like:
8282
// 'data/variables/product.yml /pat_v1_caps'
83-
function addPathToKey(mdDict: Map<string, string>, dataFilePath: string): Map<string, string> {
84-
const keys = Array.from(mdDict.keys())
83+
function addPathToKey(mdDictMap: Map<string, string>, dataFilePath: string): Map<string, string> {
84+
const keys = Array.from(mdDictMap.keys())
8585
keys.forEach((key) => {
8686
const newKey = `${dataFilePath} ${key}`
87-
const value = mdDict.get(key)
87+
const value = mdDictMap.get(key)
8888
if (value !== undefined) {
89-
mdDict.delete(key)
90-
mdDict.set(newKey, value)
89+
mdDictMap.delete(key)
90+
mdDictMap.set(newKey, value)
9191
}
9292
})
93-
return mdDict
93+
return mdDictMap
9494
}

src/content-linter/lib/linting-rules/frontmatter-hero-image.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const frontmatterHeroImage: Rule = {
4545

4646
// Check if heroImage is an absolute path
4747
if (!heroImage.startsWith('/')) {
48-
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
48+
const line = params.lines.find((ln: string) => ln.trim().startsWith('heroImage:'))
4949
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
5050
addError(
5151
onError,
@@ -59,7 +59,7 @@ export const frontmatterHeroImage: Rule = {
5959

6060
// Check if heroImage points to banner-images directory
6161
if (!heroImage.startsWith('/assets/images/banner-images/')) {
62-
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
62+
const line = params.lines.find((ln: string) => ln.trim().startsWith('heroImage:'))
6363
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
6464
addError(
6565
onError,
@@ -74,7 +74,7 @@ export const frontmatterHeroImage: Rule = {
7474
// Check if the file actually exists
7575
const validHeroImages = getValidHeroImages()
7676
if (validHeroImages.length > 0 && !validHeroImages.includes(heroImage)) {
77-
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
77+
const line = params.lines.find((ln: string) => ln.trim().startsWith('heroImage:'))
7878
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
7979
const availableImages = validHeroImages.join(', ')
8080
addError(

src/content-linter/lib/linting-rules/frontmatter-intro-links.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export const frontmatterIntroLinks: Rule = {
4848
for (const key of Object.keys(introLinks)) {
4949
if (!validKeys.includes(key)) {
5050
// Find the line with this key
51-
const line = params.lines.find((line: string) => {
52-
const trimmed = line.trim()
51+
const line = params.lines.find((ln: string) => {
52+
const trimmed = ln.trim()
5353
return trimmed.startsWith(`${key}:`) && !trimmed.startsWith('introLinks:')
5454
})
5555
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1

0 commit comments

Comments
 (0)