Skip to content

Commit

Permalink
Merge pull request #479 from apollographql/abernix/guide-to-rust-install
Browse files Browse the repository at this point in the history
Convey missing prerequisites, but don't try to install them.
  • Loading branch information
abernix committed Mar 1, 2021
2 parents 9d5b679 + 145c870 commit 33b98a0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
21 changes: 16 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ orbs:
# be found at http://github.com/apollographql/CircleCI-Orbs/.
# We could use Renovate to bump this version via PR, but that's not set up now.
oss: apollo/oss-ci-cd-tooling@0.0.15
rust: circleci/rust@1.0.0

commands:
# These are the steps used for each version of Node which we're testing
Expand All @@ -19,11 +20,21 @@ commands:
steps:
- oss/install_specific_npm_version
- checkout
- run:
# rustup must be installed in order to use `wasm-pack`.
# If rustup isn't already in our environment, install it.
name: Ensure / Install rustup
command: WRITE_BASH_ENV=t npm run rustup-install

# Install Rust
- rust/install:
version: stable

# Setup the Cargo env in CircleCI's BASH_ENV file.
#
# It's unfortunate that the rust/install Orb doesn't do this since this
# is a CircleCI-ism. I've opened a PR in hopes of avoiding this,
# though it's possible that it's out of scope (or I'm doing smth wrong):
#
# => https://github.com/CircleCI-Public/rust-orb/pull/3
# => https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command
#
- run: echo 'source $HOME/.cargo/env' >> $BASH_ENV
- oss/npm_clean_install_with_caching
- run:
command: npm run test:ci
Expand Down
26 changes: 26 additions & 0 deletions ensure-prereqs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

const { spawnSync } = require('child_process');

// Try to run rustup with the "version" (-V) flag, to smoke test whether
// or not Rust is already installed.
const result =
spawnSync(process.platform === "win32" ? "rustup.exe" : "rustup", ["-V"]);

// If this returns 0, then it is available! No need for additional work.
// If it returns anything else (most likely `null`, since there's not much
// else that can go wrong with the "version" command), then it's likely that
// Rust isn't installed, or that the installation is otherwise broken.
if (result.status === 0) {
process.exit(0);
}

console.info("***************************************************************");
console.info("* Rustup needs to be installed to work with this repository *");
console.info("***************************************************************");
console.info("");
console.info("For information how to install it, visit:")
console.info("");
console.info(" => https://rustup.rs/");
console.info("");
process.exit(1);
23 changes: 0 additions & 23 deletions ensure-rustup.sh

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"watch": "tsc --build tsconfig.build.json --watch",
"release:version-bump": "lerna version --force-publish=@apollo/query-planner-wasm",
"release:start-ci-publish": "node -p '`Publish (dist-tag:${process.env.APOLLO_DIST_TAG || \"latest\"})`' | git tag -F - \"publish/$(date -u '+%Y%m%d%H%M%S')\" && git push origin \"$(git describe --match='publish/*' --tags --exact-match HEAD)\"",
"postinstall": "npm run rustup-ensure && lerna run monorepo-prepare --stream && npm run compile",
"preinstall": "npm run ensure-prereqs",
"postinstall": "lerna run monorepo-prepare --stream && npm run compile",
"test": "jest --verbose",
"test:clean": "jest --clearCache",
"test:watch": "jest --verbose --watchAll",
"testonly": "npm test",
"test:ci": "npm test -- --ci --maxWorkers=2 --reporters=default --reporters=jest-junit",
"rustup-install": "INSTALL_RUSTUP=true ./ensure-rustup.sh",
"rustup-ensure": "INSTALL_RUSTUP= ./ensure-rustup.sh"
"ensure-prereqs": "node ensure-prereqs.js"
},
"engines": {
"node": ">=6"
Expand Down

0 comments on commit 33b98a0

Please sign in to comment.