Skip to content
Open
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
26 changes: 26 additions & 0 deletions .github/workflows/check-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ jobs:
run: npm run check-ci -- --stream
shell: bash

# Downloading and extracting MongoDB server binaries is slow on Windows,
# so we cache them between runs.
#
# Cache directories are named after the requested version range ('8.x',
# '*'), not the version it resolved to, so a cache entry pins tests to
# whichever release was current when it was written. Including the ISO
# week in the key rotates that weekly, keeping us at most a week behind.
# Bump `v1` to force a refresh.
- name: Compute cache week
if: ${{ runner.os == 'Windows' }}
id: cache-week
run: echo "week=$(date -u +%G-%V)" >> "$GITHUB_OUTPUT"
shell: bash

- name: Cache MongoDB binaries
if: ${{ runner.os == 'Windows' }}
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ runner.temp }}/mongodb-binaries
key: v1-mongodb-binaries-${{ runner.os }}-${{ steps.cache-week.outputs.week }}

- name: Set MongoDB binaries download dir
if: ${{ runner.os == 'Windows' }}
run: echo "MONGODB_RUNNER_DOWNLOAD_DIR=${RUNNER_TEMP}/mongodb-binaries" >> $GITHUB_ENV
shell: bash

- name: Run Tests
run: |
scopes=$(node .github/scripts/compute-test-group.mjs "${{ matrix.group }}" "${TOTAL_GROUPS}")
Expand Down
6 changes: 5 additions & 1 deletion packages/mongodb-runner/src/mongocluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export interface RSMemberOptions {
export interface CommonOptions {
/**
* Directory where server binaries will be downloaded and stored.
* Defaults to the `MONGODB_RUNNER_DOWNLOAD_DIR` environment variable if set,
* otherwise to `tmpDir`.
*/
downloadDir?: string;
/**
Expand Down Expand Up @@ -380,7 +382,9 @@ export class MongoCluster extends EventEmitter<MongoClusterEvents> {
cluster.defaultConnectionOptions = { ...options.internalClientOptions };
if (!options.binDir) {
options.binDir = await this.downloadMongoDb(
options.downloadDir ?? options.tmpDir,
options.downloadDir ??
process.env.MONGODB_RUNNER_DOWNLOAD_DIR ??

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to avoid using env here and instead pass the downloadDir everywhere? It will add a bit more code and could lead to folks not passing it though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like env is fine but since this is in the CLI could we add it to the help menu along side the --downloadDir flag and call this PR a feat -> (feat to add env var control for the download location)

options.tmpDir,
options.version,
options.downloadOptions,
);
Expand Down
Loading