Skip to content

Commit f20eca9

Browse files
authored
add some article api test debugging (#59072)
1 parent bc72f1f commit f20eca9

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,7 @@ jobs:
163163
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
164164
ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api' || matrix.name == 'landings' ) && 'src/fixtures/fixtures' || '' }}
165165
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api') && 'src/fixtures/fixtures/translations' || '' }}
166+
# Enable debug logging when "Re-run jobs with debug logging" is used in GitHub Actions UI
167+
# This will output additional timing and path information to help diagnose timeout issues
168+
RUNNER_DEBUG: ${{ runner.debug }}
166169
run: npm test -- src/${{ matrix.name }}/tests/

src/article-api/tests/github-apps-transformer.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ describe('GitHub Apps transformer', () => {
7070
})
7171

7272
test('endpoints are formatted as bullet lists', async () => {
73-
const res = await get(
74-
makeURL(
75-
'/en/rest/authentication/endpoints-available-for-github-app-installation-access-tokens',
76-
),
73+
const DEBUG = process.env.RUNNER_DEBUG === '1' || process.env.DEBUG === '1'
74+
const url = makeURL(
75+
'/en/rest/authentication/endpoints-available-for-github-app-installation-access-tokens',
7776
)
77+
const startTime = DEBUG ? Date.now() : 0
78+
if (DEBUG) console.log(`[DEBUG] Test sending request to ${url}`)
79+
const res = await get(url)
80+
if (DEBUG)
81+
console.log(`[DEBUG] Test response: ${res.statusCode} in ${Date.now() - startTime}ms`)
7882
expect(res.statusCode).toBe(200)
7983

8084
// Check for bullet list items with asterisks (per content guidelines)

src/article-api/tests/rest-transformer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ describe('REST transformer', () => {
8181
})
8282

8383
test('Status codes are formatted correctly', async () => {
84-
const res = await get(makeURL('/en/rest/actions/artifacts'))
84+
const DEBUG = process.env.RUNNER_DEBUG === '1' || process.env.DEBUG === '1'
85+
const url = makeURL('/en/rest/actions/artifacts')
86+
const startTime = DEBUG ? Date.now() : 0
87+
if (DEBUG) console.log(`[DEBUG] Test sending request to ${url}`)
88+
const res = await get(url)
89+
if (DEBUG)
90+
console.log(`[DEBUG] Test response: ${res.statusCode} in ${Date.now() - startTime}ms`)
8591
expect(res.statusCode).toBe(200)
8692

8793
// Check for status codes section

src/article-api/transformers/github-apps-transformer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fileURLToPath } from 'url'
88

99
const __filename = fileURLToPath(import.meta.url)
1010
const __dirname = dirname(__filename)
11+
const DEBUG = process.env.RUNNER_DEBUG === '1' || process.env.DEBUG === '1'
1112

1213
// GitHub Apps data types
1314
interface GitHubAppsOperation {
@@ -100,6 +101,9 @@ export class GithubAppsTransformer implements PageTransformer {
100101
context: Context,
101102
apiVersion?: string,
102103
): Promise<string> {
104+
const startTime = DEBUG ? Date.now() : 0
105+
if (DEBUG) console.log(`[DEBUG] GitHubAppsTransformer: ${pathname}`)
106+
103107
// Import getAppsData dynamically to avoid circular dependencies
104108
const { getAppsData } = await import('@/github-apps/lib/index')
105109

@@ -216,6 +220,10 @@ export class GithubAppsTransformer implements PageTransformer {
216220
})
217221
}
218222

223+
if (DEBUG)
224+
console.log(
225+
`[DEBUG] GitHubAppsTransformer.transform completed in ${Date.now() - startTime}ms`,
226+
)
219227
return finalContent
220228
}
221229

src/article-api/transformers/rest-transformer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { fastTextOnly } from '@/content-render/unified/text-only'
1010

1111
const __filename = fileURLToPath(import.meta.url)
1212
const __dirname = dirname(__filename)
13+
const DEBUG = process.env.RUNNER_DEBUG === '1' || process.env.DEBUG === '1'
1314

1415
/**
1516
* Transformer for REST API pages
@@ -28,6 +29,9 @@ export class RestTransformer implements PageTransformer {
2829
context: Context,
2930
apiVersion?: string,
3031
): Promise<string> {
32+
const startTime = DEBUG ? Date.now() : 0
33+
if (DEBUG) console.log(`[DEBUG] RestTransformer: ${pathname}`)
34+
3135
// Import getRest dynamically to avoid circular dependencies
3236
const { default: getRest } = await import('@/rest/lib/index')
3337

@@ -110,6 +114,7 @@ export class RestTransformer implements PageTransformer {
110114
markdownRequested: true,
111115
})
112116

117+
if (DEBUG) console.log(`[DEBUG] RestTransformer completed in ${Date.now() - startTime}ms`)
113118
return rendered
114119
}
115120

src/github-apps/lib/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface AppsConfig {
1212
// Note: Using 'any' for AppsData to maintain compatibility with existing consumers that expect different shapes
1313
type AppsData = any
1414

15+
const DEBUG = process.env.RUNNER_DEBUG === '1' || process.env.DEBUG === '1'
1516
const ENABLED_APPS_DIR = 'src/github-apps/data'
1617
const githubAppsData = new Map<string, Map<string, AppsData>>()
1718

@@ -29,6 +30,12 @@ export async function getAppsData(
2930
docsVersion: string,
3031
apiVersion?: string,
3132
): Promise<AppsData> {
33+
if (DEBUG) {
34+
console.log(
35+
`[DEBUG] getAppsData: ROOT=${process.env.ROOT || '(not set)'}, path=${ENABLED_APPS_DIR}`,
36+
)
37+
}
38+
3239
const pageTypeMap = githubAppsData.get(pageType)!
3340
const filename = `${pageType}.json`
3441
const openApiVersion = getOpenApiVersion(docsVersion) + (apiVersion ? `-${apiVersion}` : '')

0 commit comments

Comments
 (0)