etherpad-lite/.github/workflows/installer-test.yml
John McLear 301ae4df2c
feat: add one-line installer script (#7466) (#7485)
* feat: add one-line installer script (#7466)

Adds bin/installer.sh, a small POSIX shell script that:
- Verifies prerequisites (git, Node.js >= 18)
- Installs pnpm globally if missing (with sudo fallback)
- Clones etherpad-lite (configurable branch / dir)
- Runs `pnpm i` and `pnpm run build:etherpad`
- Optionally starts Etherpad if ETHERPAD_RUN=1

Users can now install Etherpad with a single command:

  curl -fsSL https://raw.githubusercontent.com/ether/etherpad-lite/master/bin/installer.sh | sh

README updated to feature the one-liner above the existing
Docker-Compose / manual install instructions.

Closes #7466

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add installer-test workflow + Windows PowerShell installer

- bin/installer.ps1: PowerShell port of installer.sh so the one-liner
  also works on Windows via 'irm ... | iex'.
- .github/workflows/installer-test.yml: end-to-end CI that runs each
  installer against the PR's own commit (via ETHERPAD_REPO/BRANCH env
  vars), verifies clone + node_modules + admin SPA artifacts, and
  smoke-tests by starting Etherpad and curling /api. Runs on
  ubuntu-latest, macos-latest, and windows-latest. Includes a
  shellcheck job for installer.sh.
- README: feature the Windows one-liner alongside the POSIX one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: fix windows smoke test - wrap pnpm in cmd /c

Start-Process can't run pnpm.cmd directly ("not a valid Win32 application").
Wrap it via cmd.exe /c instead, and bump the wait window to 90s for slower
Windows runners. Also dump stderr alongside stdout when the smoke test
fails for easier debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Qodo review on installer (#7485)

Two correctness issues caught by Qodo:

1. Node version mismatch: installer required Node >= 18, but the repo's
   engines.node is >= 20. Bump REQUIRED_NODE_MAJOR to 20 in both shell
   and PowerShell installers, and update the README's quick-install
   prerequisite and Requirements section to match.

2. Branch ignored for existing checkouts: when ETHERPAD_DIR already
   existed, the script ran 'git pull --ff-only' on whatever branch
   happened to be checked out, ignoring ETHERPAD_BRANCH and never
   verifying ETHERPAD_REPO. The existing-dir path now:
   - validates the remote URL matches ETHERPAD_REPO
   - refuses to clobber uncommitted changes (excluding pnpm-lock.yaml,
     which pnpm i rewrites during install)
   - fetches with --tags --prune
   - checks out ETHERPAD_BRANCH as a branch or detaches at it as a tag
   - prints the resulting commit short SHA for clarity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 17:10:22 +01:00

166 lines
5.8 KiB
YAML

name: "Installer test"
# Exercises bin/installer.sh and bin/installer.ps1 end-to-end so the
# one-line install paths in the README stay working.
on:
push:
paths:
- "bin/installer.sh"
- "bin/installer.ps1"
- ".github/workflows/installer-test.yml"
pull_request:
paths:
- "bin/installer.sh"
- "bin/installer.ps1"
- ".github/workflows/installer-test.yml"
permissions:
contents: read
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run shellcheck on installer.sh
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
shellcheck bin/installer.sh
installer-posix:
name: end-to-end install (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Pre-install pnpm (avoid sudo prompt in the installer)
run: npm install -g pnpm
- name: Run bin/installer.sh against this commit
env:
ETHERPAD_DIR: ${{ runner.temp }}/etherpad-installer-test
ETHERPAD_REPO: ${{ github.server_url }}/${{ github.repository }}.git
ETHERPAD_BRANCH: ${{ github.head_ref || github.ref_name }}
NO_COLOR: "1"
run: sh ./bin/installer.sh
- name: Verify clone + dependencies + build artifacts
shell: bash
env:
ETHERPAD_DIR: ${{ runner.temp }}/etherpad-installer-test
run: |
set -eux
test -d "$ETHERPAD_DIR/.git"
test -f "$ETHERPAD_DIR/package.json"
test -d "$ETHERPAD_DIR/node_modules"
test -d "$ETHERPAD_DIR/src/node_modules"
# build:etherpad copies the admin SPA into src/templates/admin
test -f "$ETHERPAD_DIR/src/templates/admin/index.html"
- name: Smoke test - start Etherpad and curl /api
shell: bash
env:
ETHERPAD_DIR: ${{ runner.temp }}/etherpad-installer-test
run: |
set -eu
cd "$ETHERPAD_DIR"
pnpm run prod >/tmp/etherpad.log 2>&1 &
PID=$!
# Wait up to 60s for the API to come up.
ok=0
for i in $(seq 1 60); do
if curl -fsS http://localhost:9001/api >/dev/null 2>&1; then
echo "Etherpad answered on /api after ${i}s"
ok=1
break
fi
sleep 1
done
if [ "$ok" != "1" ]; then
echo "Etherpad did not start within 60s. Last 200 lines of log:" >&2
tail -200 /tmp/etherpad.log >&2 || true
kill "$PID" 2>/dev/null || true
exit 1
fi
kill "$PID" 2>/dev/null || true
wait "$PID" 2>/dev/null || true
installer-windows:
name: end-to-end install (windows-latest)
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Pre-install pnpm
run: npm install -g pnpm
- name: Run bin/installer.ps1 against this commit
shell: pwsh
env:
ETHERPAD_DIR: ${{ runner.temp }}\etherpad-installer-test
ETHERPAD_REPO: ${{ github.server_url }}/${{ github.repository }}.git
ETHERPAD_BRANCH: ${{ github.head_ref || github.ref_name }}
NO_COLOR: "1"
run: ./bin/installer.ps1
- name: Verify clone + dependencies + build artifacts
shell: pwsh
env:
ETHERPAD_DIR: ${{ runner.temp }}\etherpad-installer-test
run: |
if (-not (Test-Path "$env:ETHERPAD_DIR\.git")) { throw '.git missing' }
if (-not (Test-Path "$env:ETHERPAD_DIR\package.json")) { throw 'package.json missing' }
if (-not (Test-Path "$env:ETHERPAD_DIR\node_modules")) { throw 'node_modules missing' }
if (-not (Test-Path "$env:ETHERPAD_DIR\src\node_modules")) { throw 'src/node_modules missing' }
if (-not (Test-Path "$env:ETHERPAD_DIR\src\templates\admin\index.html")) { throw 'admin SPA missing' }
- name: Smoke test - start Etherpad and curl /api
shell: pwsh
env:
ETHERPAD_DIR: ${{ runner.temp }}\etherpad-installer-test
run: |
Push-Location $env:ETHERPAD_DIR
$logPath = Join-Path $env:RUNNER_TEMP 'etherpad.log'
# pnpm on Windows is a .cmd shim, which Start-Process can't run
# directly — wrap it in cmd.exe.
$proc = Start-Process -FilePath cmd.exe `
-ArgumentList '/c','pnpm','run','prod' `
-RedirectStandardOutput $logPath `
-RedirectStandardError "$logPath.err" `
-PassThru -NoNewWindow
$ok = $false
for ($i = 1; $i -le 90; $i++) {
try {
Invoke-WebRequest -UseBasicParsing -Uri http://localhost:9001/api -TimeoutSec 2 | Out-Null
Write-Host "Etherpad answered on /api after ${i}s"
$ok = $true
break
} catch { Start-Sleep -Seconds 1 }
}
if (-not $ok) {
Write-Host 'Etherpad did not start within 90s. Last 200 lines of log (stdout):'
if (Test-Path $logPath) { Get-Content $logPath -Tail 200 }
Write-Host 'Last 200 lines of stderr:'
if (Test-Path "$logPath.err") { Get-Content "$logPath.err" -Tail 200 }
Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue
Pop-Location
exit 1
}
Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue
Pop-Location