-
Notifications
You must be signed in to change notification settings - Fork 84
feat: add a download script to facilitate easy use in CI MONGOSH-2687 #2532
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
base: main
Are you sure you want to change the base?
Conversation
download_latest.sh
Outdated
| arch=arm64 | ||
| esac | ||
|
|
||
| urls=$(curl -fsSL https://api.github.com/repos/mongodb-js/mongosh/releases/latest | jq -r '.assets[] | .browser_download_url' | grep -v -e \.sig -e shared -e openssl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use https://downloads.mongodb.com/compass/mongosh.json for this rather than GH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely better, yes. Adjusted jq query accordingly.
addaleax
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we need to have some sort of triage conversation in the team here, we don't typically add this type of feature on a very ad-hoc basis but this does make sense to me to add in general
download_latest.sh
Outdated
|
|
||
| curl -fsSL "$url" | tar -xzf - \ | ||
| --transform "s/.*\///" \ | ||
| --wildcards "**/mongosh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd probably want mongosh_crypt_v1.so to be extracted next to mongosh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should maybe know this, but: why so? What breaks if it’s not there? (It worked for me without.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automatic encryption for Queryable Encryption & CSFLE don't – not everybody cares about those, but I don't think we'd like to ship "partially broken" versions of mongosh if we don't need to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the script now downloads both the executable and the shared library.
Co-authored-by: Anna Henningsen <github@addaleax.net>
Co-authored-by: Anna Henningsen <github@addaleax.net>
|
@addaleax Triage: by all means. I just wanted to PoC the idea to get the ball rolling. |
| esac | ||
|
|
||
| jq_query=$(cat <<EOF | ||
| .versions[0].downloads[] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really do a semver comparison here, right? Otherwise I think that would be highly preferable.
If we leave this as-is, I'd leave a comment in
| currentVersions.sort((a, b) => semver.rcompare(a.version, b.version)); |
| select( | ||
| .distro == "$os" and | ||
| .arch == "$arch" and | ||
| (has("sharedOpenssl") | not) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally the sharedOpenssl versions are mildly preferable – we could test for the presence on the current system through e.g. ldd $(which curl) | grep -q libssl.so.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they preferable because we want updates from system library maintenance?
I get antsy testing for anything OpenSSL-related. macOS’s default curl actually uses SecureTransport, so I’m not sure testing curl is the best approach.
Does mongosh always require OpenSSL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it maybe suffice merely to output a sufficiently-loud warning in the console that the downloaded mongosh uses a static OpenSSL & thus is only recommended for short-term usage?
download_latest.sh
Outdated
| zip) | ||
| file=$(mktemp) | ||
|
|
||
| echo "Downloading $url to $file …" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would keep using >&2 like above for all diagnostic information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
download_latest.sh
Outdated
| exit 1 | ||
| esac | ||
|
|
||
| echo "✅ Success! 'mongosh' and its crypto library are now saved in this directory." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(including this line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| [installation documentation](https://www.mongodb.com/docs/mongodb-shell/install#mdb-shell-install). | ||
|
|
||
| You can also run `download_latest.sh` to download a `mongosh` binary. You can use | ||
| this script without cloning the repository thus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd mention npx mongosh here, since that's probably easier for most people who don't truly need a local installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed something … it may not be the best verbiage.
No description provided.