cherry-pick(#17896): chore: make local docker build work on branch (#17906)

Branch does not pass `isDevelopmentMode` check because it does not have
a version ending with `-next`. Therefore, `env.PWTEST_DOCKER_BASE_IMAGE`
is ignored which leads to the pull of non-existent image.
This commit is contained in:
Dmitry Gozman 2022-10-07 10:11:41 -07:00 committed by GitHub
parent 3f0af1e4df
commit c05225f9b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,12 +75,12 @@ async function deletePlaywrightImage() {
async function buildPlaywrightImage() { async function buildPlaywrightImage() {
await checkDockerEngineIsRunningOrDie(); await checkDockerEngineIsRunningOrDie();
const isDevelopmentMode = getPlaywrightVersion().includes('next');
let baseImageName = `mcr.microsoft.com/playwright:v${getPlaywrightVersion()}-${VRT_IMAGE_DISTRO}`;
// 1. Build or pull base image. // 1. Build or pull base image.
if (isDevelopmentMode) { let baseImageName = process.env.PWTEST_DOCKER_BASE_IMAGE || '';
// Use our docker build scripts in development mode! if (!baseImageName) {
if (!process.env.PWTEST_DOCKER_BASE_IMAGE) { const isDevelopmentMode = getPlaywrightVersion().includes('next');
if (isDevelopmentMode) {
// Use our docker build scripts in development mode!
const arch = process.arch === 'arm64' ? '--arm64' : '--amd64'; const arch = process.arch === 'arm64' ? '--arm64' : '--amd64';
throw createStacklessError(utils.wrapInASCIIBox([ throw createStacklessError(utils.wrapInASCIIBox([
`You are in DEVELOPMENT mode!`, `You are in DEVELOPMENT mode!`,
@ -91,8 +91,7 @@ async function buildPlaywrightImage() {
` PWTEST_DOCKER_BASE_IMAGE=playwright:localbuild npx playwright docker build`, ` PWTEST_DOCKER_BASE_IMAGE=playwright:localbuild npx playwright docker build`,
].join('\n'), 1)); ].join('\n'), 1));
} }
baseImageName = process.env.PWTEST_DOCKER_BASE_IMAGE; baseImageName = `mcr.microsoft.com/playwright:v${getPlaywrightVersion()}-${VRT_IMAGE_DISTRO}`;
} else {
const { code } = await spawnAsync('docker', ['pull', baseImageName], { stdio: 'inherit' }); const { code } = await spawnAsync('docker', ['pull', baseImageName], { stdio: 'inherit' });
if (code !== 0) if (code !== 0)
throw new Error('Failed to pull docker image!'); throw new Error('Failed to pull docker image!');