( project: ProjectConfig | null, env: RunEnv, )
| 133 | } |
| 134 | |
| 135 | export async function runOnProject( |
| 136 | project: ProjectConfig | null, |
| 137 | env: RunEnv, |
| 138 | ): Promise<ProjectRunResult> { |
| 139 | const { |
| 140 | refs: { head, base }, |
| 141 | settings, |
| 142 | } = env; |
| 143 | |
| 144 | const ctx = createCommandContext(settings, project); |
| 145 | |
| 146 | if (project) { |
| 147 | logInfo(`Running Code PushUp on monorepo project ${project.name}`); |
| 148 | } |
| 149 | |
| 150 | const config = settings.configPatterns |
| 151 | ? configFromPatterns(settings.configPatterns, project) |
| 152 | : await printPersistConfig(ctx); |
| 153 | logDebug( |
| 154 | settings.configPatterns |
| 155 | ? `Parsed persist and upload configs from configPatterns option - ${JSON.stringify(config)}` |
| 156 | : `Loaded persist and upload configs from print-config command - ${JSON.stringify(config)}`, |
| 157 | ); |
| 158 | |
| 159 | await runCollect(ctx, { hasFormats: hasDefaultPersistFormats(config) }); |
| 160 | const currReport = await saveReportFiles({ |
| 161 | project, |
| 162 | type: 'current', |
| 163 | files: persistedFilesFromConfig(config, ctx), |
| 164 | settings, |
| 165 | }); |
| 166 | logDebug(`Collected current report at ${currReport.files.json}`); |
| 167 | |
| 168 | const noDiffOutput = { |
| 169 | name: projectToName(project), |
| 170 | files: { current: currReport.files }, |
| 171 | } satisfies ProjectRunResult; |
| 172 | |
| 173 | if (base == null) { |
| 174 | return noDiffOutput; |
| 175 | } |
| 176 | |
| 177 | logInfo( |
| 178 | `PR/MR detected, preparing to compare base branch ${base.ref} to head ${head.ref}`, |
| 179 | ); |
| 180 | |
| 181 | const baseArgs: BaseReportArgs = { project, env, base, config, ctx }; |
| 182 | const prevReport = await collectPreviousReport(baseArgs); |
| 183 | if (!prevReport) { |
| 184 | return noDiffOutput; |
| 185 | } |
| 186 | |
| 187 | const compareArgs = { ...baseArgs, currReport, prevReport }; |
| 188 | return compareReports(compareArgs); |
| 189 | } |
| 190 | |
| 191 | export async function compareReports( |
| 192 | args: CompareReportsArgs, |
no test coverage detected