Skip to content

Commit 8596ab8

Browse files
authored
chore(ci): run packaged app test outside of git repository COMPASS-5515 (#4910)
This works nicely on Linux and macOS, not so much on Windows unfortunately. This probably still gives us decent coverage for the problem this is intended to prevent (Compass accidentally relying on npm packages inside the repository).
1 parent 9bdab8f commit 8596ab8

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

.evergreen/functions.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ variables:
4040
# WARN: This version is behind our electron runtime, but updating it will
4141
# drop support for some older linux platforms, so we are keeping them out of
4242
# sync for now
43-
# TODO: https://jira.mongodb.org/browse/COMPASS-6915
43+
# TODO: https://jira.mongodb.org/browse/COMPASS-6915
4444
NODE_JS_VERSION: '16.20.2'
4545
NPM_VERSION: '8.19.4'
4646
# secrets
@@ -323,38 +323,42 @@ functions:
323323
shell: bash
324324
env:
325325
<<: *compass-env
326-
COMPASS_APP_PATH: ${appPath}
327-
COMPASS_APP_NAME: ${packagerOptions.name}
326+
COMPASS_APP_PATH_ORIGINAL: ${appPath}
328327
script: |
329328
set -e
330329
# Load environment variables
331330
eval $(.evergreen/print-compass-env.sh)
331+
set -x
332332
333333
# Check the app bundle size.
334334
npm run --workspace mongodb-compass check-bundled-app-size
335335
336-
echo "Unpacking ${app_archive_name} ..."
336+
if [[ "$IS_WINDOWS" == "true" ]]; then
337+
COMPASS_OUTDIR="$COMPASS_APP_PATH_ORIGINAL"
338+
else
339+
# Unpack outside the Compass working tree to avoid interactions with
340+
# npm packages from inside it.
341+
# (This doesn't seem to work on Windows without issues around being
342+
# able to spawn the extracted executable, unfortunately.)
343+
COMPASS_OUTDIR="$PWD/../tmp/from-packaged"
344+
fi
345+
346+
mkdir -p "$COMPASS_OUTDIR"
347+
echo "Unpacking ${app_archive_name} to $COMPASS_OUTDIR ..."
337348
338349
# Unpack the app archive
339350
if [[ "${app_archive_name}" == *.zip ]]; then
340-
COMPASS_OUTDIR="$COMPASS_APP_PATH"
341-
if [[ "$IS_OSX" == "true" ]]; then
342-
# unzip on macos needs a different path to avoid nesting the .app
343-
# inside another .app dir
344-
COMPASS_OUTDIR=$(dirname "$COMPASS_APP_PATH")
345-
fi
346-
echo "Unpacking ${app_archive_name} to $COMPASS_OUTDIR ..."
347-
mkdir -p "$COMPASS_OUTDIR"
348351
unzip "packages/compass/dist/${app_archive_name}" -d "$COMPASS_OUTDIR"
349352
else
350-
COMPASS_OUTDIR="packages/compass/dist"
351-
echo "Unpacking ${app_archive_name} to $COMPASS_OUTDIR ..."
352-
mkdir -p "$COMPASS_OUTDIR"
353353
tar -xzf "packages/compass/dist/${app_archive_name}" -C "$COMPASS_OUTDIR"
354354
fi
355355
356356
# Print folder content to confirm that it worked
357-
ls -la packages/compass/dist
357+
ls -la "$COMPASS_OUTDIR"
358+
359+
if [[ "$IS_WINDOWS" == "true" ]]; then
360+
chmod +x "$COMPASS_OUTDIR"/*.exe
361+
fi
358362
359363
e2e-coverage:
360364
- command: shell.exec
@@ -387,7 +391,7 @@ functions:
387391
shell: bash
388392
env:
389393
<<: *compass-env
390-
COMPASS_APP_PATH: ${appPath}
394+
COMPASS_APP_PATH_ORIGINAL: ${appPath}
391395
COMPASS_APP_NAME: ${packagerOptions.name}
392396
DEBUG: ${debug|}
393397
MONGODB_VERSION: ${mongodb_version|}
@@ -398,10 +402,15 @@ functions:
398402
eval $(.evergreen/print-compass-env.sh)
399403
source .evergreen/start-docker-envs.sh
400404
405+
if [[ "$IS_WINDOWS" == "true" ]]; then
406+
export COMPASS_APP_PATH="$COMPASS_APP_PATH_ORIGINAL"
407+
else
408+
export COMPASS_APP_PATH="$PWD/../tmp/from-packaged/$(basename "$COMPASS_APP_PATH_ORIGINAL")"
409+
fi
401410
echo "Running tests against packaged app at $COMPASS_APP_PATH for MongoDB $MONGODB_VERSION..."
402411
403412
if [[ "$IS_OSX" == "true" ]]; then
404-
echo "Disabling keychain usage in Compass (TODO: https://jira.mongodb.org/browse/BUILD-14458)"
413+
echo "Disabling keychain usage in Compass (TODO: https://jira.mongodb.org/browse/COMPASS-7102)"
405414
export COMPASS_E2E_DISABLE_KEYCHAIN_USAGE="true"
406415
echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)"
407416
export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true"

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,12 @@ async function getCompassBuildMetadata(): Promise<BinPathOptions> {
726726
}
727727
// Double-checking that Compass app path exists, not only the metadata
728728
await fs.stat(metadata.appPath);
729+
debug('Existing Compass found', metadata);
729730
return metadata;
730-
} catch (e) {
731+
} catch (e: any) {
732+
debug('Existing Compass build not found', e);
731733
throw new Error(
732-
"Compass package metadata doesn't exist. Make sure you built Compass before running e2e tests"
734+
`Compass package metadata doesn't exist. Make sure you built Compass before running e2e tests: ${e.message}`
733735
);
734736
}
735737
}

0 commit comments

Comments
 (0)