Skip to content

Commit 14929e2

Browse files
committed
ci: cache Arsenal Image Mounter files
This commits add logic to cache files used to create a Windows RAM disk to avoid extra HTTP requests.
1 parent e35750d commit 14929e2

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

.circleci/config.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ orbs:
1818
# Windows needs its own cache key because binaries in node_modules are different.
1919
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
2020
var_1: &cache_key v1-angular_devkit-14.19-{{ checksum "yarn.lock" }}
21-
var_1_win: &cache_key_win v1-angular_devkit-win-14.19-{{ checksum "yarn.lock" }}
21+
var_1_win: &cache_key_win v1-angular_devkit-win-16.10-{{ checksum "yarn.lock" }}
2222
var_3: &default_nodeversion '14.19'
2323
# Workspace initially persisted by the `setup` job, and then enhanced by `setup-and-build-win`.
2424
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
@@ -83,12 +83,6 @@ commands:
8383
at: *workspace_location
8484
setup_windows:
8585
steps:
86-
- run:
87-
# We use Arsenal Image Mounter (AIM) instead of ImDisk because of: https://github.com/nodejs/node/issues/6861
88-
# Useful resources for AIM: http://reboot.pro/index.php?showtopic=22068
89-
name: 'Arsenal Image Mounter (RAM Disk)'
90-
command: |
91-
pwsh ./.circleci/win-ram-disk.ps1
9286
- run: nvm install 16.10
9387
- run: nvm use 16.10
9488
- run: npm install -g [email protected]
@@ -323,11 +317,20 @@ jobs:
323317
- restore_cache:
324318
keys:
325319
- *cache_key_win
320+
- run:
321+
# We use Arsenal Image Mounter (AIM) instead of ImDisk because of: https://github.com/nodejs/node/issues/6861
322+
# Useful resources for AIM: http://reboot.pro/index.php?showtopic=22068
323+
name: 'Arsenal Image Mounter (RAM Disk)'
324+
command: |
325+
pwsh ./.circleci/win-ram-disk.ps1
326326
- run: yarn install --frozen-lockfile --cache-folder ../.cache/yarn
327327
- save_cache:
328328
key: *cache_key_win
329329
paths:
330330
- ~/.cache/yarn
331+
# Path where Arsenal Image Mounter files are downloaded.
332+
# Must match path in .circleci/win-ram-disk.ps1
333+
- ./aim
331334
# Run partial e2e suite on PRs only. Release branches will run the full e2e suite.
332335
- run:
333336
name: Execute E2E Tests

.circleci/win-ram-disk.ps1

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
# Download AIM Drivers and validate hash
2-
Invoke-WebRequest "https://github.com/ArsenalRecon/Arsenal-Image-Mounter/raw/988930e4b3180ec34661504e6f9906f98943a022/DriverSetup/DriverFiles.zip" -OutFile "aim_drivers.zip" -UseBasicParsing
3-
$aimDriversDownloadHash = (Get-FileHash aim_drivers.zip -a sha256).Hash
4-
If ($aimDriversDownloadHash -ne "1F5AA5DD892C2D5E8A0083752B67C6E5A2163CD83B6436EA545508D84D616E02") {
5-
throw "aim_drivers.zip hash is ${aimDriversDownloadHash} which didn't match the known version."
6-
}
7-
Expand-Archive -Path "aim_drivers.zip"
1+
$aimContents = "./aim";
2+
3+
if (-not (Test-Path -Path $aimContents)) {
4+
echo "Arsenal Image Mounter files not found in cache. Downloading..."
5+
6+
# Download AIM Drivers and validate hash
7+
Invoke-WebRequest "https://github.com/ArsenalRecon/Arsenal-Image-Mounter/raw/988930e4b3180ec34661504e6f9906f98943a022/DriverSetup/DriverFiles.zip" -OutFile "aim_drivers.zip" -UseBasicParsing
8+
$aimDriversDownloadHash = (Get-FileHash aim_drivers.zip -a sha256).Hash
9+
If ($aimDriversDownloadHash -ne "1F5AA5DD892C2D5E8A0083752B67C6E5A2163CD83B6436EA545508D84D616E02") {
10+
throw "aim_drivers.zip hash is ${aimDriversDownloadHash} which didn't match the known version."
11+
}
12+
Expand-Archive -Path "aim_drivers.zip" -DestinationPath $aimContents/drivers
813

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

1725
# Install AIM drivers
18-
./aim_ll/x64/aim_ll.exe --install ./aim_drivers
26+
./aim/cli/x64/aim_ll.exe --install ./aim/drivers
1927

2028
# Setup RAM disk mount. Same parameters as ImDisk
2129
# See: https://support.circleci.com/hc/en-us/articles/4411520952091-Create-a-windows-RAM-disk
22-
./aim_ll/x64/aim_ll.exe -a -s 5G -m X: -p "/fs:ntfs /q /y"
30+
./aim/cli/x64/aim_ll.exe -a -s 5G -m X: -p "/fs:ntfs /q /y"

0 commit comments

Comments
 (0)