Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use RAM disk for Windows tests #23327

Merged
merged 4 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ orbs:
# Windows needs its own cache key because binaries in node_modules are different.
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
var_1: &cache_key v1-angular_devkit-14.19-{{ checksum "yarn.lock" }}
var_1_win: &cache_key_win v1-angular_devkit-win-14.19-{{ checksum "yarn.lock" }}
var_1_win: &cache_key_win v1-angular_devkit-win-16.10-{{ checksum "yarn.lock" }}
var_3: &default_nodeversion '14.19'
# Workspace initially persisted by the `setup` job, and then enhanced by `setup-and-build-win`.
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
Expand Down Expand Up @@ -317,19 +317,29 @@ jobs:
- restore_cache:
keys:
- *cache_key_win
- run:
# We use Arsenal Image Mounter (AIM) instead of ImDisk because of: https://github.com/nodejs/node/issues/6861
# Useful resources for AIM: http://reboot.pro/index.php?showtopic=22068
name: 'Arsenal Image Mounter (RAM Disk)'
command: |
pwsh ./.circleci/win-ram-disk.ps1
- run: yarn install --frozen-lockfile --cache-folder ../.cache/yarn
- save_cache:
key: *cache_key_win
paths:
- ~/.cache/yarn
# Path where Arsenal Image Mounter files are downloaded.
# Must match path in .circleci/win-ram-disk.ps1
- ./aim
# Run partial e2e suite on PRs only. Release branches will run the full e2e suite.
- run:
name: Execute E2E Tests
command: |
mkdir X:/ramdisk/e2e-main
if (Test-Path env:CIRCLE_PULL_REQUEST) {
node tests\legacy-cli\run_e2e.js "--glob={tests/basic/**,tests/i18n/extract-ivy*.ts,tests/build/profile.ts,tests/test/test-sourcemap.ts,tests/misc/check-postinstalls.ts}" --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
node tests\legacy-cli\run_e2e.js "--glob={tests/basic/**,tests/i18n/extract-ivy*.ts,tests/build/profile.ts,tests/test/test-sourcemap.ts,tests/misc/check-postinstalls.ts}" --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX --tmpdir=X:/ramdisk/e2e-main
} else {
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX --tmpdir=X:/ramdisk/e2e-main
}
- fail_fast

Expand Down
30 changes: 30 additions & 0 deletions .circleci/win-ram-disk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$aimContents = "./aim";

if (-not (Test-Path -Path $aimContents)) {
echo "Arsenal Image Mounter files not found in cache. Downloading..."

# Download AIM Drivers and validate hash
Invoke-WebRequest "https://github.com/ArsenalRecon/Arsenal-Image-Mounter/raw/988930e4b3180ec34661504e6f9906f98943a022/DriverSetup/DriverFiles.zip" -OutFile "aim_drivers.zip" -UseBasicParsing
$aimDriversDownloadHash = (Get-FileHash aim_drivers.zip -a sha256).Hash
If ($aimDriversDownloadHash -ne "1F5AA5DD892C2D5E8A0083752B67C6E5A2163CD83B6436EA545508D84D616E02") {
throw "aim_drivers.zip hash is ${aimDriversDownloadHash} which didn't match the known version."
}
Expand-Archive -Path "aim_drivers.zip" -DestinationPath $aimContents/drivers

# Download AIM CLI and validate hash
Invoke-WebRequest "https://github.com/ArsenalRecon/Arsenal-Image-Mounter/raw/988930e4b3180ec34661504e6f9906f98943a022/Command%20line%20applications/aim_ll.zip" -OutFile "aim_ll.zip" -UseBasicParsing
$aimCliDownloadHash = (Get-FileHash aim_ll.zip -a sha256).Hash
If ($aimCliDownloadHash -ne "9AD3058F14595AC4A5E5765A9746737D31C219383766B624FCBA4C5ED96B20F3") {
throw "aim_ll.zip hash is ${aimCliDownloadHash} which didn't match the known version."
}
Expand-Archive -Path "aim_ll.zip" -DestinationPath $aimContents/cli
} else {
echo "Arsenal Image Mounter files found in cache. Skipping download."
}

# Install AIM drivers
./aim/cli/x64/aim_ll.exe --install ./aim/drivers

# Setup RAM disk mount. Same parameters as ImDisk
# See: https://support.circleci.com/hc/en-us/articles/4411520952091-Create-a-windows-RAM-disk
./aim/cli/x64/aim_ll.exe -a -s 5G -m X: -p "/fs:ntfs /q /y"
17 changes: 7 additions & 10 deletions tests/legacy-cli/e2e/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,13 @@ export async function killAllProcesses(signal = 'SIGTERM'): Promise<void> {
}

processesToKill.push(
new Promise<void>((resolve, reject) => {
treeKill(childProc.pid, signal, (err) => {
if (err && !err.message.includes('not found')) {
// Ignore process not found errors.
// This is due to a race condition with the `waitForMatch` logic.
// where promises are resolved on matches and not when the process terminates.
reject(err);
} else {
resolve();
}
new Promise<void>((resolve) => {
treeKill(childProc.pid, signal, () => {
// Ignore all errors.
// This is due to a race condition with the `waitForMatch` logic.
// where promises are resolved on matches and not when the process terminates.
// Also in some cases in windows we get `The operation attempted is not supported`.
resolve();
});
}),
);
Expand Down