Add concurrency for flakey tests detection (#67019)

This ensures we parallelize our flakey test detection since when a lot
are changed it can hit the timeout and not be able to run them all.
This commit is contained in:
JJ Kasper 2024-06-19 07:01:24 -07:00 committed by GitHub
parent af93aafc95
commit 42f6dc3d9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 6 deletions

View file

@ -284,10 +284,15 @@ jobs:
needs: ['changes', 'build-native', 'build-next'] needs: ['changes', 'build-native', 'build-next']
if: ${{ needs.changes.outputs.docs-only == 'false' }} if: ${{ needs.changes.outputs.docs-only == 'false' }}
strategy:
fail-fast: false
matrix:
group: [1/4, 2/4, 3/4, 4/4]
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
afterBuild: node scripts/test-new-tests.mjs --dev-mode afterBuild: node scripts/test-new-tests.mjs --dev-mode --group ${{ matrix.group }}
stepName: 'test-new-tests-dev' stepName: 'test-new-tests-dev-${{matrix.group}}'
secrets: inherit secrets: inherit
@ -296,10 +301,15 @@ jobs:
needs: ['changes', 'build-native', 'build-next'] needs: ['changes', 'build-native', 'build-next']
if: ${{ needs.changes.outputs.docs-only == 'false' }} if: ${{ needs.changes.outputs.docs-only == 'false' }}
strategy:
fail-fast: false
matrix:
group: [1/4, 2/4, 3/4, 4/4]
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
afterBuild: node scripts/test-new-tests.mjs --prod-mode afterBuild: node scripts/test-new-tests.mjs --prod-mode --group ${{ matrix.group }}
stepName: 'test-new-tests-start' stepName: 'test-new-tests-start-${{matrix.group}}'
secrets: inherit secrets: inherit

View file

@ -2,9 +2,23 @@
import fs from 'fs/promises' import fs from 'fs/promises'
import execa from 'execa' import execa from 'execa'
import path from 'path' import path from 'path'
import yargs from 'yargs'
async function main() { async function main() {
let testMode = process.argv.includes('--dev-mode') ? 'dev' : 'start' let argv = await yargs(process.argv.slice(2))
.boolean('--dev-mode')
.string('group').argv
let testMode = argv['--dev-mode'] ? 'dev' : 'start'
const rawGroup = argv['group']
let currentGroup = 1
let groupTotal = 1
if (rawGroup) {
;[currentGroup, groupTotal] = rawGroup
.split('/')
.map((item) => Number(item))
}
let eventData = {} let eventData = {}
@ -102,7 +116,35 @@ async function main() {
) )
) )
const currentTests = testMode === 'dev' ? devTests : prodTests let currentTests = testMode === 'dev' ? devTests : prodTests
/**
@type {Array<string[]>}
*/
const fileGroups = []
for (const test of currentTests) {
let smallestGroup = fileGroups[0]
let smallestGroupIdx = 0
// get the smallest group time to add current one to
for (let i = 0; i < groupTotal; i++) {
if (!fileGroups[i]) {
fileGroups[i] = []
}
if (
smallestGroup &&
fileGroups[i] &&
fileGroups[i].length < smallestGroup.length
) {
smallestGroup = fileGroups[i]
smallestGroupIdx = i
}
}
fileGroups[smallestGroupIdx].push(test)
}
currentTests = fileGroups[currentGroup - 1] || []
if (currentTests.length === 0) { if (currentTests.length === 0) {
console.log(`No added/changed tests detected`) console.log(`No added/changed tests detected`)