mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[tests] Use AL2 build container for relevant e2e tests (#11329)
* Forces the AL2 build container image for fixtures that depend on it, via `engines.node` in package.json for most cases. * The `testDeployment()` function was updated to send `projectSettings.nodeVersion` in the POST body, to mimic the behavior in CLI. * For Go, Ruby, and Python tests, the `projectSettings.nodeVersion` property is set "globally" in the Jest setup file, so that individual fixtures didn't need to be adjusted.
This commit is contained in:
@@ -8,6 +8,10 @@ const { spawn } = require('child_process');
|
||||
const fetch = require('./fetch-retry.js');
|
||||
const { nowDeploy, fileModeSymbol, fetchWithAuth } = require('./now-deploy.js');
|
||||
const { logWithinTest } = require('./log');
|
||||
const {
|
||||
scanParentDirs,
|
||||
getSupportedNodeVersion,
|
||||
} = require('@vercel/build-utils');
|
||||
|
||||
async function packAndDeploy(builderPath, shouldUnlink = true) {
|
||||
await spawnAsync('npm', ['--loglevel', 'warn', 'pack'], {
|
||||
@@ -304,7 +308,7 @@ async function runProbe(probe, deploymentId, deploymentUrl, ctx) {
|
||||
assert(hadTest, 'probe must have a test condition');
|
||||
}
|
||||
|
||||
async function testDeployment(fixturePath, opts) {
|
||||
async function testDeployment(fixturePath, opts = {}) {
|
||||
const projectName = path
|
||||
.basename(fixturePath)
|
||||
.toLowerCase()
|
||||
@@ -348,6 +352,34 @@ async function testDeployment(fixturePath, opts) {
|
||||
const uploadNowJson = nowJson.uploadNowJson;
|
||||
delete nowJson.uploadNowJson;
|
||||
|
||||
// Set `projectSettings.nodeVersion` based on the "engines.node" field of
|
||||
// the `package.json`. This ensures the correct build-container version is used.
|
||||
let rootDirectory = path.join(
|
||||
fixturePath,
|
||||
nowJson.builds?.length
|
||||
? path.dirname(nowJson.builds[0].src)
|
||||
: nowJson.projectSettings?.rootDirectory ?? ''
|
||||
);
|
||||
const { packageJson } = await scanParentDirs(
|
||||
rootDirectory,
|
||||
true,
|
||||
fixturePath
|
||||
);
|
||||
let nodeVersion;
|
||||
if (packageJson?.engines?.node) {
|
||||
try {
|
||||
const { range } = await getSupportedNodeVersion(packageJson.engines.node);
|
||||
nodeVersion = range;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeVersion) {
|
||||
if (!opts.projectSettings) opts.projectSettings = {};
|
||||
opts.projectSettings.nodeVersion = nodeVersion;
|
||||
}
|
||||
|
||||
const probePath = path.resolve(fixturePath, 'probe.js');
|
||||
let probes = [];
|
||||
if ('probes' in nowJson) {
|
||||
|
||||
Reference in New Issue
Block a user