Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit 5c8aa39

Browse files
authored
feat(core): Introduce batch-size flag
2 parents 8a09d38 + d84270d commit 5c8aa39

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

INTERNAL-NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
## How to check for release version
44

55
```
6-
pnpm dlx release-please release-pr --token="<insert-github-token>" --repo-url=paambaati/codeclimate-action --trace --dry-run
6+
pnpm dlx release-please release-pr --token="<insert-github-token>" --repo-url=paambaati/codeclimate-action --config-file=".release-please-config.json" --trace --dry-run
77
```

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec
1212

1313
### Inputs
1414

15-
| Input | Default | Description |
16-
| ------------------- | --------------- | ---------------------------------------------------------------------------------- |
17-
| `coverageCommand` | | The actual command that should be executed to run your tests and capture coverage. |
18-
| `workingDirectory` | | Specify a custom working directory where the coverage command should be executed. |
19-
| `debug` | `false` | Enable Code Coverage debug output when set to `true`. |
20-
| `coverageLocations` | | Locations to find code coverage as a multiline string.<br>Each line should be of the form `<location>:<type>`.<br>`type` can be any one of `clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov`. See examples below. |
21-
| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) |
22-
| `verifyDownload` | `true` | Verifies the downloaded Code Climate reporter binary's checksum and GPG signature. See [Verifying binaries](https://github.com/codeclimate/test-reporter#verifying-binaries) |
23-
| `verifyEnvironment` | `true` | Verifies the current runtime environment (operating system and CPU architecture) is supported by the Code Climate reporter. See [list of supported platforms](https://github.com/codeclimate/test-reporter#binaries) |
15+
| Input | Default | Description |
16+
|---------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
17+
| `coverageCommand` | | The actual command that should be executed to run your tests and capture coverage. |
18+
| `workingDirectory` | | Specify a custom working directory where the coverage command should be executed. |
19+
| `debug` | `false` | Enable Code Coverage debug output when set to `true`. |
20+
| `coverageLocations` | | Locations to find code coverage as a multiline string.<br>Each line should be of the form `<location>:<type>`.<br>`type` can be any one of `clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov`. See examples below. |
21+
| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) |
22+
| `verifyDownload` | `true` | Verifies the downloaded Code Climate reporter binary's checksum and GPG signature. See [Verifying binaries](https://github.com/codeclimate/test-reporter#verifying-binaries) |
23+
| `verifyEnvironment` | `true` | Verifies the current runtime environment (operating system and CPU architecture) is supported by the Code Climate reporter. See [list of supported platforms](https://github.com/codeclimate/test-reporter#binaries) |
24+
| `batchSize` | | Batch size for source files (cc-test-reporter upload-coverage uses 500 by default) |
2425

2526
> **Note**
2627
> If you are a Ruby developer using [SimpleCov](https://github.com/simplecov-ruby/simplecov), other users have recommended installing an additional gem – `gem "simplecov_json_formatter"` – this gem fixes `json` error from the default `coverage/.resultset.json` output from SimpleCov.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ inputs:
3333
required: false
3434
description: 'Verify that the Action environment (OS and CPU architecture) is supported by Code Climate test reporter'
3535
default: 'true'
36+
batchSize:
37+
required: false
38+
description: 'Batch size for source files (cc-test-reporter upload-coverage uses 500 by default)'
39+
default: ''
3640
runs:
3741
using: 'node20'
3842
main: 'lib/main.mjs'

src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface ActionArguments {
3838
verifyDownload?: string;
3939
/** Verifies if the current OS and CPU architecture is supported by CodeClimate test reporter. */
4040
verifyEnvironment?: string;
41+
/** Batch size for source files used by upload-coverage command (default 500) */
42+
batchSize?: string;
4143
}
4244

4345
const CURRENT_ENVIRONMENT = getSupportedEnvironmentInfo();
@@ -209,6 +211,7 @@ export async function run({
209211
coveragePrefix,
210212
verifyDownload = DEFAULT_VERIFY_DOWNLOAD,
211213
verifyEnvironment = DEFAULT_VERIFY_ENVIRONMENT,
214+
batchSize,
212215
}: ActionArguments = {}): Promise<void> {
213216
let lastExitCode = 1;
214217
if (verifyEnvironment === 'true') {
@@ -368,6 +371,9 @@ export async function run({
368371
// Upload to Code Climate.
369372
const uploadCommands = ['upload-coverage', '-i', 'coverage.total.json'];
370373
if (codeClimateDebug === 'true') uploadCommands.push('--debug');
374+
if (batchSize) {
375+
uploadCommands.push('--batch-size', batchSize);
376+
}
371377
try {
372378
lastExitCode = await exec(executable, uploadCommands, execOpts);
373379
if (lastExitCode !== 0) {
@@ -432,6 +438,7 @@ if (isThisFileBeingRunViaCLI) {
432438
'verifyEnvironment',
433439
DEFAULT_VERIFY_ENVIRONMENT,
434440
);
441+
const batchSize = getOptionalString('batchSize');
435442

436443
try {
437444
run({
@@ -444,6 +451,7 @@ if (isThisFileBeingRunViaCLI) {
444451
coveragePrefix,
445452
verifyDownload,
446453
verifyEnvironment,
454+
batchSize,
447455
});
448456
} finally {
449457
// Finally clean up all artifacts that we downloaded.

test/main.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ t.test('🧪 run() should run the CC reporter (happy path).', async (t) => {
183183
coverageCommand: `${ECHO_CMD} 'coverage ok'`,
184184
verifyDownload: 'false',
185185
verifyEnvironment: 'false',
186+
batchSize: '200',
186187
});
187188
stdHook.unhook();
188189
} catch (err) {

0 commit comments

Comments
 (0)