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

Commit a611b9b

Browse files
committed
Add support for batch-size when uploading code coverage
1 parent 8a7376a commit a611b9b

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

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` | `500` | Batch size for source files used by upload-coverage command. |
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 to be sent to Code Climate in upload coverage step'
39+
default: '500'
3640
runs:
3741
using: 'node20'
3842
main: 'lib/main.mjs'

src/main.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface ActionArguments {
3939
/** Verifies if the current OS and CPU architecture is supported by CodeClimate test reporter. */
4040
verifyEnvironment?: string;
4141
/** Batch size for source files used by upload-coverage command (default 500) */
42-
batchSize?: number;
42+
batchSize?: string;
4343
}
4444

4545
const CURRENT_ENVIRONMENT = getSupportedEnvironmentInfo();
@@ -61,7 +61,7 @@ const DEFAULT_CODECLIMATE_DEBUG = 'false';
6161
const DEFAULT_COVERAGE_LOCATIONS = '';
6262
const DEFAULT_VERIFY_DOWNLOAD = 'true';
6363
const DEFAULT_VERIFY_ENVIRONMENT = 'true';
64-
const DEFAULT_BATCH_SIZE = 500;
64+
const DEFAULT_BATCH_SIZE = '500';
6565

6666
const SUPPORTED_GITHUB_EVENTS = [
6767
// Regular PRs.
@@ -209,10 +209,10 @@ export async function run({
209209
workingDirectory = DEFAULT_WORKING_DIRECTORY,
210210
codeClimateDebug = DEFAULT_CODECLIMATE_DEBUG,
211211
coverageLocationsParam = DEFAULT_COVERAGE_LOCATIONS,
212-
batchSize = DEFAULT_BATCH_SIZE,
213212
coveragePrefix,
214213
verifyDownload = DEFAULT_VERIFY_DOWNLOAD,
215214
verifyEnvironment = DEFAULT_VERIFY_ENVIRONMENT,
215+
batchSize = DEFAULT_BATCH_SIZE,
216216
}: ActionArguments = {}): Promise<void> {
217217
let lastExitCode = 1;
218218
if (verifyEnvironment === 'true') {
@@ -373,7 +373,7 @@ export async function run({
373373
const uploadCommands = ['upload-coverage', '-i', 'coverage.total.json'];
374374
if (codeClimateDebug === 'true') uploadCommands.push('--debug');
375375
if (batchSize) {
376-
uploadCommands.push('--batch-size', batchSize.toString());
376+
uploadCommands.push('--batch-size', batchSize);
377377
}
378378
try {
379379
lastExitCode = await exec(executable, uploadCommands, execOpts);
@@ -439,6 +439,10 @@ if (isThisFileBeingRunViaCLI) {
439439
'verifyEnvironment',
440440
DEFAULT_VERIFY_ENVIRONMENT,
441441
);
442+
const batchSize = getOptionalString(
443+
'batchSize',
444+
DEFAULT_BATCH_SIZE,
445+
);
442446

443447
try {
444448
run({
@@ -451,6 +455,7 @@ if (isThisFileBeingRunViaCLI) {
451455
coveragePrefix,
452456
verifyDownload,
453457
verifyEnvironment,
458+
batchSize,
454459
});
455460
} finally {
456461
// Finally clean up all artifacts that we downloaded.

test/main.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +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,
186+
batchSize: '200',
187187
});
188188
stdHook.unhook();
189189
} catch (err) {

0 commit comments

Comments
 (0)