diff --git a/README.md b/README.md index 8d0666d6..80d8954e 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,16 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec ### Inputs -| Input | Default | Description | -| ------------------- | --------------- | ---------------------------------------------------------------------------------- | -| `coverageCommand` | | The actual command that should be executed to run your tests and capture coverage. | -| `workingDirectory` | | Specify a custom working directory where the coverage command should be executed. | -| `debug` | `false` | Enable Code Coverage debug output when set to `true`. | -| `coverageLocations` | | Locations to find code coverage as a multiline string.
Each line should be of the form `:`.
`type` can be any one of `clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov`. See examples below. | -| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) | -| `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) | -| `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) | +| Input | Default | Description | +|---------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `coverageCommand` | | The actual command that should be executed to run your tests and capture coverage. | +| `workingDirectory` | | Specify a custom working directory where the coverage command should be executed. | +| `debug` | `false` | Enable Code Coverage debug output when set to `true`. | +| `coverageLocations` | | Locations to find code coverage as a multiline string.
Each line should be of the form `:`.
`type` can be any one of `clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov`. See examples below. | +| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) | +| `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) | +| `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) | +| `batchSize` | | Batch size for source files (cc-test-reporter upload-coverage uses 500 by default) | > **Note** > 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. diff --git a/action.yml b/action.yml index 87eafae6..8a44a29f 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,10 @@ inputs: required: false description: 'Verify that the Action environment (OS and CPU architecture) is supported by Code Climate test reporter' default: 'true' + batchSize: + required: false + description: 'Batch size for source files (cc-test-reporter upload-coverage uses 500 by default)' + default: '' runs: using: 'node20' main: 'lib/main.mjs' diff --git a/src/main.ts b/src/main.ts index 4e21012f..d0f4afe5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,6 +38,8 @@ export interface ActionArguments { verifyDownload?: string; /** Verifies if the current OS and CPU architecture is supported by CodeClimate test reporter. */ verifyEnvironment?: string; + /** Batch size for source files used by upload-coverage command (default 500) */ + batchSize?: string; } const CURRENT_ENVIRONMENT = getSupportedEnvironmentInfo(); @@ -209,6 +211,7 @@ export async function run({ coveragePrefix, verifyDownload = DEFAULT_VERIFY_DOWNLOAD, verifyEnvironment = DEFAULT_VERIFY_ENVIRONMENT, + batchSize, }: ActionArguments = {}): Promise { let lastExitCode = 1; if (verifyEnvironment === 'true') { @@ -368,6 +371,9 @@ export async function run({ // Upload to Code Climate. const uploadCommands = ['upload-coverage', '-i', 'coverage.total.json']; if (codeClimateDebug === 'true') uploadCommands.push('--debug'); + if (batchSize) { + uploadCommands.push('--batch-size', batchSize); + } try { lastExitCode = await exec(executable, uploadCommands, execOpts); if (lastExitCode !== 0) { @@ -432,6 +438,7 @@ if (isThisFileBeingRunViaCLI) { 'verifyEnvironment', DEFAULT_VERIFY_ENVIRONMENT, ); + const batchSize = getOptionalString('batchSize'); try { run({ @@ -444,6 +451,7 @@ if (isThisFileBeingRunViaCLI) { coveragePrefix, verifyDownload, verifyEnvironment, + batchSize, }); } finally { // Finally clean up all artifacts that we downloaded. diff --git a/test/main.test.ts b/test/main.test.ts index c3a1974f..54e888a8 100644 --- a/test/main.test.ts +++ b/test/main.test.ts @@ -183,6 +183,7 @@ t.test('๐Ÿงช run() should run the CC reporter (happy path).', async (t) => { coverageCommand: `${ECHO_CMD} 'coverage ok'`, verifyDownload: 'false', verifyEnvironment: 'false', + batchSize: '200', }); stdHook.unhook(); } catch (err) {