-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Evaldo Felipe <[email protected]>
- Loading branch information
1 parent
f9ae6d8
commit ff92515
Showing
2 changed files
with
75 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import glob from 'glob'; | ||
|
||
if (!process.env.CI_TOTAL) { | ||
console.error('No environment variable CI_TOTAL defined'); | ||
process.exit(1); | ||
} | ||
|
||
if (!process.env.CI_INDEX) { | ||
console.error('No environment variable CI_INDEX defined'); | ||
process.exit(1); | ||
} | ||
|
||
function splitChunks(items: string[], total: number): string[][] { | ||
let chunks: string[][] = []; | ||
|
||
let currentChunk = 0; | ||
for (let currentItem = 0; currentItem < items.length; currentItem++) { | ||
if (!chunks[currentChunk]) { | ||
chunks[currentChunk] = []; | ||
} | ||
|
||
chunks[currentChunk].push(items[currentItem]); | ||
|
||
currentChunk++; | ||
if (currentChunk >= total) { | ||
currentChunk = 0; | ||
} | ||
} | ||
|
||
return chunks; | ||
} | ||
|
||
const files: string[] = glob.sync('test/**/*.ts'); | ||
const chunks: string[][] = splitChunks(files, parseInt(process.env.CI_TOTAL)); | ||
|
||
if (chunks[parseInt(process.env.CI_INDEX)]) { | ||
for (const file of chunks[parseInt(process.env.CI_INDEX)]) { | ||
process.stdout.write(file + "\n"); | ||
} | ||
} |