Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parallel builds to be disabled #3001

Merged
merged 3 commits into from Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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