## Summary - **Fix CI build failure**: Auth0Client crashes during Next.js prerendering when env vars aren't set. Returns a no-op stub (`getSession → null`) when domain is missing — semantically correct for static generation - **Lazy-load markdown libs (~260kb)**: ReactMarkdown, remarkGfm, and react-syntax-highlighter were eagerly imported in monaco-diff-viewer but only rendered when user expands "Generated Tests". Extracted into a dynamic component - **Parallelize repo detail query**: `getRepositoryById` ran the activity count sequentially after the repo lookup. Since `repoId` is already available, all three queries now run in parallel ## Test plan - [ ] CI `build` check passes (was failing since #2598) - [ ] Trace page still renders generated tests correctly when expanded - [ ] Repository detail page loads correctly with activity status
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import fs from "node:fs"
|
|
import { AnyOctokit } from "./types.js"
|
|
|
|
const APP_ID: string = process.env.APP_ID || "" // Replace with your GitHub App ID
|
|
|
|
const PRIVATE_KEY: string = fs.readFileSync("codeflash-app.2023-11-04.private-key.pem", "utf8")
|
|
const CLIENT_ID: string = process.env.CLIENT_ID || "" // Replace with your GitHub App client ID
|
|
const CLIENT_SECRET: string = process.env.CLIENT_SECRET || "" // Replace with your GitHub App client secret
|
|
|
|
if (!APP_ID || !PRIVATE_KEY || !CLIENT_ID || !CLIENT_SECRET) {
|
|
throw new Error("Environment variables are not set")
|
|
}
|
|
|
|
export async function createWorkflow(repoOwner: string, repoName: string) {
|
|
const content = Buffer.from(
|
|
`
|
|
name: Code Optimization
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
optimize:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: Codeflash/optimize-action@main
|
|
with:
|
|
token:
|
|
`,
|
|
).toString("base64")
|
|
|
|
let installationOctokit: AnyOctokit
|
|
await installationOctokit.rest.repos.createOrUpdateFileContents({
|
|
owner: repoOwner,
|
|
repo: repoName,
|
|
path: ".github/workflows/optimize.yml",
|
|
message: "Setup Code Optimization action",
|
|
content,
|
|
})
|
|
}
|
|
|
|
// Example usage
|
|
createWorkflow("user-or-org", "repo-name") // Replace with actual owner, repo name, and installation ID
|