-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure NPM Windows Installs Work Correctly (#2059)
Fixes: #2056 This PR fixes the reported bug that `rover` will not install correctly on Windows when using an `npm` installer. The problem was that the renaming function was using the word `rover` rather than `rover.exe` as it should have done when calling the rename.
- Loading branch information
1 parent
592cf06
commit 23b4aad
Showing
10 changed files
with
206 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,11 +104,17 @@ executors: | |
environment: | ||
XTASK_TARGET: "x86_64-unknown-linux-gnu" | ||
|
||
node_js: | ||
node_js_nix: | ||
docker: | ||
- image: node:lts | ||
- image: node:20.16.0 | ||
resource_class: medium | ||
|
||
node_js_windows: | ||
machine: | ||
image: "windows-server-2019-vs2019:2022.08.1" | ||
shell: powershell.exe -ExecutionPolicy Bypass | ||
resource_class: windows.medium | ||
|
||
|
||
tag_matches_prerelease: &tag_matches_prerelease | ||
matches: | ||
|
@@ -171,10 +177,11 @@ workflows: | |
rust_channel: [stable] | ||
command: [integration-test] | ||
- install_js: | ||
name: Test installation for Javascript Package Managers (<< matrix.package_manager >>) | ||
name: Test installation for Javascript Package Managers (<< matrix.package_manager >> on << matrix.platform >>) | ||
matrix: | ||
parameters: | ||
package_manager: [npm, npm_global, pnpm] | ||
platform: [windows, nix] | ||
- node/test: | ||
name: Test NPM Installer Scripts | ||
app-dir: "~/project/installers/npm" | ||
|
@@ -216,10 +223,11 @@ workflows: | |
<<: *run_release | ||
|
||
- install_js: | ||
name: Test installation for Javascript Package Managers (<< matrix.package_manager >>) | ||
name: Test installation for Javascript Package Managers (<< matrix.package_manager >> on << matrix.platform >>) | ||
matrix: | ||
parameters: | ||
package_manager: [ npm, npm_global, pnpm ] | ||
platform: [windows, nix] | ||
<<: *run_release | ||
|
||
- node/test: | ||
|
@@ -244,9 +252,12 @@ workflows: | |
- "Run cargo tests + studio integration tests (stable rust on amd_windows)" | ||
- "Run studio integration tests in GitHub Actions (amd_macos)" | ||
- "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)" | ||
- "Test installation for Javascript Package Managers (npm on nix)" | ||
- "Test installation for Javascript Package Managers (npm_global on nix)" | ||
- "Test installation for Javascript Package Managers (pnpm on nix)" | ||
- "Test installation for Javascript Package Managers (npm on windows)" | ||
- "Test installation for Javascript Package Managers (npm_global on windows)" | ||
- "Test installation for Javascript Package Managers (pnpm on windows)" | ||
- "Test NPM Installer Scripts" | ||
<<: *run_release | ||
|
||
|
@@ -348,15 +359,42 @@ jobs: | |
package_manager: | ||
type: enum | ||
enum: ["npm", "npm_global", "pnpm"] | ||
executor: node_js | ||
platform: | ||
type: enum | ||
enum: ["nix", "windows"] | ||
executor: node_js_<<parameters.platform>> | ||
steps: | ||
- checkout: | ||
path: "rover" | ||
- run: | ||
name: "Invoke Install Scripts" | ||
command: | | ||
cd rover/.circleci/scripts | ||
./install_<< parameters.package_manager >>.sh | ||
- when: | ||
condition: | ||
equal: ["nix", <<parameters.platform>>] | ||
steps: | ||
- run: | ||
name: "Invoke Install Scripts (Unix)" | ||
command: | | ||
cd rover/.circleci/scripts/<<parameters.platform>> | ||
./install_<< parameters.package_manager >>.sh | ||
- when: | ||
condition: | ||
equal: ["windows", <<parameters.platform>>] | ||
steps: | ||
- run: | ||
name: "Invoke Install Scripts (Windows)" | ||
command: | | ||
Write-Output "Installing Volta" | ||
choco install volta | ||
refreshenv | ||
Write-Output "Installing Node & NPM" | ||
volta install [email protected] | ||
Write-Output "Checking Node & NPM version" | ||
node --version | ||
npm --version | ||
$script_location=Join-Path rover\.circleci\scripts << parameters.platform >> | ||
Set-Location $script_location | ||
.\install_<< parameters.package_manager >>.ps1 | ||
|
||
# reusable command snippets can be referred to in any `steps` object | ||
commands: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
Function New-TemporaryFolder { | ||
# Make a new folder based upon a TempFileName | ||
$TEMP_PATH=[System.IO.Path]::GetTempPath() | ||
$T= Join-Path $TEMP_PATH tmp$([convert]::tostring((get-random 65535),16).padleft(4,'0')) | ||
New-Item -ItemType Directory -Path $T | ||
} | ||
|
||
# Find the installers directory | ||
$installer_dir = [System.IO.Path]::Combine($PSScriptRoot, "..", "..", "..", "installers", "npm") | ||
Write-Output "Found installers directory at $installer_dir" | ||
|
||
# Create a temporary folder for the test | ||
$test_dir = New-TemporaryFolder | ||
Write-Output "Created test directory at $test_dir" | ||
Set-Location $test_dir | ||
# Initialise an empty NPM package | ||
npm init -y | ||
Write-Output "Initialised new npm package" | ||
|
||
# The choice of version here is arbitrary (we just need something we know exists) so that we can test if the | ||
# installer works, given an existing version. This way we're not at the mercy of whether the binary that corresponds | ||
# to the latest commit exists. | ||
npm --prefix "$installer_dir" version --allow-same-version 0.23.0 | ||
Write-Output "Temporarily patched package.json to fixed stable binary" | ||
|
||
# Install all the dependencies, including `rover` | ||
npm install --install-links=true "$installer_dir" | ||
Write-Output "Installed rover as local npm package" | ||
|
||
# Move to the installed location | ||
$node_modules_path=[System.IO.Path]::Combine($test_dir, "node_modules", ".bin") | ||
Set-Location $node_modules_path | ||
|
||
# Check the version | ||
Write-Output "Checking version" | ||
$dir_sep=[IO.Path]::DirectorySeparatorChar | ||
$rover_command=".${dir_sep}rover --version" | ||
Invoke-Expression $rover_command | ||
Write-Output "Checked version, all ok!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
Function New-TemporaryFolder { | ||
# Make a new folder based upon a TempFileName | ||
$TEMP_PATH=[System.IO.Path]::GetTempPath() | ||
$T= Join-Path $TEMP_PATH tmp$([convert]::tostring((get-random 65535),16).padleft(4,'0')) | ||
New-Item -ItemType Directory -Path $T | ||
} | ||
|
||
# Find the installers directory | ||
$installer_dir = [System.IO.Path]::Combine($PSScriptRoot, "..", "..", "..", "installers", "npm") | ||
Write-Output "Found installers directory at $installer_dir" | ||
|
||
# Create a temporary folder for the test | ||
$test_dir = New-TemporaryFolder | ||
Write-Output "Created test directory at $test_dir" | ||
Set-Location $test_dir | ||
|
||
# The choice of version here is arbitrary (we just need something we know exists) so that we can test if the | ||
# installer works, given an existing version. This way we're not at the mercy of whether the binary that corresponds | ||
# to the latest commit exists. | ||
npm --prefix "$installer_dir" version --allow-same-version 0.23.0 | ||
Write-Output "Temporarily patched package.json to fixed stable binary" | ||
|
||
# Install all the dependencies, including `rover` | ||
npm install --install-links=true -g "$installer_dir" | ||
Write-Output "Installed rover as global npm package" | ||
|
||
# Check the version | ||
Write-Output "Checking version" | ||
rover --version | ||
Write-Output "Checked version, all ok!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
Function New-TemporaryFolder { | ||
# Make a new folder based upon a TempFileName | ||
$TEMP_PATH=[System.IO.Path]::GetTempPath() | ||
$T= Join-Path $TEMP_PATH tmp$([convert]::tostring((get-random 65535),16).padleft(4,'0')) | ||
New-Item -ItemType Directory -Path $T | ||
} | ||
|
||
# Find the installers directory | ||
$installer_dir = [System.IO.Path]::Combine($PSScriptRoot, "..", "..", "..", "installers", "npm") | ||
Write-Output "Found installers directory at $installer_dir" | ||
|
||
# Create a temporary folder for the test | ||
$test_dir = New-TemporaryFolder | ||
Write-Output "Created test directory at $test_dir" | ||
Set-Location $test_dir | ||
# Install pnpm | ||
npm install -g pnpm@v9.3.0 | ||
|
||
# The choice of version here is arbitrary (we just need something we know exists) so that we can test if the | ||
# installer works, given an existing version. This way we're not at the mercy of whether the binary that corresponds | ||
# to the latest commit exists. | ||
npm --prefix "$installer_dir" version --allow-same-version 0.23.0 | ||
Write-Output "Temporarily patched package.json to fixed stable binary" | ||
|
||
# Install all the dependencies, including `rover` | ||
pnpm init | ||
pnpm add "file:$installer_dir" | ||
Write-Output "Installed rover as local npm package" | ||
|
||
# Move to the installed location | ||
$node_modules_path=[System.IO.Path]::Combine($test_dir, "node_modules", ".bin") | ||
Set-Location $node_modules_path | ||
|
||
# Check the version | ||
Write-Output "Checking version" | ||
$dir_sep=[IO.Path]::DirectorySeparatorChar | ||
$rover_command=".${dir_sep}rover --version" | ||
Invoke-Expression $rover_command | ||
Write-Output "Checked version, all ok!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.