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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic CI jobs parallelization breaks some usecases #2415

Closed
kamituel opened this issue Feb 27, 2020 · 4 comments
Closed

Automatic CI jobs parallelization breaks some usecases #2415

kamituel opened this issue Feb 27, 2020 · 4 comments
Labels

Comments

@kamituel
Copy link

Situation

I'm running 4 parallel steps in a Bitbucket pipeline. Each of those steps does a different thing - each builds and tests a different subproject. In one of those subprojects I'm trying to run ava test runner with one test file.

Problem

However, in lib/cli.js we have this:

	if (isCi && ciParallelVars) {
		const {index: currentIndex, total: totalRuns} = ciParallelVars;
		parallelRuns = {currentIndex, totalRuns};
	}

This condition will always evaluate in CI (at least that's the intention) and the ci-parallel-vars package used here will assign currentIndex to a value of BITBUCKET_PARALLEL_STEP env variable, and totalRuns to BITBUCKET_PARALLEL_STEP_COUNT.

In my case currentIndex evaluates to 3 and totalRuns to 4. That's invalid because I only execute the test in one of those parallel steps.

Then in lib/api.jsthere's this code:

if (this.options.parallelRuns) {
    // ... truncated for brevity
    selectedFiles = chunkd(selectedFiles, currentIndex, totalRuns);
    // Evaluates as:
    //  selectedFiles = chunkd([x], 3, 4)
    // which is an empty array
    // ...
}

This way the only test file I have is being dropped and no tests are evaluated.

Expected behavior

I would expect to have an option to disable the CI parallel runs feature. Or maybe to provide custom values for currentIndex and totalRuns.

Workaround
The only workaround I found is to do this:

(unset BITBUCKET_PARALLEL_STEP; unset BITBUCKET_PARALLEL_STEP_COUNT; npm run test)

Context

I believe this is related to #1811 and #1812.

@novemberborn
Copy link
Member

Oh nice use case.

Let's add support for configuration like this:

// ava.config.js

export default {
  ciParallelRuns: false,
}

I'd like to keep the "ci" prefix, to avoid confusion with the concurrency option.

We'd only allow the false value for now.

This should be implemented in lib/cli.js.

@novemberborn novemberborn added enhancement new functionality help wanted and removed needs triage labels Feb 27, 2020
@tuopppi
Copy link

tuopppi commented Nov 17, 2021

Our team has the same multi-project setup and we faced the same issue. It took some time to figure out why ava reported: "No files tested in this parallel run" even though the same command locally resulted in all tests being run. Maybe ava could print out some debug info in verbose mode if it's running just a subset of test cases.

@novemberborn
Copy link
Member

@tuopppi what kind of info are you looking for? AVA already prints when it ran a subset of the test files in a parallel run, and also when it could not run any test files.

Meanwhile I'll happily take a PR for this.

@novemberborn
Copy link
Member

Parallelization can be disabled, see #2994.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants