You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/ci/README.md
+46-26Lines changed: 46 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,7 @@ Optionally, you can override default options for further customization:
109
109
|`logger`|`Logger`|`console`| Logger for reporting progress and encountered problems |
110
110
|`skipComment`|`boolean`|`false`| Toggles if comparison comment is posted to PR |
111
111
|`configPatterns`|`ConfigPatterns \| null`|`null`| Additional configuration which enables [faster CI runs](#faster-ci-runs-with-configpatterns)|
112
+
|`searchCommits`|`boolean \| number`|`false`| If base branch has no cached report in portal, [extends search up to 100 recent commits](#search-latest-commits-for-previous-report)|
112
113
113
114
[^1]: By default, the `code-pushup.config` file is autodetected as described in [`@code-pushup/cli` docs](../cli/README.md#configuration).
114
115
@@ -217,32 +218,6 @@ await runInCI(refs, api, {
217
218
});
218
219
```
219
220
220
-
### Faster CI runs with `configPatterns`
221
-
222
-
By default, the `print-config` command is run sequentially for each project in order to reliably detect how `code-pushup` is configured - specifically, where to read output files from (`persist` config) and whether portal may be used as a cache (`upload` config). This allows for each project to be configured in its own way without breaking anything, but for large monorepos these extra `code-pushup print-config` executions can accumulate and significantly slow down CI pipelines.
223
-
224
-
As a more scalable alternative, `configPatterns` may be provided. A user declares upfront how every project is configured, which allows `print-config` to be skipped. It's the user's responsibility to ensure this configuration holds for every project (it won't be checked). The `configPatterns` support string interpolation, substituting `{projectName}` with each project's name. Other than that, each project's `code-pushup.config` must have exactly the same `persist` and `upload` configurations.
225
-
226
-
```ts
227
-
awaitrunInCI(refs, api, {
228
-
monorepo: true,
229
-
configPatterns: {
230
-
persist: {
231
-
outputDir: '.code-pushup/{projectName}',
232
-
filename: 'report',
233
-
format: ['json', 'md'],
234
-
},
235
-
// optional: will use portal as cache when comparing reports in PRs
In monorepo mode, the resolved object includes the merged diff at the top-level, as well as a list of projects.
@@ -273,3 +248,48 @@ if (result.mode === 'monorepo') {
273
248
}
274
249
}
275
250
```
251
+
252
+
## Advanced usage
253
+
254
+
### Faster CI runs with `configPatterns`
255
+
256
+
By default, the `print-config` command is run sequentially for each project in order to reliably detect how `code-pushup` is configured - specifically, where to read output files from (`persist` config) and whether portal may be used as a cache (`upload` config). This allows for each project to be configured in its own way without breaking anything, but for large monorepos these extra `code-pushup print-config` executions can accumulate and significantly slow down CI pipelines.
257
+
258
+
As a more scalable alternative, `configPatterns` may be provided. A user declares upfront how every project is configured, which allows `print-config` to be skipped. It's the user's responsibility to ensure this configuration holds for every project (it won't be checked). The `configPatterns` support string interpolation, substituting `{projectName}` with each project's name. Other than that, each project's `code-pushup.config` must have exactly the same `persist` and `upload` configurations.
259
+
260
+
```ts
261
+
awaitrunInCI(refs, api, {
262
+
monorepo: true,
263
+
configPatterns: {
264
+
persist: {
265
+
outputDir: '.code-pushup/{projectName}',
266
+
filename: 'report',
267
+
format: ['json', 'md'],
268
+
},
269
+
// optional: will use portal as cache when comparing reports in PRs
When comparing reports, the report for the base branch can be cached. If a project has an `upload` configuration, then the Portal API is queried for a report matching that commit. If no such report was uploaded, then the report is looked up in CI artifacts (implemented in `downloadReportArtifact` in [`ProviderApiClient`](#provider-api-client)). If there's no report to be found, then the base branch is checked and the previous report is collected.
283
+
284
+
In some scenarios, there may not be a report for the latest commit in main branch, but some other recent commit may have a usable report - e.g. if `nxProjectsFilter` is used with `--affected` flag. In that case, the `searchCommits` option can be enabled. Then a limited number of recent commits in the main branch will be checked, but.
`The searchCommits option must be a boolean or an integer in range ${MIN_SEARCH_COMMITS} to ${MAX_SEARCH_COMMITS}, ignoring invalid value ${searchCommits}.`,
136
+
);
137
+
returnundefined;
138
+
}
139
+
140
+
returnsearchCommits;
141
+
}
142
+
110
143
exportasyncfunctionrunOnProject(
111
144
project: ProjectConfig|null,
112
145
env: RunEnv,
@@ -382,8 +415,13 @@ async function loadCachedBaseReportFromPortal(
0 commit comments