mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
The docs E2E suite covered guides and troubleshooting pages only, and did not run at all on pull requests that just change the OpenAPI specs or the reference rendering code — including the weekly automated spec update. Add reference-pages.spec.ts, which loads all 14 reference sections and asserts each returns 200 and renders an article with a heading. It uses a fixed page list rather than the changed-files scope, so scope resolution now keeps Playwright running for reference-relevant paths even when no guide pages resolve.
83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Resolve docs E2E page scope from changed files.
|
|
*
|
|
* Usage:
|
|
* git diff --name-only origin/master...HEAD | node --experimental-strip-types scripts/resolve-docs-scope.ts
|
|
* node --experimental-strip-types scripts/resolve-docs-scope.ts --files a.mdx,b.mdx
|
|
*
|
|
* Outputs (GitHub Actions friendly):
|
|
* skip=true|false
|
|
* paths=<comma-separated /docs/... paths>
|
|
* Also prints each path on its own line to stderr for debugging.
|
|
*/
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { parseChangedFilesList, resolveDocsScope } from '../utils/resolve-docs-scope.ts'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const REPO_ROOT = join(__dirname, '../../..')
|
|
|
|
function readChangedFilesFromArgv(argv: string[]): string[] | null {
|
|
const filesIdx = argv.indexOf('--files')
|
|
if (filesIdx !== -1 && argv[filesIdx + 1]) {
|
|
return parseChangedFilesList(argv[filesIdx + 1])
|
|
}
|
|
return null
|
|
}
|
|
|
|
async function readStdin(): Promise<string> {
|
|
const chunks: Buffer[] = []
|
|
for await (const chunk of process.stdin) {
|
|
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)
|
|
}
|
|
return Buffer.concat(chunks).toString('utf8')
|
|
}
|
|
|
|
async function main() {
|
|
const argv = process.argv.slice(2)
|
|
let changedFiles = readChangedFilesFromArgv(argv)
|
|
|
|
if (!changedFiles) {
|
|
if (process.stdin.isTTY) {
|
|
console.error('Pass changed files via stdin or --files path1,path2')
|
|
process.exit(2)
|
|
}
|
|
changedFiles = parseChangedFilesList(await readStdin())
|
|
}
|
|
|
|
const result = await resolveDocsScope({
|
|
changedFiles,
|
|
repoRoot: REPO_ROOT,
|
|
})
|
|
|
|
// GitHub Actions step outputs
|
|
const githubOutput = process.env.GITHUB_OUTPUT
|
|
const skipLine = `skip=${result.skip}`
|
|
const pathsLine = `paths=${result.pages.join(',')}`
|
|
|
|
if (githubOutput) {
|
|
// appendFile via sync to keep the CLI dependency-free
|
|
const { appendFileSync } = await import('node:fs')
|
|
appendFileSync(githubOutput, `${skipLine}\n${pathsLine}\n`)
|
|
} else {
|
|
console.log(skipLine)
|
|
console.log(pathsLine)
|
|
}
|
|
|
|
if (result.pages.length > 0) {
|
|
console.error(`Resolved ${result.pages.length} docs page(s):`)
|
|
for (const page of result.pages) {
|
|
console.error(` ${page}`)
|
|
}
|
|
} else if (result.skip) {
|
|
console.error('No in-scope docs pages — skipping Playwright suite.')
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error(error instanceof Error ? error.message : error)
|
|
process.exit(1)
|
|
})
|