Skip to content

Commit

Permalink
Fix pnpm installs by moving binary download location (#1927)
Browse files Browse the repository at this point in the history
Fixes #1881 

Now binaries will be stored in a consistent location no matter what mechanism we use to grab them. This will mean they won't conflict with the shim that pnpm uses and thus avoid the infinite loop
  • Loading branch information
jonathanrainer authored Jun 17, 2024
1 parent 436a677 commit 691e5b0
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ executors:
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"

node_js:
docker:
- image: node:lts
resource_class: medium


tag_matches_prerelease: &tag_matches_prerelease
matches:
pattern: "^.*(beta|alpha|rc|prerelease|draft|test).*$"
Expand Down Expand Up @@ -143,6 +149,11 @@ workflows:
platform: [amd_ubuntu]
rust_channel: [stable]
command: [integration-test]
- install_js:
name: Test installation for Javascript Package Managers (<< matrix.package_manager >>)
matrix:
parameters:
package_manager: [npm, npm_global, pnpm]
release:
jobs:
- xtask:
Expand All @@ -163,6 +174,13 @@ workflows:
command: [integration-test]
<<: *run_release

- install_js:
name: Test installation for Javascript Package Managers (<< matrix.package_manager >>)
matrix:
parameters:
package_manager: [ npm, npm_global, pnpm ]
<<: *run_release

- xtask:
name: Build and bundle release artifacts (<< matrix.platform >>)
matrix:
Expand All @@ -177,6 +195,9 @@ workflows:
- "Run cargo tests + studio integration tests (stable rust on amd_macos)"
- "Run cargo tests + studio integration tests (stable rust on amd_windows)"
- "Run supergraph-demo tests (stable rust on amd_ubuntu)"
- "Test installation for Javascript Package Managers (npm)"
- "Test installation for Javascript Package Managers (npm_global)"
- "Test installation for Javascript Package Managers (pnpm)"
<<: *run_release

- publish_release:
Expand Down Expand Up @@ -272,6 +293,21 @@ jobs:
- gh_release
- npm_publish

install_js:
parameters:
package_manager:
type: enum
enum: ["npm", "npm_global", "pnpm"]
executor: node_js
steps:
- checkout:
path: "rover"
- run:
name: "Invoke Install Scripts"
command: |
cd rover/.circleci/scripts
./install_<< parameters.package_manager >>.sh
# reusable command snippets can be referred to in any `steps` object
commands:
setup:
Expand Down
15 changes: 15 additions & 0 deletions .circleci/scripts/install_npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
set -euo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd "$(mktemp -d)"
echo "Created test directory"
npm init -y
echo "Initialised new npm package"
npm install --install-links=true "$SCRIPT_DIR/../../installers/npm"
echo "Installed rover as local npm package"
cd node_modules/.bin/
echo "Checking version"
./rover --version
echo "Checked version, all ok!"
13 changes: 13 additions & 0 deletions .circleci/scripts/install_npm_global.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash
set -euo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd "$(mktemp -d)"
echo "Created test directory"
npm install --install-links=true -g "$SCRIPT_DIR/../../installers/npm"
echo "Installed rover as global npm package"
cd /usr/local/bin/
echo "Checking version"
./rover --version
echo "Checked version, all ok!"
16 changes: 16 additions & 0 deletions .circleci/scripts/install_pnpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash
set -euo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd "$(mktemp -d)"
echo "Created test directory"
npm install -g [email protected]
echo "Installed pnpm"
pnpm init
pnpm add "file:$SCRIPT_DIR/../../installers/npm"
echo "Installed rover as pnpm package"
cd node_modules/.bin/
echo "Checking version"
./rover --version
echo "Checked version, all ok!"
7 changes: 4 additions & 3 deletions installers/npm/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getPlatform = () => {

/*! Copyright (c) 2019 Avery Harnish - MIT License */
class Binary {
constructor(name, url, config) {
constructor(name, url) {
let errors = [];
if (typeof url !== "string") {
errors.push("url must be a string");
Expand Down Expand Up @@ -131,8 +131,9 @@ class Binary {
}
this.url = url;
this.name = name;
this.installDirectory =
config?.installDirectory || join(__dirname, "node_modules", ".bin");
const { dirname } = require('path');
const appDir = dirname(require.main.filename);
this.installDirectory = join(appDir, "binary");

if (!existsSync(this.installDirectory)) {
mkdirSync(this.installDirectory, { recursive: true });
Expand Down

0 comments on commit 691e5b0

Please sign in to comment.