Skip to content

Commit 605a6ef

Browse files
NejcSclaude
andcommitted
add non-interactive install.ps1 + windows install smoke job
Slice 1 of the Windows e2e port: mirror the bash CODEPLAIN_INSTALL_NONINTERACTIVE contract in install.ps1 (skip Read-Host prompts and Clear-Host calls), and add a windows-latest workflow job that just runs install.ps1 and verifies `codeplain --help`. The pytest-based render/run flow comes in a follow-up once we confirm install.ps1 works non-interactively on a real GHA runner. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent bba36ef commit 605a6ef

2 files changed

Lines changed: 84 additions & 35 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,29 @@ jobs:
4343
uses: actions/upload-artifact@v4
4444
with:
4545
name: e2e-outputs-linux
46-
path: /tmp/pytest-of-runner/**/container_work*/**
46+
path: /tmp/pytest-of-runner/**/container_work*/**
47+
48+
# Slice 1: smoke-test that install.ps1 runs non-interactively on a real
49+
# windows-latest runner. The pytest-based render/run flow will be added in a
50+
# follow-up commit once this is green.
51+
e2e-windows:
52+
runs-on: windows-latest
53+
timeout-minutes: 15
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Run install.ps1 non-interactively
58+
env:
59+
CODEPLAIN_API_KEY: ${{ secrets.CODEPLAIN_API_KEY }}
60+
CODEPLAIN_INSTALL_NONINTERACTIVE: '1'
61+
shell: pwsh
62+
run: ./install/powershell/install.ps1
63+
64+
- name: Verify codeplain is installed
65+
shell: pwsh
66+
run: |
67+
# install.ps1 persists PATH changes to the user registry but the
68+
# current pwsh session has a stale Path. Refresh it from the registry
69+
# so `codeplain` is discoverable here.
70+
$env:Path = [Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [Environment]::GetEnvironmentVariable('Path', 'Machine')
71+
codeplain --help

install/powershell/install.ps1

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
$ErrorActionPreference = 'Stop'
22

3+
# Non-interactive mode for unattended installs (CI, scripted setup). Skips all
4+
# prompts and Clear-Host calls. Same env var name as install.sh.
5+
$nonInteractive = ($env:CODEPLAIN_INSTALL_NONINTERACTIVE -eq "1")
6+
if ($nonInteractive) {
7+
Write-Host "running in non-interactive mode (CODEPLAIN_INSTALL_NONINTERACTIVE=1)"
8+
}
9+
310
# Base URL for additional scripts
411
if (-not $env:CODEPLAIN_SCRIPTS_BASE_URL) {
512
$env:CODEPLAIN_SCRIPTS_BASE_URL = "https://codeplain.ai"
@@ -34,7 +41,7 @@ $env:GRAY_LIGHT = $GRAY_LIGHT
3441
$env:BOLD = $BOLD
3542
$env:NC = $NC
3643

37-
Clear-Host
44+
if (-not $nonInteractive) { Clear-Host }
3845
Write-Host "started ${YELLOW}${BOLD}*codeplain CLI${NC} installation..."
3946

4047
# Install uv if not present
@@ -94,7 +101,7 @@ if ($codeplainLine) {
94101
Write-Host "installing codeplain...${NC}"
95102
Write-Host ""
96103
uv tool install codeplain
97-
Clear-Host
104+
if (-not $nonInteractive) { Clear-Host }
98105
Write-Host "${GREEN}✓ codeplain installed successfully!${NC}"
99106
}
100107

@@ -119,25 +126,34 @@ Write-Host ""
119126
# Check if API key already exists
120127
$skipApiKeySetup = $false
121128
if ($env:CODEPLAIN_API_KEY) {
122-
Write-Host " you already have an API key configured."
123-
Write-Host ""
124-
Write-Host " would you like to log in and get a new one?"
125-
Write-Host ""
126-
$getNewKey = Read-Host " [y/N]"
127-
Write-Host ""
128-
129-
if ($getNewKey -notmatch '^[Yy]$') {
130-
Write-Host "${GREEN}${NC} using existing API key."
129+
if ($nonInteractive) {
130+
Write-Host "${GREEN}${NC} using existing CODEPLAIN_API_KEY (non-interactive mode)."
131131
$skipApiKeySetup = $true
132+
} else {
133+
Write-Host " you already have an API key configured."
134+
Write-Host ""
135+
Write-Host " would you like to log in and get a new one?"
136+
Write-Host ""
137+
$getNewKey = Read-Host " [y/N]"
138+
Write-Host ""
139+
140+
if ($getNewKey -notmatch '^[Yy]$') {
141+
Write-Host "${GREEN}${NC} using existing API key."
142+
$skipApiKeySetup = $true
143+
}
132144
}
133145
}
134146

135147
$apiKey = $null
136148
if (-not $skipApiKeySetup) {
137-
Write-Host "go to ${YELLOW}https://platform.codeplain.ai${NC} and sign up to get your API key."
138-
Write-Host ""
139-
$apiKey = Read-Host "paste your API key here"
140-
Write-Host ""
149+
if ($nonInteractive) {
150+
Write-Host "${GRAY}no CODEPLAIN_API_KEY set; skipping key setup (non-interactive mode).${NC}"
151+
} else {
152+
Write-Host "go to ${YELLOW}https://platform.codeplain.ai${NC} and sign up to get your API key."
153+
Write-Host ""
154+
$apiKey = Read-Host "paste your API key here"
155+
Write-Host ""
156+
}
141157
}
142158

143159
if ($skipApiKeySetup) {
@@ -155,7 +171,7 @@ if ($skipApiKeySetup) {
155171
}
156172

157173
# ASCII Art Welcome
158-
Clear-Host
174+
if (-not $nonInteractive) { Clear-Host }
159175
Write-Host ""
160176
Write-Host "${NC}"
161177
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
@@ -178,10 +194,14 @@ Write-Host ""
178194
Write-Host ""
179195
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
180196
Write-Host ""
181-
Write-Host " would you like to get a quick intro to ***plain specification language?"
182-
Write-Host ""
183-
$walkthroughChoice = Read-Host " [Y/n]"
184-
Write-Host ""
197+
if ($nonInteractive) {
198+
$walkthroughChoice = "n"
199+
} else {
200+
Write-Host " would you like to get a quick intro to ***plain specification language?"
201+
Write-Host ""
202+
$walkthroughChoice = Read-Host " [Y/n]"
203+
Write-Host ""
204+
}
185205

186206
# Determine script directory for local execution
187207
$ScriptDir = ""
@@ -225,27 +245,31 @@ if ($walkthroughChoice -notmatch '^[Nn]$') {
225245
}
226246

227247
# Download examples step
228-
Clear-Host
229-
Write-Host ""
230-
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
231-
Write-Host " ${YELLOW}${BOLD}Example Projects${NC}"
232-
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
233-
Write-Host ""
234-
Write-Host " we've prepared some example Plain projects for you"
235-
Write-Host " to explore and experiment with."
236-
Write-Host ""
237-
Write-Host " would you like to download them?"
238-
Write-Host ""
239-
$downloadExamples = Read-Host " [Y/n]"
240-
Write-Host ""
248+
if ($nonInteractive) {
249+
$downloadExamples = "n"
250+
} else {
251+
Clear-Host
252+
Write-Host ""
253+
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
254+
Write-Host " ${YELLOW}${BOLD}Example Projects${NC}"
255+
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
256+
Write-Host ""
257+
Write-Host " we've prepared some example Plain projects for you"
258+
Write-Host " to explore and experiment with."
259+
Write-Host ""
260+
Write-Host " would you like to download them?"
261+
Write-Host ""
262+
$downloadExamples = Read-Host " [Y/n]"
263+
Write-Host ""
264+
}
241265

242266
# Run examples download if user agrees
243267
if ($downloadExamples -notmatch '^[Nn]$') {
244268
Invoke-SubScript "examples.ps1"
245269
}
246270

247271
# Final message
248-
Clear-Host
272+
if (-not $nonInteractive) { Clear-Host }
249273
Write-Host ""
250274
Write-Host "${GRAY}────────────────────────────────────────────${NC}"
251275
Write-Host " ${YELLOW}${BOLD}You're all set!${NC}"

0 commit comments

Comments
 (0)