ci: deploy simulator and run post-deploy UI tests
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
name: Test, deploy, and browser-test System Landscape Simulator
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test-build:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
- run: node --version && npm --version
|
||||
- run: npm ci --include=dev --prefer-offline --no-audit --no-fund
|
||||
- run: npm test
|
||||
- run: npm run build
|
||||
|
||||
deploy:
|
||||
if: ${{ gitea.event_name == 'push' }}
|
||||
needs: test-build
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
- name: Load deployment SSH key
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
- name: Deploy to port 7004
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" '
|
||||
set -Eeuo pipefail
|
||||
TARGET_DIR=/mnt/appdata/prod/SystemLandscapeSimulator
|
||||
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/SystemLandscapeSimulator.git
|
||||
mkdir -p "$TARGET_DIR"
|
||||
if [ ! -d "$TARGET_DIR/.git" ]; then
|
||||
git init "$TARGET_DIR"
|
||||
git -C "$TARGET_DIR" remote add origin "$REPO_URL"
|
||||
else
|
||||
git -C "$TARGET_DIR" remote set-url origin "$REPO_URL"
|
||||
fi
|
||||
GIT_SSH_COMMAND="ssh -p 222 -o StrictHostKeyChecking=no" git -C "$TARGET_DIR" fetch origin main
|
||||
git -C "$TARGET_DIR" reset --hard origin/main
|
||||
git -C "$TARGET_DIR" clean -fdx
|
||||
docker ps -q --filter publish=7004 | xargs -r docker rm -f
|
||||
docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" down --remove-orphans || true
|
||||
SYSTEM_LANDSCAPE_PORT=7004 docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" build
|
||||
SYSTEM_LANDSCAPE_PORT=7004 docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" up -d
|
||||
'
|
||||
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12; do
|
||||
curl --fail --silent --show-error --max-time 15 http://192.168.1.15:7004/healthz && exit 0
|
||||
sleep 5
|
||||
done
|
||||
exit 1
|
||||
|
||||
browser-test:
|
||||
if: ${{ gitea.event_name == 'push' }}
|
||||
needs: deploy
|
||||
timeout-minutes: 20
|
||||
runs-on: docker
|
||||
env:
|
||||
E2E_BASE_URL: https://syssim.dumas.ddns.net
|
||||
PLAYWRIGHT_BROWSERS_PATH: .playwright
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- run: npm ci --include=dev --prefer-offline --no-audit --no-fund
|
||||
- run: npx playwright install --with-deps chromium
|
||||
- run: npm run test:ui
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --include=dev
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.27-alpine
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
@@ -54,6 +54,21 @@ npm run build
|
||||
# Browser UI smoke tests (requires a Playwright browser install once)
|
||||
npx playwright install chromium
|
||||
npm run test:ui
|
||||
|
||||
## Docker deployment
|
||||
|
||||
The production image is a static Nginx container. It serves the simulator on
|
||||
port 80 inside the container and uses `SYSTEM_LANDSCAPE_PORT` for the host
|
||||
port (7004 by default):
|
||||
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
curl http://localhost:7004/healthz
|
||||
```
|
||||
|
||||
The Gitea workflow builds and deploys `main` to port 7004, then runs the
|
||||
Playwright suite against `https://syssim.dumas.ddns.net`. The post-deploy
|
||||
browser job fails the workflow if the deployed UI does not pass.
|
||||
```
|
||||
|
||||
## Limitations
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
container_name: system-landscape-simulator
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${SYSTEM_LANDSCAPE_PORT:-7004}:80"
|
||||
@@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location = /healthz {
|
||||
access_log off;
|
||||
add_header Content-Type text/plain;
|
||||
return 200 'ok\n';
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,18 @@ export default defineConfig({
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
reporter: 'html',
|
||||
use: {
|
||||
baseURL: 'http://127.0.0.1:5173',
|
||||
baseURL: process.env.E2E_BASE_URL || 'http://127.0.0.1:5173',
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
},
|
||||
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
||||
webServer: {
|
||||
command: 'npm run dev -- --host 127.0.0.1',
|
||||
url: 'http://127.0.0.1:5173',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 30_000,
|
||||
},
|
||||
...(process.env.E2E_BASE_URL ? {} : {
|
||||
webServer: {
|
||||
command: 'npm run dev -- --host 127.0.0.1',
|
||||
url: 'http://127.0.0.1:5173',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 30_000,
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ test('loads the demo and advances a scenario', async ({ page }) => {
|
||||
test('places a preset and keeps the new system editable', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Presets' }).click()
|
||||
await page.locator('.preset-item .run-mini').first().click()
|
||||
await expect(page.getByRole('heading', { name: /Place preset/ })).toBeVisible()
|
||||
await expect(page.locator('.preset-modal')).toBeVisible()
|
||||
await page.getByRole('button', { name: 'Place system' }).click()
|
||||
await expect(page.locator('.inspector-content').first()).toContainText('Save system')
|
||||
})
|
||||
@@ -34,7 +34,8 @@ test('persists an edited scenario across refresh', async ({ page }) => {
|
||||
test('enters and exits presentation mode', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Presentation mode' }).click()
|
||||
await expect(page.getByRole('button', { name: 'Exit presentation' })).toBeVisible()
|
||||
await expect(page.locator('.topbar')).toBeHidden()
|
||||
await expect(page.locator('.playback')).toBeVisible()
|
||||
await expect(page.locator('.failure-config')).toBeHidden()
|
||||
await page.getByRole('button', { name: 'Exit presentation' }).click()
|
||||
await expect(page.getByRole('button', { name: 'Presentation mode' })).toBeVisible()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user