* Fetch the full recursive tree from GitHub's Git Trees API. * Returns only blob entries (files, not directories).
( owner: string, repo: string, ref: string, )
| 53 | * Returns only blob entries (files, not directories). |
| 54 | */ |
| 55 | async function fetchGitHubTree( |
| 56 | owner: string, |
| 57 | repo: string, |
| 58 | ref: string, |
| 59 | ): Promise<{ files: GitHubTreeEntry[]; sha: string }> { |
| 60 | const url = `https://api.github.com/repos/${owner}/${repo}/git/trees/${ref}?recursive=1`; |
| 61 | const headers: Record<string, string> = { |
| 62 | Accept: 'application/vnd.github+json', |
| 63 | 'User-Agent': 'opentrace-pipeline-test', |
| 64 | }; |
| 65 | // Use GITHUB_TOKEN if available (avoids rate limits in CI) |
| 66 | if (process.env.GITHUB_TOKEN) { |
| 67 | headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`; |
| 68 | } |
| 69 | |
| 70 | const res = await fetch(url, { headers }); |
| 71 | if (!res.ok) { |
| 72 | throw new Error(`GitHub API ${res.status}: ${await res.text()}`); |
| 73 | } |
| 74 | |
| 75 | const data: GitHubTreeResponse = await res.json(); |
| 76 | const files = data.tree.filter((e) => e.type === 'blob'); |
| 77 | return { files, sha: data.sha }; |
| 78 | } |
| 79 | |
| 80 | describe.skipIf(SKIP)('github: grafana/grafana', () => { |
| 81 | let repoTree: RepoTree; |