diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ca5f8b9f..91f6e2ac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,9 +17,9 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1 + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: ${{ matrix.node-version }} - run: npm ci diff --git a/test/test-integration.mjs b/test/test-integration.mjs index 2d8e4fd3..ab3b71a5 100644 --- a/test/test-integration.mjs +++ b/test/test-integration.mjs @@ -64,7 +64,7 @@ describe('integration tests', { timeout: 12 * 60 * 1000 }, () => { await checkAudit(runResult.env.cwd); //console.log('command-ts with test: Running extension compile'); - const res2 = await doSpawn(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); + const res2 = await doSpawnWithNetworkRetry(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); if (res2.exitCode !== 0) { assert.fail(`npm run test failed: stdout ${res2.stdout} stderr ${res2.stderr}`); } @@ -94,7 +94,7 @@ describe('integration tests', { timeout: 12 * 60 * 1000 }, () => { await checkAudit(runResult.env.cwd); //console.log('command-ts-webpack with test: Running extension compile'); - const res2 = await doSpawn(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); + const res2 = await doSpawnWithNetworkRetry(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); if (res2.exitCode !== 0) { assert.fail(`npm run compile failed: stdout ${res2.stdout} stderr ${res2.stderr}`); } @@ -124,7 +124,7 @@ describe('integration tests', { timeout: 12 * 60 * 1000 }, () => { await checkAudit(runResult.env.cwd); //console.log('command-ts-esbuild with test: Running extension compile'); - const res2 = await doSpawn(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); + const res2 = await doSpawnWithNetworkRetry(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); if (res2.exitCode !== 0) { assert.fail(`npm run compile failed: stdout ${res2.stdout} stderr ${res2.stderr}`); } @@ -154,7 +154,7 @@ describe('integration tests', { timeout: 12 * 60 * 1000 }, () => { await checkAudit(runResult.env.cwd); //console.log('command-ts-web with test: Running extension compile-web'); - const res2 = await doSpawn(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); + const res2 = await doSpawnWithNetworkRetry(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); if (res2.exitCode !== 0) { assert.fail(`npm run test failed: stdout ${res2.stdout} stderr ${res2.stderr}`); } @@ -184,7 +184,7 @@ describe('integration tests', { timeout: 12 * 60 * 1000 }, () => { await checkAudit(runResult.env.cwd); //console.log('command-ts-web with test: Running extension compile-web'); - const res2 = await doSpawn(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); + const res2 = await doSpawnWithNetworkRetry(npmCommand, ['run', 'test'], { cwd: runResult.env.cwd, shell: true }); if (res2.exitCode !== 0) { assert.fail(`npm run test failed: stdout ${res2.stdout} stderr ${res2.stderr}`); } @@ -213,3 +213,12 @@ async function doSpawn(execName, allArguments, options) { }); } +async function doSpawnWithNetworkRetry(execName, allArguments, options) { + for (let attempt = 1; attempt <= 3; attempt++) { + const result = await doSpawn(execName, allArguments, options); + if (result.exitCode === 0 || !/ETIMEDOUT/.test(`${result.stdout}\n${result.stderr}`) || attempt === 3) { + return result; + } + await new Promise(resolve => setTimeout(resolve, 1000)); + } +}