Skip to content

Commit fd9fc07

Browse files
authored
Merge pull request #33 from roc-lang/install-new-compiler
hidden install page for new compiler
2 parents 1761f22 + aeee3a5 commit fd9fc07

File tree

10 files changed

+603
-3
lines changed

10 files changed

+603
-3
lines changed

.github/workflows/CI.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
99
cancel-in-progress: true
1010

11+
env:
12+
ROC_NIGHTLY_VERSION: 2025-10-31-8553832
1113

1214
# Do not add permissions here! Configure them at the job level!
1315
permissions: {}
@@ -36,3 +38,180 @@ jobs:
3638
- run: |
3739
cd website
3840
roc check build_website.roc
41+
42+
test-install-script-unix:
43+
strategy:
44+
matrix:
45+
include:
46+
- os: ubuntu-24.04
47+
platform: linux
48+
arch: x86_64
49+
- os: ubuntu-24.04-arm
50+
platform: linux
51+
arch: arm64
52+
- os: macos-15
53+
platform: macos
54+
arch: apple_silicon
55+
- os: macos-15-intel
56+
platform: macos
57+
arch: x86_64
58+
runs-on: ${{ matrix.os }}
59+
timeout-minutes: 30
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Test install script (answer no to PATH)
64+
run: |
65+
cd website/content/installnew/install_scripts
66+
bash install_roc.sh <<< "n"
67+
68+
- name: Verify installation (no PATH)
69+
run: |
70+
cd website/content/installnew/install_scripts
71+
DIR_NAME="roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
72+
if [ ! -d "$DIR_NAME" ]; then
73+
echo "Error: Installation directory $DIR_NAME not found"
74+
exit 1
75+
fi
76+
77+
- name: Test roc binary (no PATH)
78+
run: |
79+
cd website/content/installnew/install_scripts
80+
DIR_NAME="roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
81+
"$DIR_NAME/roc" version
82+
83+
- name: Clean up for second test
84+
run: |
85+
cd website/content/installnew/install_scripts
86+
rm -rf roc_nightly-*
87+
88+
- name: Test install script (answer yes to PATH)
89+
run: |
90+
cd website/content/installnew/install_scripts
91+
bash install_roc.sh <<< "y"
92+
93+
- name: Verify PATH was updated
94+
run: |
95+
# Detect shell profile based on SHELL
96+
if [ -n "${SHELL:-}" ]; then
97+
case "$SHELL" in
98+
*/bash) PROFILE="$HOME/.bashrc" ;;
99+
*/zsh) PROFILE="$HOME/.zshrc" ;;
100+
*/fish) PROFILE="$HOME/.config/fish/config.fish" ;;
101+
*) PROFILE="$HOME/.profile" ;;
102+
esac
103+
else
104+
PROFILE="$HOME/.profile"
105+
fi
106+
107+
if ! grep -q "roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}" "$PROFILE"; then
108+
echo "Error: PATH not updated in $PROFILE"
109+
exit 1
110+
fi
111+
echo "✅ PATH successfully updated in $PROFILE"
112+
113+
test-install-script-windows:
114+
strategy:
115+
matrix:
116+
include:
117+
- os: windows-2022
118+
arch: x86_64
119+
proc_arch: AMD64
120+
- os: windows-2025
121+
arch: x86_64
122+
proc_arch: AMD64
123+
- os: windows-11-arm
124+
arch: arm64
125+
proc_arch: ARM64
126+
127+
runs-on: ${{ matrix.os }}
128+
timeout-minutes: 30
129+
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- name: Test install script (answer no to PATH)
134+
shell: pwsh
135+
env:
136+
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
137+
run: |
138+
Set-Location website\content\installnew\install_scripts
139+
"n" | pwsh -ExecutionPolicy Bypass -File .\install_roc.ps1
140+
141+
- name: Verify installation (no PATH)
142+
shell: pwsh
143+
run: |
144+
Set-Location website\content\installnew\install_scripts
145+
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
146+
if (-not (Test-Path $dirName)) {
147+
Write-Error "❌ Installation directory $dirName not found"
148+
} else {
149+
Write-Host "✅ Found $dirName"
150+
}
151+
152+
- name: Test roc binary (no PATH) – x86_64 only
153+
if: ${{ matrix.arch == 'x86_64' }}
154+
shell: pwsh
155+
run: |
156+
Set-Location website\content\installnew\install_scripts
157+
$dirName = "roc_nightly-windows_x86_64-${{ env.ROC_NIGHTLY_VERSION }}"
158+
$rocPath = Join-Path $dirName "roc.exe"
159+
if (-not (Test-Path $rocPath)) {
160+
Write-Host "❌ roc.exe not found at $rocPath"
161+
Write-Host "Contents of ${dirName}:"
162+
Get-ChildItem $dirName -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $_" }
163+
exit 1
164+
} else {
165+
Write-Host "Running roc.exe version..."
166+
& $rocPath version
167+
}
168+
169+
- name: Clean up for second test
170+
shell: pwsh
171+
run: |
172+
Set-Location website\content\installnew\install_scripts
173+
Get-Item .\roc_nightly-* -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force
174+
Write-Host "🧹 Cleaned up previous installation directories"
175+
176+
- name: Test install script (answer yes to PATH)
177+
shell: pwsh
178+
env:
179+
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
180+
run: |
181+
Set-Location website\content\installnew\install_scripts
182+
"y" | pwsh -ExecutionPolicy Bypass -File .\install_roc.ps1
183+
184+
- name: Verify PATH was updated
185+
shell: pwsh
186+
env:
187+
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
188+
run: |
189+
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
190+
191+
# The script uses SetEnvironmentVariable("Path", "User")
192+
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
193+
194+
if ([string]::IsNullOrEmpty($userPath)) {
195+
Write-Error "❌ User PATH is empty or not readable"
196+
exit 1
197+
}
198+
199+
if ($userPath -notlike "*$dirName*") {
200+
Write-Error "❌ PATH not updated with $dirName"
201+
exit 1
202+
} else {
203+
Write-Host "✅ PATH successfully updated with $dirName"
204+
}
205+
206+
- name: Test roc binary (after PATH update)
207+
shell: pwsh
208+
run: |
209+
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
210+
$rocPath = Join-Path $PWD "website\content\installnew\install_scripts\$dirName\roc.exe"
211+
212+
# Pull the updated user PATH and merge into current session
213+
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
214+
$env:PATH = "$userPath;$env:PATH"
215+
216+
Write-Host "Running roc.exe version..."
217+
roc.exe version

website/content/install/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ If you are looking for more resources to learn about Roc, check out the followin
5252
- [Roc Examples](/examples)
5353
- [Roc Guides](/docs#guides)
5454
- [Roc Language Reference](/docs#language-reference)
55-
- [Roc Exercism Track](https://exercism.org/tracks/roc)
55+
- [Roc Exercism Track](https://exercism.org/tracks/roc)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Install
2+
3+
<div class="banner">
4+
Roc is a <b>Work in Progress!</b>
5+
</div>
6+
7+
<!-- TODO detect current OS with browser and show that one first -->
8+
<!-- TODO docker release -->
9+
- [Linux or macOS](/installnew/unix)
10+
- [Windows](/installnew/windows)
11+
- [Other Systems](/installnew/other)
12+
13+
<!-- TODO mention editor plugins once they are up to date -->
14+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Roc Nightly Installer for Windows
2+
# Downloads, verifies, extracts, and (optionally) adds Roc to the user PATH.
3+
# Based on your 2025-10-31 nightly.
4+
5+
$ErrorActionPreference = "Stop"
6+
7+
# ---- Configuration ----
8+
$VersionDate = "2025-10-31"
9+
$BuildId = "8553832"
10+
$BaseUrl = "https://github.com/roc-lang/nightlies/releases/download/nightly-2025-October-31-$BuildId"
11+
12+
# Known SHA256 checksums for Windows
13+
$Sha_Windows_x86_64 = "1d37d0262ec272cca1c7a32acb23b7c02115cc94a11e721bf50ddb352943f332"
14+
$Sha_Windows_arm64 = "6c148e8e362c9a594446145481f872d5777a02d6c47d3320f92377be5b9a60d6"
15+
16+
# ---- Detect architecture ----
17+
$arch = $env:PROCESSOR_ARCHITECTURE
18+
switch ($arch.ToLower()) {
19+
"amd64" { $ArchName = "x86_64" }
20+
"arm64" { $ArchName = "arm64" }
21+
default { throw "Unsupported architecture: $arch" }
22+
}
23+
24+
$Platform = "windows"
25+
26+
# ---- Pick the right file ----
27+
# You gave us the exact filenames, so we can just branch:
28+
if ($ArchName -eq "x86_64") {
29+
$File = "roc_nightly-windows_x86_64-$VersionDate-$BuildId.zip"
30+
$ExpectedSha = $Sha_Windows_x86_64
31+
} elseif ($ArchName -eq "arm64") {
32+
$File = "roc_nightly-windows_arm64-$VersionDate-$BuildId.zip"
33+
$ExpectedSha = $Sha_Windows_arm64
34+
} else {
35+
throw "No Windows artifact for architecture $ArchName"
36+
}
37+
38+
$Url = "$BaseUrl/$File"
39+
40+
Write-Host "➡️ Step 1: Downloading Roc for $Platform ($ArchName)..."
41+
$downloadPath = Join-Path $PWD $File
42+
43+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
44+
Invoke-WebRequest -Uri $Url -OutFile $downloadPath -UseBasicParsing
45+
Write-Host "✅ Download complete: $downloadPath"
46+
Write-Host ""
47+
48+
# ---- Verify SHA256 ----
49+
Write-Host "🔒 Step 2: Checking file integrity..."
50+
$actualHash = (Get-FileHash -Algorithm SHA256 -Path $downloadPath).Hash.ToLower()
51+
if ($actualHash -ne $ExpectedSha.ToLower()) {
52+
Write-Host "❌ Checksum mismatch!"
53+
Write-Host "Expected: $ExpectedSha"
54+
Write-Host "Actual: $actualHash"
55+
throw "The file might be corrupted. Aborting."
56+
} else {
57+
Write-Host "✅ File verified successfully!"
58+
Write-Host ""
59+
}
60+
61+
# ---- Extract ----
62+
Write-Host "📦 Step 3: Extracting files..."
63+
64+
$installDirName = "roc_nightly-$Platform`_$ArchName-$VersionDate-$BuildId"
65+
$installDir = Join-Path $PWD $installDirName
66+
67+
Expand-Archive -Path $downloadPath -DestinationPath $PWD -Force
68+
69+
Write-Host "✅ Roc was extracted to: $installDir"
70+
Write-Host ""
71+
72+
Write-Host @"
73+
⭐ Step 4: Making Roc easy to run
74+
75+
Right now, Roc is installed in:
76+
$installDir
77+
78+
You can add that folder to your Windows user PATH so you can run `roc`
79+
from any new PowerShell or CMD window.
80+
"@
81+
82+
$folderToAdd = $installDir
83+
84+
# ---- Ask to add to PATH ----
85+
$answer = Read-Host "Would you like me to add Roc to your *user* PATH automatically? [y/N]"
86+
if ($answer -match '^(y|Y)$') {
87+
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
88+
89+
$pathParts = @()
90+
if ($currentPath) {
91+
$pathParts = $currentPath.Split(";") | Where-Object { $_ -ne "" }
92+
}
93+
94+
if ($pathParts -contains $folderToAdd) {
95+
Write-Host "ℹ️ PATH already contains $folderToAdd"
96+
} else {
97+
$newPath = if ($currentPath) { "$currentPath;$folderToAdd" } else { $folderToAdd }
98+
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
99+
Write-Host "✅ Added Roc to your user PATH."
100+
Write-Host " (Open a new terminal for it to take effect.)"
101+
}
102+
103+
Write-Host ""
104+
Write-Host "🎉 All done!"
105+
Write-Host "Open a new PowerShell and run: roc version"
106+
} else {
107+
Write-Host ""
108+
Write-Host "ℹ️ No problem!"
109+
Write-Host "To run Roc in *this* PowerShell session, run:"
110+
Write-Host ""
111+
Write-Host " `$env:PATH += `";$folderToAdd`""
112+
Write-Host ""
113+
Write-Host "Then:"
114+
Write-Host " roc version"
115+
Write-Host ""
116+
Write-Host "🎉 All done!"
117+
}

0 commit comments

Comments
 (0)