Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
build-and-test:
name: Build and smoke test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ npm run build

The static site is generated in `dist/`.

## Test

```bash
npm run build
npm test
```

The test command starts `vite preview` from the built `dist/` folder and checks that the app serves both `/` and a module deep route.

## CI

Pull requests to `main` run GitHub Actions on Linux (`ubuntu-latest`):

- `npm ci`
- `npm run build`
- `npm test`

## What Is Included

- Ukrainian, Ukrainian+Spanish, and Spanish-only language modes.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "bash scripts/smoke-test.sh"
},
"dependencies": {
"lucide-react": "^0.468.0",
Expand Down
34 changes: 34 additions & 0 deletions scripts/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

PORT="${PORT:-4173}"
HOST="127.0.0.1"
BASE_URL="http://${HOST}:${PORT}"
LOG_FILE="${TMPDIR:-/tmp}/plusik-vite-preview.log"

cleanup() {
if [[ -n "${SERVER_PID:-}" ]]; then
kill "${SERVER_PID}" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT

npm run preview -- --host "${HOST}" --port "${PORT}" >"${LOG_FILE}" 2>&1 &
SERVER_PID=$!

for _ in {1..30}; do
if curl -fsS "${BASE_URL}/" >/dev/null 2>&1; then
break
fi
if ! kill -0 "${SERVER_PID}" >/dev/null 2>&1; then
cat "${LOG_FILE}"
exit 1
fi
sleep 1
done

HOME_HTML="$(curl -fsS "${BASE_URL}/")"
MODULE_HTML="$(curl -fsS "${BASE_URL}/module/addition-no-carry")"

[[ "${HOME_HTML}" == *'<div id="root">'* ]]
[[ "${MODULE_HTML}" == *'<div id="root">'* ]]
Loading