Skip to content

Commit

Permalink
Allow parallel builds to be disabled
Browse files Browse the repository at this point in the history
Fixes #2994.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
  • Loading branch information
il3ven and novemberborn committed Apr 10, 2022
1 parent 388ea53 commit c299fdb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/06-configuration.md
Expand Up @@ -59,6 +59,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con
- `timeout`: Timeouts in AVA behave differently than in other test frameworks. AVA resets a timer after each test, forcing tests to quit if no new test results were received within the specified timeout. This can be used to handle stalled tests. See our [timeout documentation](./07-test-timeouts.md) for more options.
- `nodeArguments`: Configure Node.js arguments used to launch worker processes.
- `sortTestFiles`: A comparator function to sort test files with. Available only when using a `ava.config.*` file. See an example use case [here](recipes/splitting-tests-ci.md).
- `utilizeParallelBuilds`: If `false`, disable [parallel builds](/docs/recipes/splitting-tests-ci.md) (default: true)

Note that providing files on the CLI overrides the `files` option.

Expand Down
4 changes: 3 additions & 1 deletion docs/recipes/splitting-tests-ci.md
Expand Up @@ -2,6 +2,8 @@

AVA automatically detects whether your CI environment supports parallel builds using [ci-parallel-vars](https://www.npmjs.com/package/ci-parallel-vars). When parallel builds support is detected, AVA sorts the all detected test files by name, and splits them into chunks. Each CI machine is assigned a chunk (subset) of the tests, and then each chunk is run in parallel.

To disable this feature, set `utilizeParallelBuilds` to `false` in your [AVA configuration](/docs/06-configuration.md#options).

To better distribute the tests across the machines, you can configure a custom comparator function:

**`ava.config.js`:**
Expand Down Expand Up @@ -43,7 +45,7 @@ jobs:
steps:
# Check out code and perform setup steps
# ...

- name: Test
run: npx ava
env:
Expand Down
2 changes: 1 addition & 1 deletion lib/cli.js
Expand Up @@ -393,7 +393,7 @@ export default async function loadCli() { // eslint-disable-line complexity
}

let parallelRuns = null;
if (isCi && ciParallelVars) {
if (isCi && ciParallelVars && combined.utilizeParallelBuilds !== false) {
const {index: currentIndex, total: totalRuns} = ciParallelVars;
parallelRuns = {currentIndex, totalRuns};
}
Expand Down

0 comments on commit c299fdb

Please sign in to comment.